KettlePasswordService extends Base64PasswordService { @Override public String decrypt( String encryptedPassword ) throws PasswordServiceException { if ( StringUtil.isEmpty( encryptedPassword ) ) { return encryptedPassword; } else { if ( encryptedPassword.startsWith( prefix ) ) { return encoder.decode( encryptedPassword ); } else { return super.decrypt( encryptedPassword ); } } } KettlePasswordService(); @Override String encrypt( String password ); @Override String decrypt( String encryptedPassword );  }
@Test public void testDecryptWhiteSpacePasswordFallbackToBase64( ) throws Exception { String res = service.decrypt( "ICAg" ); assertEquals( " ", res ); }
@Test public void testDecryptEmptyPassword( ) throws Exception { String res = service.decrypt( "" ); assertEquals( "", res ); }
@Test public void testDecryptNullPassword( ) throws Exception { String res = service.decrypt( null ); assertNull( res ); }
@Test public void testDecryptValidPassword( ) throws Exception { String res = service.decrypt( "Encrypted 6173646667686a6b6c646965756b616e636fc8f9c6a70ec18581ae0ea462d585aac8" ); assertEquals( "asdfghjkldieukancmvaiodfweewjrkwer", res ); }