aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient/src
diff options
context:
space:
mode:
authoredyta <edyta.krukowska@nokia.com>2020-04-01 15:16:37 +0200
committeredyta <edyta.krukowska@nokia.com>2020-04-02 10:47:56 +0200
commit0ed89748a4c7b4def76f5a3479410946ca75f389 (patch)
treec88862dae3972668e115631d3eee4a114bca02bc /certServiceClient/src
parent917ec642c1b2237ecb8670e40283b03f392553af (diff)
Fix sonar issue Password
Issue-ID: AAF-1118 Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com> Change-Id: I07b50976f57c97c17ae5ffcd36775c7aba089c4f
Diffstat (limited to 'certServiceClient/src')
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreator.java4
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java18
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreatorTest.java4
3 files changed, 15 insertions, 11 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreator.java
index 6dc2ef87..43784609 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreator.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreator.java
@@ -43,13 +43,13 @@ public class KeystoreTruststoreCreator {
throws PemToPKCS12ConverterException {
Password password = generator.generate(PASSWORD_LENGTH);
creator.saveKeystoreData(converter.convertKeystore(data, password, CERTIFICATE_ALIAS, privateKey),
- password.getPassword());
+ password.getCurrentPassword());
}
public void createTruststore(List<String> data)
throws PemToPKCS12ConverterException {
Password password = generator.generate(PASSWORD_LENGTH);
creator.saveTruststoreData(converter.convertTruststore(data, password, TRUSTED_CERTIFICATE_ALIAS),
- password.getPassword());
+ password.getCurrentPassword());
}
}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java
index 09c65ca6..35ae9f96 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java
@@ -21,22 +21,26 @@
package org.onap.aaf.certservice.client.certification.conversion;
class Password {
+ // We are excluding this line in Sonar due to fact that
+ // PASSWORD_PATTERN does not contain password. This solution
+ // is safe.
+ // NOSONAR
private static final String PASSWORD_PATTERN = "[\\w$#]{16,}";
- private final String password;
+ private final String currentPassword;
- Password(String password) {
- this.password = password;
+ Password(String currentPassword) {
+ this.currentPassword = currentPassword;
}
- String getPassword() {
- return password;
+ String getCurrentPassword() {
+ return currentPassword;
}
char[] toCharArray() {
- return password.toCharArray();
+ return currentPassword.toCharArray();
}
boolean isCorrectPasswordPattern() {
- return password.matches(PASSWORD_PATTERN);
+ return currentPassword.matches(PASSWORD_PATTERN);
}
}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreatorTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreatorTest.java
index 04bccf0b..5921c316 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreatorTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/KeystoreTruststoreCreatorTest.java
@@ -54,7 +54,7 @@ class KeystoreTruststoreCreatorTest {
// then
verify(passwordGenerator, times(1)).generate(passwordLength);
verify(converter, times(1)).convertKeystore(certificates, password, alias, privateKey);
- verify(filesCreator, times(1)).saveKeystoreData(keystoreBytes, password.getPassword());
+ verify(filesCreator, times(1)).saveKeystoreData(keystoreBytes, password.getCurrentPassword());
}
@Test
@@ -75,6 +75,6 @@ class KeystoreTruststoreCreatorTest {
// then
verify(passwordGenerator, times(1)).generate(passwordLength);
verify(converter, times(1)).convertTruststore(certificates, password, alias);
- verify(filesCreator, times(1)).saveTruststoreData(truststoreBytes, password.getPassword());
+ verify(filesCreator, times(1)).saveTruststoreData(truststoreBytes, password.getCurrentPassword());
}
} \ No newline at end of file