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());
}
}
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);
}
}
// 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
// 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