UriUtils { public static String getUpdateUri(String url, boolean encrypt) { String updatedPath = null; try { String query = URIUtil.getQuery(url); URIBuilder builder = new URIBuilder(url); builder.removeQuery(); StringBuilder updatedQuery = new StringBuilder(); List<NameValuePair> queryParams = getUserDetails(query); ListIterator<NameValuePair> iterator = queryParams.listIterator(); while (iterator.hasNext()) { NameValuePair param = iterator.next(); String value = null; if ("password".equalsIgnoreCase(param.getName()) && param.getValue() != null) { value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue()); } else { value = param.getValue(); } if (updatedQuery.length() == 0) { updatedQuery.append(param.getName()).append('=') .append(value); } else { updatedQuery.append('&').append(param.getName()) .append('=').append(value); } } String schemeAndHost = ""; URI newUri = builder.build(); if (newUri.getScheme() != null) { schemeAndHost = newUri.getScheme() + ": } updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery; } catch (URISyntaxException e) { throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage()); } return updatedPath; }  static String formNfsUri(String host, String path); static String formIscsiUri(String host, String iqn, Integer lun); static String formFileUri(String path); static String encodeURIComponent(String url); static String getCifsUriParametersProblems(URI uri); static boolean hostAndPathPresent(URI uri); static boolean cifsCredentialsPresent(URI uri); static String getUpdateUri(String url, boolean encrypt); static Long getRemoteSize(String url); static Pair<String, Integer> validateUrl(String url); static Pair<String, Integer> validateUrl(String format, String url); static void checkUrlExistence(String url); static InputStream getInputStreamFromUrl(String url, String user, String password); static final Logger s_logger; }
@Test public void getUpdateUri() { Assert.assertEquals("http: .getUpdateUri("http: Assert.assertEquals("http: .getUpdateUri("http: Assert.assertTrue(UriUtils.getUpdateUri( "http: "http: Assert.assertEquals("http: .getUpdateUri("http: }