Use Jetty deobfuscation method on password strings 24/76124/1
authormark.j.leonard <mark.j.leonard@gmail.com>
Tue, 22 Jan 2019 12:42:30 +0000 (12:42 +0000)
committermark.j.leonard <mark.j.leonard@gmail.com>
Tue, 22 Jan 2019 12:57:46 +0000 (12:57 +0000)
Change-Id: Ifc36d8358c54f2602ecab2fb965461a6436bfcae
Issue-ID: AAI-2110
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
src/main/java/org/onap/aai/validation/config/RestConfig.java
src/main/java/org/onap/aai/validation/config/RuleIndexingConfig.java
src/main/java/org/onap/aai/validation/config/TopicConfig.java
src/test/java/org/onap/aai/validation/config/TestRestConfig.java
src/test/java/org/onap/aai/validation/config/TestTopicAdminConfig.java
src/test/java/org/onap/aai/validation/publisher/TestValidationEventPublisher.java
src/test/resources/rest-config/aai-environment.properties

index 344c203..b192e73 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.aai.validation.config;
 
 import java.util.Objects;
 import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.eclipse.jetty.util.security.Password;
 import org.springframework.beans.factory.annotation.Value;
 
 /**
@@ -111,7 +112,7 @@ public class RestConfig {
      * @return the decrypted password
      */
     public String getTrustStorePassword() {
-        return trustStorePassword;
+        return Password.deobfuscate(trustStorePassword);
     }
 
     public void setTrustStorePassword(String trustStorePassword) {
@@ -132,7 +133,7 @@ public class RestConfig {
      * @return the decrypted password
      */
     public String getKeyStorePassword() {
-        return keyStorePassword;
+        return Password.deobfuscate(keyStorePassword);
     }
 
     public void setKeyStorePassword(String keyStorePassword) {
index 67b0b8a..511df07 100644 (file)
@@ -20,7 +20,7 @@ package org.onap.aai.validation.config;
 import java.util.List;
 
 /**
- * Loads the properties needed by the controller using spring.
+ * Loads the properties needed by the controller using Spring.
  */
 public class RuleIndexingConfig extends PropertiesConfig {
 
index a167672..d769935 100644 (file)
@@ -24,11 +24,12 @@ import java.util.Objects;
 import java.util.Properties;
 import javax.annotation.Resource;
 import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.eclipse.jetty.util.security.Password;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 
 /**
- * Gets the configuration of the topics. The topics are configured using Spring in topic-config-beans.xml.
+ * Gets the configuration of the topics using Spring.
  */
 
 public class TopicConfig {
@@ -132,6 +133,7 @@ public class TopicConfig {
         private String consumerGroup;
         private String consumerId;
         private String transportType;
+        private String protocol;
 
         public String getName() {
             return name;
@@ -158,7 +160,7 @@ public class TopicConfig {
         }
 
         public String getPassword() {
-            return password;
+            return Password.deobfuscate(password);
         }
 
         public void setPassword(String password) {
index 313c847..0c632ee 100644 (file)
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
 import javax.inject.Inject;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.aai.validation.config.RestConfig;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
@@ -48,9 +47,9 @@ public class TestRestConfig {
         expectedRestConfig.setProtocol("https");
         expectedRestConfig.setBaseModelURI("${baseModelURI}");
         expectedRestConfig.setTrustStorePath("/dir1/dir2/trustStorePath");
-        expectedRestConfig.setTrustStorePassword("70c87528c88dcd9f9c2558d30e817868");
+        expectedRestConfig.setTrustStorePassword("OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
         expectedRestConfig.setKeyStorePath("/dir1/dir2/keyStorePath");
-        expectedRestConfig.setKeyStorePassword("70c87528c88dcd9f9c2558d30e817868");
+        expectedRestConfig.setKeyStorePassword("OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
         expectedRestConfig.setKeyManagerFactoryAlgorithm("AES");
         expectedRestConfig.setKeyStoreType("jks");
         expectedRestConfig.setSecurityProtocol("TLS");
index f6a6195..8e24f3a 100644 (file)
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
 import javax.inject.Inject;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.aai.validation.config.TopicAdminConfig;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
@@ -44,9 +43,9 @@ public class TestTopicAdminConfig {
         TopicAdminConfig expectedTopicAdminConfig = new TopicAdminConfig();
 
         expectedTopicAdminConfig.setPublishEnable(true);
-        expectedTopicAdminConfig.setPublishRetries(3l);
+        expectedTopicAdminConfig.setPublishRetries(3L);
         expectedTopicAdminConfig.setConsumeEnable(true);
-        expectedTopicAdminConfig.setConsumePollingIntervalSeconds(3l);
+        expectedTopicAdminConfig.setConsumePollingIntervalSeconds(3L);
 
         assertThat(expectedTopicAdminConfig, is(topicAdminConfig));
         assertThat(expectedTopicAdminConfig.hashCode(), is(topicAdminConfig.hashCode()));
index 8950e63..604312e 100644 (file)
@@ -31,6 +31,7 @@ import org.onap.aai.validation.publisher.ValidationEventPublisher;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import org.eclipse.jetty.util.security.Password;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -56,12 +57,12 @@ public class TestValidationEventPublisher {
         TopicAdminConfig mockTopicAdminConfig = Mockito.mock(TopicAdminConfig.class);
         when(mockTopicAdminConfig.isPublishEnable()).thenReturn(true);
 
-        Topic topic1 = new TopicConfig("poa-rule-validation","poa-audit-result").new Topic();
+        Topic topic1 = mockTopicConfig.new Topic();
         topic1.setName("aai-data-integrity");
         topic1.setHost("integrity-dummy-host");
         topic1.setPartition("integrity-dummy-partition");
         topic1.setUsername("integrity-dummy-username");
-        topic1.setPassword("integrity-dummy-password");
+        topic1.setPassword(Password.obfuscate("integrity-dummy-password"));
         topic1.setTransportType("integrity-dummy-transport-type");
         topicList.add(topic1);
 
index 988ae90..adfe002 100644 (file)
@@ -19,9 +19,9 @@ host=localhost
 port=8080
 httpProtocol=https
 trustStorePath=/dir1/dir2/trustStorePath
-trustStorePassword.x=70c87528c88dcd9f9c2558d30e817868
+trustStorePassword.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
 keyStorePath=/dir1/dir2/keyStorePath
-keyStorePassword.x=70c87528c88dcd9f9c2558d30e817868
+keyStorePassword.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
 keyManagerFactoryAlgorithm=AES
 keyStoreType=jks
 securityProtocol=TLS