diff options
author | efiacor <fiachra.corcoran@est.tech> | 2020-04-02 18:02:04 +0100 |
---|---|---|
committer | efiacor <fiachra.corcoran@est.tech> | 2020-04-02 18:19:17 +0100 |
commit | 2dfca3dc2f06f4e6319094bb006eff090178a8f1 (patch) | |
tree | 2a6655b5a1fe2814fd6cc9da90dcdda6d867e80b /datarouter-node/src/main/java/org/onap | |
parent | 6c364bc626f9bd5eb6d5dedd84bd823c3c26f91d (diff) |
New DR AAF certs for elalto branch2.2.0
Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Change-Id: I8459b64627eb79de37086dc061cf07e6dbac345f
Issue-ID: DMAAP-1421
Diffstat (limited to 'datarouter-node/src/main/java/org/onap')
-rw-r--r-- | datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java | 20 |
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; |