use of org.commonjava.maven.galley.auth.PasswordEntry in project galley by Commonjava.
the class HttpImpl method createContext.
@Override
public HttpClientContext createContext(final HttpLocation location) {
final HttpClientContext ctx = HttpClientContext.create();
if (location != null) {
final CredentialsProvider creds = new BasicCredentialsProvider();
final AuthScope as = new AuthScope(location.getHost(), location.getPort());
if (location.getUser() != null) {
final String password = passwords.getPassword(new PasswordEntry(location, PasswordEntry.USER_PASSWORD));
creds.setCredentials(as, new UsernamePasswordCredentials(location.getUser(), password));
}
if (location.getProxyHost() != null && location.getProxyUser() != null) {
final String password = passwords.getPassword(new PasswordEntry(location, PasswordEntry.PROXY_PASSWORD));
creds.setCredentials(new AuthScope(location.getProxyHost(), getProxyPort(location)), new UsernamePasswordCredentials(location.getProxyUser(), password));
}
ctx.setCredentialsProvider(creds);
}
return ctx;
}
Aggregations