aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-node/src/main
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2020-04-02 00:38:22 +0100
committerefiacor <fiachra.corcoran@est.tech>2020-04-02 02:30:51 +0100
commit786c7b6d347aeb944275fc76a796424573b1b632 (patch)
treea98e485aa2de45f1d7acdee62f68f2b0c593f870 /datarouter-node/src/main
parent1f947ed6d1ce86108a00153cbcd0e98ba881fd3e (diff)
AAF common name bug fix
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: I18f6dbbcb4310b510070b11fee30badba953a05d Issue-ID: DMAAP-1420
Diffstat (limited to 'datarouter-node/src/main')
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
index d4fc7dbe..37e5db60 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
@@ -47,6 +47,9 @@ import java.util.Enumeration;
import java.util.TimeZone;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Rdn;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
@@ -315,15 +318,16 @@ public class NodeUtils {
X509Certificate cert = (X509Certificate) ks.getCertificate(alias);
if (cert != null) {
String subject = cert.getSubjectX500Principal().getName();
- String[] parts = subject.split(",");
- if (parts.length < 1) {
- return null;
+ try {
+ LdapName ln = new LdapName(subject);
+ for (Rdn rdn : ln.getRdns()) {
+ if (rdn.getType().equalsIgnoreCase("CN")) {
+ return rdn.getValue().toString();
+ }
+ }
+ } catch (InvalidNameException e) {
+ eelfLogger.error("No valid CN not found for dr-node cert", e);
}
- subject = parts[5].trim();
- if (!subject.startsWith("CN=")) {
- return null;
- }
- return subject.substring(3);
}
}
return null;