List of usage examples for org.apache.http.client.fluent Executor auth
public Executor auth(final HttpHost host, final String username, final String password)
From source file:com.github.woki.payments.adyen.action.Endpoint.java
private static Executor createExecutor(ClientConfig config) { Executor retval = Executor.newInstance(); retval.auth(config.getEndpointHost(), config.getUsername(), config.getPassword()); if (config.hasProxy() && config.isProxyAuthenticated()) { retval.auth(config.getProxyHost(), config.getProxyUsername(), config.getProxyPassword()); }/*from w w w . j a va2 s .c om*/ return retval; }
From source file:org.apache.sling.replication.transport.authentication.impl.UserCredentialsTransportAuthenticationProvider.java
public Executor authenticate(Executor authenticable, TransportAuthenticationContext context) throws TransportAuthenticationException { ReplicationEndpoint endpoint = context.getAttribute("endpoint", ReplicationEndpoint.class); if (endpoint != null) { Executor authenticated = authenticable.auth(new HttpHost(endpoint.getUri().getHost()), username, password);//from www . j a va 2 s . c o m if (log.isInfoEnabled()) { log.info("authenticated executor {} with user and password", authenticated); } return authenticated; } else { throw new TransportAuthenticationException("the endpoint to authenticate is missing from the context"); } }
From source file:org.opendatakit.briefcase.reused.http.CommonsHttp.java
@Override public <T> Response<T> execute(Request<T> request) { // Always instantiate a new Executor to avoid side-effects between executions Executor executor = Executor.newInstance(HttpClientBuilder.create() .setDefaultRequestConfig(custom().setCookieSpec(STANDARD).build()).build()); // Apply auth settings if credentials are received request.ifCredentials((URL url, Credentials credentials) -> executor.auth(HttpHost.create(url.getHost()), credentials.getUsername(), credentials.getPassword())); // get the response body and let the Request map it return uncheckedExecute(request, executor).map(request::map); }
From source file:org.apache.sling.distribution.transport.impl.SimpleHttpDistributionTransport.java
private Executor authenticate(DistributionTransportSecret secret, Executor executor) { Map<String, String> credentialsMap = secret.asCredentialsMap(); if (credentialsMap != null) { URI uri = distributionEndpoint.getUri(); executor = executor .auth(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()), credentialsMap.get(USERNAME), credentialsMap.get(PASSWORD)) .authPreemptive(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme())); log.debug("authenticate user={}, endpoint={}", secret.asCredentialsMap().get(USERNAME), distributionEndpoint.getUri()); }//from w w w. j a va 2s .c o m return executor; }