@Test public void testMissingPhraseFile() throws Exception { PhraseService phraseService = new FilePhraseService(util.resolveFile("target/test-classes/missing.enc")); PasswordHelper underTest = new PasswordHelper(new MavenCipherImpl(new CryptoHelperImpl()), phraseService); String password = "clear-text-password"; try { underTest.encrypt(password); fail("Expected RuntimeException wrapping FileNotFoundException"); } catch (RuntimeException e) { assertThat(e.getCause(), is(instanceOf(FileNotFoundException.class))); } }
@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);  }