/* (non-Javadoc) * @see com.salesforce.ide.model.IProxy#getProxyPassword() */ public String getProxyPassword() { if (!isProxiesEnabled()) { return Constants.EMPTY_STRING; } IProxyData httpProxyData = getHttpProxyData(); if (httpProxyData == null) { return Constants.EMPTY_STRING; } if (!httpProxyData.isRequiresAuthentication()) { return Constants.EMPTY_STRING; } if (Utils.isNotEmpty(httpProxyData.getPassword())) { if (logger.isDebugEnabled()) { logger.debug("Returning '***' as proxy password "); } return httpProxyData.getPassword(); } else { if (logger.isDebugEnabled()) { logger.debug("Returning blank/null proxy password "); } return Constants.EMPTY_STRING; } }
private IProxyData getProxyData(String type) { if (Utils.isNotEmpty(proxyData)) { for (IProxyData proxyDataInstance : proxyData) { if (type.equals(proxyDataInstance.getType())) { return proxyDataInstance; } } } return null; }
/* * @see * org.rssowl.core.connection.auth.ICredentialsProvider#getProxyCredentials * (java.net.URI) */ public IProxyCredentials getProxyCredentials(URI link) { Activator activator = Activator.getDefault(); /* Check if Bundle is Stopped */ if (activator == null) return null; IProxyService proxyService = activator.getProxyService(); /* Check if Proxy is enabled */ if (!proxyService.isProxiesEnabled()) return null; String host = URIUtils.safeGetHost(link); boolean isSSL = URIUtils.HTTPS_SCHEME.equals(link.getScheme()); /* Retrieve Proxy Data */ final IProxyData proxyData = proxyService.getProxyDataForHost( host, isSSL ? IProxyData.HTTPS_PROXY_TYPE : IProxyData.HTTP_PROXY_TYPE); if (proxyData != null) { /* Look for Domain as part of Username to support NTLM Proxy */ final String proxyHost = proxyData.getHost(); final int proxyPort = proxyData.getPort(); final Pair<String /* Username */, String /* Domain */> proxyUserAndDomain = splitUserAndDomain(proxyData.getUserId()); final String proxyPassword = proxyData.getPassword(); /* Return as IProxyCredentials Object */ return new IProxyCredentials() { public String getHost() { return proxyHost; } public int getPort() { return proxyPort; } public String getUsername() { return proxyUserAndDomain.getFirst(); } public String getPassword() { return proxyPassword; } public String getDomain() { return proxyUserAndDomain.getSecond(); } }; } /* Feed does not require Proxy or Credentials not supplied */ return null; }
/* (non-Javadoc) * @see com.salesforce.ide.model.IProxy#getProxyPort() */ public String getProxyPort() { if (!isProxiesEnabled()) { return Constants.EMPTY_STRING; } IProxyData httpProxyData = getHttpProxyData(); if (httpProxyData != null && Utils.isNotEmpty(httpProxyData.getPort())) { if (logger.isDebugEnabled()) { logger.debug("Returning '" + httpProxyData.getPort() + "' as proxy port "); } return String.valueOf(httpProxyData.getPort()); } else { return Constants.EMPTY_STRING; } }
/* * @see * org.rssowl.core.connection.auth.ICredentialsProvider#setProxyCredentials * (org.rssowl.core.connection.auth.IProxyCredentials, java.net.URI) */ public void setProxyCredentials(IProxyCredentials credentials, URI link) { IProxyService proxyService = Activator.getDefault().getProxyService(); proxyService.setProxiesEnabled(true); boolean isSSL = URIUtils.HTTPS_SCHEME.equals(link.getScheme()); /* Retrieve Proxy Data */ final IProxyData proxyData = proxyService.getProxyData(isSSL ? IProxyData.HTTPS_PROXY_TYPE : IProxyData.HTTP_PROXY_TYPE); if (proxyData != null) { // TODO What if Data is NULL? proxyData.setHost(credentials.getHost()); proxyData.setPort(credentials.getPort()); proxyData.setUserid(credentials.getUsername()); proxyData.setPassword(credentials.getPassword()); } }