AESEncryption { public static String decryptUriPassword(final String rawUri) { URI uri; try { uri = new URI(rawUri); } catch (URISyntaxException e) { LOGGER.info("Invalid URI {}", rawUri, e); return rawUri; } UserInfo userInfo = extractCredentials(uri); if (userInfo != null && userInfo.password != null) { try { userInfo.password = decrypt(userInfo.password); return setCredentials(uri, userInfo).toString(); } catch (Exception e) { LOGGER.info("Could not decrypt URI password."); return rawUri; } } else { return rawUri; } } private  AESEncryption(); static String encrypt(final String src); static String decrypt(final String src); static String decryptUriPassword(final String rawUri); static String encryptUriPassword(final String rawUri); static String decrypt(final String name, final String src);  }
@Test public void decryptUriPassword_shouldDecryptCredentials() throws Exception { String decrypted = AESEncryption.decryptUriPassword(ENCRYPTED_URI); assertEquals(DECRYPTED_URI, decrypted); }