List of usage examples for org.apache.http.impl.client AbstractHttpClient setCredentialsProvider
public synchronized void setCredentialsProvider(final CredentialsProvider credsProvider)
From source file:org.jasig.portlet.proxy.service.web.interceptor.AbstractBasicAuthenticationPreInterceptor.java
/** * Add BASIC authentication credentials to the user's HttpClientService. *///from w w w.j a va2s .co m @Override protected void prepareAuthentication(HttpContentRequestImpl contentRequest, PortletRequest portletRequest) { // create a new basic auth type credentials provider final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); final Credentials credentials = getCredentials(portletRequest); credentialsProvider.setCredentials(AuthScope.ANY, credentials); // Set the credentials provider on the HTTP client. The HTTP client is // not limited to the session of the target website, so these credentials // may be applied more than once. We expect these periodic updates to // be unnecessary but do not expect them to cause any problems. final AbstractHttpClient client = httpClientService.getHttpClient(portletRequest); client.setCredentialsProvider(credentialsProvider); }
From source file:com.webbfontaine.valuewebb.startup.ProxyConfiguration.java
public void addProxy(AbstractHttpClient httpClient) { if (ApplicationProperties.isAllowProxy()) { LOGGER.debug("Adding PROXY for HTTP Client"); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(userName, password)); httpClient.setCredentialsProvider(credsProvider); HttpHost proxy = new HttpHost(host, port, protocol); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else {//www. jav a 2s . co m LOGGER.warn("HTTP Client has requested for PROXY but it is disabled."); } }
From source file:org.dmfs.android.authenticator.handlers.BasicHttpClientAuthenticationHandler.java
@Override public void authenticate(AbstractHttpClient client) { // just set the credentials assuming that proper authentication schemes are registered with the AbstractHttpClient. CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, mAuthToken.getRealm()), new UsernamePasswordCredentials(mAuthToken.getUsername(), mAuthToken.getPassword())); client.setCredentialsProvider(credsProvider); }
From source file:org.apache.jena.atlas.web.auth.AbstractCredentialsAuthenticator.java
@Override public void apply(AbstractHttpClient client, HttpContext context, URI target) { // At least a user name is required or no authentication will be done if (!this.hasUserName(target)) return;//from w w w .j a v a 2 s. com // Be careful to scope credentials to the specific URI so that // HttpClient won't try and send them to other servers HttpHost host = new HttpHost(target.getHost(), target.getPort()); CredentialsProvider provider = new BasicCredentialsProvider(); provider.setCredentials(new AuthScope(host), this.createCredentials(target)); client.setCredentialsProvider(provider); }