ConfiguredPrivateKeyPasswordProvider implements PrivateKeyPasswordProvider { @Override public char[] retrievePrivateKeyPassword() throws PasswordException { if (pkPassword == null && !isEmpty(encodedPassword)) { pkPassword = Password.decode(ExternalResolver.resolve(encodedPassword)).toCharArray(); } return pkPassword; } ConfiguredPrivateKeyPasswordProvider();  ConfiguredPrivateKeyPasswordProvider(String encPassword); @Override char[] retrievePrivateKeyPassword(); String getEncodedPassword(); void setEncodedPassword(String encodedPassword);  }
@Test public void testGetPassword() throws Exception { ConfiguredPrivateKeyPasswordProvider pkpp = new ConfiguredPrivateKeyPasswordProvider("ABCDE"); assertEquals("ABCDE", new String(pkpp.retrievePrivateKeyPassword())); pkpp = new ConfiguredPrivateKeyPasswordProvider(Password.encode("ABCDE", Password.PORTABLE_PASSWORD)); assertEquals("ABCDE", new String(pkpp.retrievePrivateKeyPassword())); }
@Test public void testGetNullPassword() throws Exception { ConfiguredPrivateKeyPasswordProvider pkpp = new ConfiguredPrivateKeyPasswordProvider(null); assertNull(pkpp.retrievePrivateKeyPassword()); }
@Test public void testGetEmpty() throws Exception { ConfiguredPrivateKeyPasswordProvider pkpp = new ConfiguredPrivateKeyPasswordProvider(""); assertNull(pkpp.retrievePrivateKeyPassword()); }