@Test public void testLegacyPhraseFallback() throws Exception { String password = "clear-text-password"; String encodedPass = legacyPasswordHelper.encrypt(password); assertDecrypt(legacyPasswordHelper, encodedPass, password); assertDecrypt(customPasswordHelper, encodedPass, password); }
@Nullable public String encrypt(@Nullable final String password) { if (password == null) { return null; } if (mavenCipher.isPasswordCipher(password)) { log.warn("Value appears to be already encrypted", log.isDebugEnabled() ? new IllegalArgumentException() : null); return password; } String encodedPassword = mavenCipher.encrypt(password, phraseService.getPhrase(ENC)); if (encodedPassword != null && !encodedPassword.equals(password)) { return phraseService.mark(encodedPassword); } return encodedPassword; }
PasswordHelper extends ComponentSupport { @Nullable public String encrypt(@Nullable final String password) { if (password == null) { return null; } if (mavenCipher.isPasswordCipher(password)) { log.warn("Value appears to be already encrypted", log.isDebugEnabled() ? new IllegalArgumentException() : null); return password; } String encodedPassword = mavenCipher.encrypt(password, phraseService.getPhrase(ENC)); if (encodedPassword != null && !encodedPassword.equals(password)) { return phraseService.mark(encodedPassword); } return encodedPassword; } }
PasswordHelper extends ComponentSupport { @Nullable public String encrypt(@Nullable final String password) { if (password == null) { return null; } if (mavenCipher.isPasswordCipher(password)) { log.warn("Value appears to be already encrypted", log.isDebugEnabled() ? new IllegalArgumentException() : null); return password; } String encodedPassword = mavenCipher.encrypt(password, phraseService.getPhrase(ENC)); if (encodedPassword != null && !encodedPassword.equals(password)) { return phraseService.mark(encodedPassword); } return encodedPassword; } @Inject  PasswordHelper(final MavenCipher mavenCipher, final PhraseService phraseService); }
PasswordHelper extends ComponentSupport { @Nullable public String encrypt(@Nullable final String password) { if (password == null) { return null; } if (mavenCipher.isPasswordCipher(password)) { log.warn("Value appears to be already encrypted", log.isDebugEnabled() ? new IllegalArgumentException() : null); return password; } String encodedPassword = mavenCipher.encrypt(password, phraseService.getPhrase(ENC)); if (encodedPassword != null && !encodedPassword.equals(password)) { return phraseService.mark(encodedPassword); } return encodedPassword; } @Inject  PasswordHelper(final MavenCipher mavenCipher, final PhraseService phraseService); @Nullable String encrypt(@Nullable final String password); @Nullable String encryptChars(@Nullable final char[] chars); @Nullable String encryptChars(@Nullable final char[] chars, final int offset, final int length); @Nullable String decrypt(@Nullable final String encodedPassword); @Nullable char[] decryptChars(@Nullable final String encodedPassword); @Nullable String tryDecrypt(@Nullable final String encodedPassword); @Nullable char[] tryDecryptChars(@Nullable final String encodedPassword); }
PasswordHelper extends ComponentSupport { @Nullable public String encrypt(@Nullable final String password) { if (password == null) { return null; } if (mavenCipher.isPasswordCipher(password)) { log.warn("Value appears to be already encrypted", log.isDebugEnabled() ? new IllegalArgumentException() : null); return password; } String encodedPassword = mavenCipher.encrypt(password, phraseService.getPhrase(ENC)); if (encodedPassword != null && !encodedPassword.equals(password)) { return phraseService.mark(encodedPassword); } return encodedPassword; } @Inject  PasswordHelper(final MavenCipher mavenCipher, final PhraseService phraseService); @Nullable String encrypt(@Nullable final String password); @Nullable String encryptChars(@Nullable final char[] chars); @Nullable String encryptChars(@Nullable final char[] chars, final int offset, final int length); @Nullable String decrypt(@Nullable final String encodedPassword); @Nullable char[] decryptChars(@Nullable final String encodedPassword); @Nullable String tryDecrypt(@Nullable final String encodedPassword); @Nullable char[] tryDecryptChars(@Nullable final String encodedPassword);  }