List of usage examples for org.apache.http.client.protocol ClientContext CREDS_PROVIDER
String CREDS_PROVIDER
To view the source code for org.apache.http.client.protocol ClientContext CREDS_PROVIDER.
Click Source Link
From source file:kuona.client.PreemptiveAuth.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); if (authState.getAuthScheme() == null) { AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth"); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authScheme != null) { Credentials creds = credsProvider .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort())); if (creds == null) { throw new HttpException("No credentials for preemptive authentication"); }// w w w. j av a2 s . c om authState.update(authScheme, creds); } } }
From source file:dtu.ds.warnme.app.ws.client.https.ssl.PreemptiveAuthenticationRequestInterceptor.java
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); }//from w ww . j av a2s . co m } }
From source file:at.bitfire.davdroid.webdav.PreemptiveAuthInterceptor.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); }//www .j a v a 2 s .c o m } }
From source file:com.mycompany.projecta.PreemptiveAuth.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { // Get the AuthState AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); // If no auth scheme available yet, try to initialize it preemptively if (authState.getAuthScheme() == null) { AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth"); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authScheme != null) { Credentials creds = credsProvider .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort())); if (creds == null) { throw new HttpException("No credentials for preemptive authentication"); }// w w w .j a v a 2 s . c o m authState.setAuthScheme(authScheme); authState.setCredentials(creds); } } }
From source file:com.liferay.portal.search.solr.interceptor.PreemptiveAuthInterceptor.java
@Override public void process(HttpRequest request, HttpContext httpContext) { AuthState authState = (AuthState) httpContext.getAttribute(ClientContext.TARGET_AUTH_STATE); if (authState.getAuthScheme() != null) { return;/*w ww .ja v a2 s . c o m*/ } CredentialsProvider credentialsProvider = (CredentialsProvider) httpContext .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHttpHost = (HttpHost) httpContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST); AuthScope authScope = new AuthScope(targetHttpHost.getHostName(), targetHttpHost.getPort()); Credentials credentials = credentialsProvider.getCredentials(authScope); if (credentials != null) { authState.update(new BasicScheme(), credentials); } }
From source file:cn.com.loopj.android.http.PreemptiveAuthorizationHttpRequestInterceptor.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); }/*from w w w. j a v a 2s. c o m*/ } }
From source file:com.controlj.experiment.bulktrend.trendclient.PreemptiveAuthRequestInterceptor.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); // If no auth scheme avaialble yet, try to initialize it preemptively if (authState.getAuthScheme() == null) { AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth"); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authScheme != null) { Credentials creds = credsProvider .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort())); if (creds == null) { throw new HttpException("No credentials for preemptive authentication"); }/*from w w w .j a v a 2 s.com*/ authState.setAuthScheme(authScheme); authState.setCredentials(creds); } } }
From source file:org.orbeon.oxf.resources.handler.PreemptiveAuthHttpRequestInterceptor.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credentialsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); // If not auth scheme has been initialized yet if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); // Obtain credentials matching the target host Credentials credentials = credentialsProvider.getCredentials(authScope); // If found, generate BasicScheme preemptively if (credentials != null) { authState.setAuthScheme(credentials instanceof NTCredentials ? new NTLMScheme(new JCIFSEngine()) : new BasicScheme()); authState.setCredentials(credentials); }/* w w w.j av a 2 s . c o m*/ } }
From source file:de.escidoc.core.http.PreemtiveAuthHttpRequestInterceptor.java
@Override public void process(final HttpRequest httpRequest, final HttpContext httpContext) throws HttpException, IOException { final AuthState authState = (AuthState) httpContext.getAttribute(ClientContext.TARGET_AUTH_STATE); final CredentialsProvider credsProvider = (CredentialsProvider) httpContext .getAttribute(ClientContext.CREDS_PROVIDER); final HttpHost targetHost = (HttpHost) httpContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST); // If not auth scheme has been initialized yet if (authState.getAuthScheme() == null) { final AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); // Obtain credentials matching the target host final Credentials creds = credsProvider.getCredentials(authScope); // If found, generate BasicScheme preemptively if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); }// w w w.ja v a2 s . co m } }
From source file:org.gbif.utils.PreemptiveAuthenticationInterceptor.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { LOG.debug(request.getRequestLine().toString()); AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); // If not auth scheme has been initialized yet if (authState.getAuthScheme() == null && credsProvider != null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); // Obtain credentials matching the target host Credentials creds = credsProvider.getCredentials(authScope); // If found, generate BasicScheme preemptively if (creds != null) { LOG.debug("Authentication used for scope " + authScope.getHost()); authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); }/*from w ww .j a va 2 s . com*/ } }