@Test public void decryptUriPassword_shouldDecryptCredentials() throws Exception { String decrypted = AESEncryption.decryptUriPassword(ENCRYPTED_URI); assertEquals(DECRYPTED_URI, decrypted); }
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; } }
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; } } }
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(); }
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); }
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);  }