use of org.graylog.shaded.elasticsearch7.org.apache.http.client.CredentialsProvider in project frontend-maven-plugin by eirslett.
the class DefaultFileDownloader method makeCredentialsProvider.
private CredentialsProvider makeCredentialsProvider(String host, int port, String username, String password) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(username, password));
return credentialsProvider;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.CredentialsProvider in project frontend-maven-plugin by eirslett.
the class DefaultFileDownloader method execute.
private CloseableHttpResponse execute(String requestUrl, String userName, String password) throws IOException {
CloseableHttpResponse response;
Proxy proxy = proxyConfig.getProxyForUrl(requestUrl);
if (proxy != null) {
LOGGER.info("Downloading via proxy " + proxy.toString());
return executeViaProxy(proxy, requestUrl);
} else {
LOGGER.info("No proxy was configured, downloading directly");
if (StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(password)) {
LOGGER.info("Using credentials (" + userName + ") from settings.xml");
// Auth target host
URL aURL = new URL(requestUrl);
HttpClientContext localContext = makeLocalContext(aURL);
CredentialsProvider credentialsProvider = makeCredentialsProvider(aURL.getHost(), aURL.getPort(), userName, password);
response = buildHttpClient(credentialsProvider).execute(new HttpGet(requestUrl), localContext);
} else {
response = buildHttpClient(null).execute(new HttpGet(requestUrl));
}
}
return response;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.CredentialsProvider in project hbase by apache.
the class TestSecureRESTServer method getClient.
private Pair<CloseableHttpClient, HttpClientContext> getClient() {
HttpClientConnectionManager pool = new PoolingHttpClientConnectionManager();
HttpHost host = new HttpHost("localhost", REST_TEST.getServletPort());
Registry<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create().register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true)).build();
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, EmptyCredentials.INSTANCE);
AuthCache authCache = new BasicAuthCache();
CloseableHttpClient client = HttpClients.custom().setDefaultAuthSchemeRegistry(authRegistry).setConnectionManager(pool).build();
HttpClientContext context = HttpClientContext.create();
context.setTargetHost(host);
context.setCredentialsProvider(credentialsProvider);
context.setAuthSchemeRegistry(authRegistry);
context.setAuthCache(authCache);
return new Pair<>(client, context);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.CredentialsProvider in project indy by Commonjava.
the class AbstractHttproxFunctionalTest method proxyContext.
protected HttpClientContext proxyContext(final String user, final String pass) {
final CredentialsProvider creds = new BasicCredentialsProvider();
creds.setCredentials(new AuthScope(HOST, proxyPort), new UsernamePasswordCredentials(user, pass));
final HttpClientContext ctx = HttpClientContext.create();
ctx.setCredentialsProvider(creds);
return ctx;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.CredentialsProvider in project indy by Commonjava.
the class BasicAuthenticator method decoratePrototypeContext.
@Override
public HttpClientContext decoratePrototypeContext(AuthScope scope, SiteConfig location, PasswordType type, HttpClientContext ctx) {
if (user != null) {
final CredentialsProvider credProvider = new BasicCredentialsProvider();
credProvider.setCredentials(scope, new UsernamePasswordCredentials(user, pass));
ctx.setCredentialsProvider(credProvider);
}
return ctx;
}
Aggregations