method.setDoAuthentication(true);
}
}
private void setupProxy(URI link, HttpClient client) throws CredentialsException {
IProxyCredentials creds = Owl.getConnectionService().getProxyCredentials(link);
if (creds != null) {
/* Apply Proxy Config to HTTPClient */
client.getParams().setAuthenticationPreemptive(true);
client.getHostConfiguration().setProxy(creds.getHost(), creds.getPort());
/* Authenticate if required */
if (creds.getUsername() != null || creds.getPassword() != null) {
String user = StringUtils.isSet(creds.getUsername()) ? creds.getUsername() : ""; //$NON-NLS-1$
String pw = StringUtils.isSet(creds.getPassword()) ? creds.getPassword() : ""; //$NON-NLS-1$
AuthScope proxyAuthScope = new AuthScope(creds.getHost(), creds.getPort());
/* Use NTLM Credentials if Domain is set */
if (creds.getDomain() != null)
client.getState().setProxyCredentials(proxyAuthScope, new NTCredentials(user, pw, creds.getHost(), creds.getDomain()));
/* Use normal Credentials if Domain is not set */
else
client.getState().setProxyCredentials(proxyAuthScope, new UsernamePasswordCredentials(user, pw));
}