Source:
public List<String> getDeployableRepos(long serverId, HttpServletRequest req, HttpServletResponse resp) { ServerConfig serverConfig = getServerConfigById(serverId); if (serverConfig == null) { log.error("Error while retrieving target repository list: Could not find Artifactory server " + "configuration by the ID " + serverId); return Lists.newArrayList(); } ArtifactoryBuildInfoClient client; String serverUrl = substituteVariables(serverConfig.getUrl()); String username = null; String password = null; if (req != null) { username = req.getParameter("user"); password = req.getParameter("password"); } if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { password = TaskUtils.decryptIfNeeded(password); } else { username = serverConfig.getUsername(); password = serverConfig.getPassword(); } username = substituteVariables(username); password = substituteVariables(password); if (StringUtils.isBlank(username)) { client = TaskUtils.getArtifactoryBuildInfoClient(new ServerConfig(serverConfig.getId(), serverUrl, StringUtils.EMPTY, StringUtils.EMPTY, serverConfig.getTimeout()), new BuildInfoLog(log)); } else { client = TaskUtils.getArtifactoryBuildInfoClient(new ServerConfig(serverConfig.getId(), serverUrl, username, password, serverConfig.getTimeout()), new BuildInfoLog(log)); } try { return client.getLocalRepositoriesKeys(); } catch (IOException ioe) { log.error("Error while retrieving target repository list from: " + serverUrl, ioe); try { if (resp != null && ioe.getMessage().contains("401")) resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); if (resp != null && ioe.getMessage().contains("404")) resp.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (IOException e) { log.error("Error while sending error to response", e); } return Lists.newArrayList(); } finally { client.close(); } }

Target:
public List<String> getDeployableRepos(long serverId, HttpServletRequest req, HttpServletResponse resp) { ServerConfig serverConfig = getServerConfigById(serverId); if (serverConfig == null) { log.error("Error while retrieving target repository list: Could not find Artifactory server " + "configuration by the ID " + serverId); return Lists.newArrayList(); } ArtifactoryBuildInfoClient client; String serverUrl = substituteVariables(serverConfig.getUrl()); String username = null; String password = null; if (req != null) { username = req.getParameter("user"); password = req.getParameter("password"); } if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { password = TaskUtils.decryptIfNeeded(password); } else { username = serverConfig.getUsername(); password = serverConfig.getPassword(); } username = substituteVariables(username); password = substituteVariables(password); if (StringUtils.isBlank(username)) { client = TaskUtils.getArtifactoryBuildInfoClient(new ServerConfig(serverConfig.getId(), serverUrl, "", "", serverConfig.getTimeout()), new BuildInfoLog(log)); } else { client = TaskUtils.getArtifactoryBuildInfoClient(new ServerConfig(serverConfig.getId(), serverUrl, username, password, serverConfig.getTimeout()), new BuildInfoLog(log)); } try { return client.getLocalRepositoriesKeys(); } catch (IOException ioe) { log.error("Error while retrieving target repository list from: " + serverUrl, ioe); try { if (resp != null && ioe.getMessage().contains("401")) resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); if (resp != null && ioe.getMessage().contains("404")) resp.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (IOException e) { log.error("Error while sending error to response", e); } return Lists.newArrayList(); } finally { client.close(); } }