diff options
Diffstat (limited to 'datarouter-node/src')
6 files changed, 52 insertions, 42 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; diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtilsTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtilsTest.java index 927b8bef..ccf2744e 100644 --- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtilsTest.java +++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtilsTest.java @@ -36,6 +36,6 @@ public class NodeAafPropsUtilsTest { @Test public void Veirfy_Aaf_Pass_Decryp_Successful() { - Assert.assertEquals("tVac2#@Stx%tIOE^x[c&2fgZ", nodeAafPropsUtils.getDecryptedPass("cadi_keystore_password")); + Assert.assertEquals("V+b}aGuWxHI+BPSNMVXqD*bx", nodeAafPropsUtils.getDecryptedPass("cadi_keystore_password")); } } diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java index 2d87b8b9..9832785e 100644 --- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java +++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java @@ -78,8 +78,14 @@ public class NodeUtilsTest { } @Test - public void Given_Get_CanonicalName_Called_Valid_CN_Returned() { + public void Given_Get_CanonicalName_Called_Valid_CN_Returned_From_JKS() { String canonicalName = NodeUtils.getCanonicalName("jks", "src/test/resources/org.onap.dmaap-dr-test-cert.jks", "WGxd2P6MDo*Bi4+UdzWs{?$8"); Assert.assertEquals("dmaap-dr-node", canonicalName); } + + @Test + public void Given_Get_CanonicalName_Called_Valid_CN_Returned_From_P12() { + String canonicalName = NodeUtils.getCanonicalName("PKCS12", "src/test/resources/aaf/org.onap.dmaap-dr.p12", "V+b}aGuWxHI+BPSNMVXqD*bx"); + Assert.assertEquals("dmaap-dr-node", canonicalName); + } } diff --git a/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.cred.props b/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.cred.props index 70d01908..f63286f3 100644 --- a/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.cred.props +++ b/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.cred.props @@ -4,14 +4,14 @@ # on 2019-10-02T14:25:19.002+0000 # @copyright 2019, AT&T ############################################################ -Challenge=enc:wQM4uZbepQQWfJd9uhcfPZJc7TAOnfTnj5xv9uCRteQOTuc7mSXAWjg9heC7lXod +Challenge=enc:HJsK_drz0D2MDwwSw-8DRU9HMrZKkyoLzJoHmSWzVNmfV60-Thvzv8cVzE_5muYb cadi_alias=dmaap-dr-node@dmaap-dr.onap.org -cadi_key_password=enc:YhS5u9Fqt-ssUs-1wWrv7xkOliMQDb8d7kmKKK2QwtwQu4Q7i_psLw0baQ-NY3mF +cadi_key_password=enc:9dftI1cNP6buWnYEeCezE20kaEM7FXz7uZnRfbtQWJKw6F6Xgph6VOG8PCItM7Q9 cadi_keyfile=src/test/resources/aaf/org.onap.dmaap-dr.keyfile cadi_keystore=src/test/resources/aaf/org.onap.dmaap-dr.p12 -cadi_keystore_password=enc:NwhywpJzc4rlcpwkPRs4GWkOliMQDb8d7kmKKK2QwtwQu4Q7i_psLw0baQ-NY3mF -cadi_keystore_password_jks=enc:McsNbnuHb5tgoa_UMgdTdHqWEG4bt6VcPsc_NTzS277aDcrNRutDSBDYyyLD5no2 -cadi_keystore_password_p12=enc:NwhywpJzc4rlcpwkPRs4GWkOliMQDb8d7kmKKK2QwtwQu4Q7i_psLw0baQ-NY3mF +cadi_keystore_password=enc:HRDU37Il5FnfAIi9F7Hk76nenrM67n38irDqaZMq47tAu2o-KS3pCwiXSly0WZ0L +cadi_keystore_password_jks=enc:xra37lQs-DyHe714sczkXACFJqtvylqj01qbqaC39bvkDMd0qInjg_pib9aJDM9S +cadi_keystore_password_p12=enc:HRDU37Il5FnfAIi9F7Hk76nenrM67n38irDqaZMq47tAu2o-KS3pCwiXSly0WZ0L cadi_truststore=src/test/resources/aaf/org.onap.dmaap-dr.trust.jks cadi_truststore_password=enc:xWbQBg4WdbHbQgvKGrol0ns16g9jgFYteR3nQkwTl65BtvtWf_ZKhSVP8w_Z0VHU cadi_x509_issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US diff --git a/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.keyfile b/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.keyfile index cbed0407..8794edd7 100644 --- a/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.keyfile +++ b/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.keyfile @@ -1,27 +1,27 @@ -hPUFfq-4kxkPy1LmRi50b_bhcRn9BKecnkq0u-Uec6JnRIsMgqUiEYJMbxGCGEZquBLszBBPj2Ux -udBAZ5FPIp5IkQFX6NpXJTCqPW9lb4k6KVhRSqSocascKnbYdZxrdThqOaw26kDiw04NFzA7jwxF -G9m2IVWF9AaKx7jQAqaoy4SSK5g1OaI4fGqWQn4HW3HuVJ7cc52JUmrcIGIV-I_6pR0ZAPezHxGn -5k-0rErQEZBHfj0S1M74Lx-eOa7gRlj0b3O8Zq-yfOllRLBZiMLuTmWlVz4ikbmL_eNC2RmjuEyy -v-wFva0Y4dqXEVEj9FoBUAQy7vE-I6VxGRffQRAi4Mnz0v4ISkHPmiOJsYmIzjT2bWyLKloJENfQ -LhV180qF-7UrjWGI2DhlVV_r4AY32-KLU7HLECpKRSjeqhWva_nZAj7ELGvBBTftGDu3HKts_MqU -hb14f5482rHZGPDYv3dCsere31ShIF6WF_YNhO494RgdSMugvWDZwxQYngNjGTgxS8hKezD5erp_ -BoqMuI3xotgaKZluV8yrxsc-M-0F97hJGxn7k1y37jKQugGUNDEwsX5MiHFd9OYY5jY9Pdr2tEXk -PqEmZQXBeCXJOku7KQFwEl4nqkw-52JJS1PAks4v_dlkrJIL95q6zAQOrgSgc597_-0x90k22Zd8 -FowwHQ42R-bo9oRyO0Qbypzd1Ftzu7kCalYH35qcLyAiIOO9NYAwSi5tYldzHgUhVq4wb1aoomeP -HISpNJfT2rK-AGMZw3d3nXWK1b3ztkF-74nD2s-WuTLeomBni1eMiLED850GyRD4uB4j4zF_4dZF -OmT6iShH7RR-gTolGZSAG7sBbwNs3lks9usVWI0qSulQvHBs14QvOY7EmO4SMRueUMo6ZIaOJIkB -uxNzoM_yQ2mMb24AZm_tT1xqMbGf76oYcx8Mu4zcXFkoe-4xDA1D-HXiPtyOzj6K0ByR86aytY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NedMCQUCz_8GeKi5Luwt_we4uheZYF2um +2VVQmcHNk94hgA4jaiHBXnLK7qLHVLpRBaNvNjFI7GFI4CMIkhZV-e7ziPk1dauaUaeAI7Th2_Sb +lsyzGJ-pjF_l53QENjwTR5Dp6Dia61unCImJJ3xFcZuq-ewnWjdp8l8MBz5Sp5hOnkLEoL_M_FyF +zo6f868bB8Eqq_zn08Icb8QpvBQx62-GOg51jCdTCSKWJauTf_zhTNfdd2h-IO2RX03NYXr3ZDuo +j9KLodsG0FIwEdX91Ju_X1A15RJKKKK2aAhF1gPj1_pq4gsACcie4QGox7y1kbVMhqNJc0cStvxc +tcEQJd2cMfawVeHoOUpTXwfbUk_GaLPmodoks3Dm1f0M7WdsSme4_c4iRsrawRPXEnbhiEbstumq +koQUPe0f3hcCnmQPC2jLNZIISJNwp_BfziG9IlO0TuxKt9a_Qkmx22NKft4QXUSAgiMjffJP9OMj +jYeryZYGIRGjGgxZ-J5_2U65_lLhtwalQqmyAWl6ET41xpM5tUth-iOy3Sx1-jG4bRchnFzDxkL7 +iy-BD1lICg5UuDr2mMF3QxHkJ9UqNaDgY9ix9CFvIilyq9QJv1seweTllLd8BZzNnBpRytz3b4If +5GDts41sdx388IgIcj0zhwJZNwjWa7GJRKIHymq6rRGTlfDruski_En-Vqct0-74mpX3c9kSLY02 +QFU04YfTduCRnNnrAKRccTuo20HE5gC0g16R5BGJ-9puLzhmQfl96M-WfnHz-i9oYd_Yq235Uq6O +K2iuPqDFt1Ob9HUFH1F1X9MD8MbZnG8UD6CQMmJn3bO4r8zBpUo2pQMhAOHAWBHFE-5EscJ3APgg +YCvwlPjYBRn1za-kmn9pTQ0gr7TkqjwLKBtdeh6RFWmA2ebxzQ20UIDlzppHokQ652n7SQy1Cagy +BOmDZvZ91ylkv_aygfFsnsOqNFnCF9L6lo05rw9Bt_jzLjbuT-Up6IGyhkCy6I785e8gDyCX
\ No newline at end of file diff --git a/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.p12 b/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.p12 Binary files differindex b5c30479..607e2f89 100644 --- a/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.p12 +++ b/datarouter-node/src/test/resources/aaf/org.onap.dmaap-dr.p12 |