Basic authentication scheme as defined in RFC 2617.
474475476477478479480481482483484
HttpHost targethost = getServerHttp(); HttpContext context = new BasicHttpContext(); AuthCache authCache = new BasicAuthCache(); authCache.put(targethost, new BasicScheme()); context.setAttribute(ClientContext.AUTH_CACHE, authCache); HttpGet httpget = new HttpGet("/"); HttpResponse response1 = this.httpclient.execute(targethost, httpget, context);
504505506507508509510511512513514
486487488489490491492493494495496
} String userinfo = wrapper.getURI().getUserInfo(); if (userinfo != null) { targetAuthState.update( new BasicScheme(), new UsernamePasswordCredentials(userinfo)); } HttpHost proxy = route.getProxyHost(); if (virtualHost != null) { target = virtualHost;
196197198199200201202203204205206
int port = url.getPort() > -1 ? url.getPort() : AuthScope.ANY_PORT; httpClient.getCredentialsProvider().setCredentials( new AuthScope( host, port ), creds ); AuthCache authCache = new BasicAuthCache(); BasicScheme basicAuth = new BasicScheme(); HttpHost targetHost = new HttpHost( url.getHost(), url.getPort(), url.getProtocol() ); authCache.put( targetHost, basicAuth ); localContext = new BasicHttpContext(); localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
487488489490491492493494495496497
} String userinfo = wrapper.getURI().getUserInfo(); if (userinfo != null) { targetAuthState.update( new BasicScheme(), new UsernamePasswordCredentials(userinfo)); } // Reset headers on the request wrapper wrapper.resetHeaders();
473474475476477478479480481482483
503504505506507508509510511512513
171172173174175176177178179180181
8182838485868788899091
if( user != null && user.length() > 0 ) { client.getCredentialsProvider().setCredentials( AuthScope.ANY, new UsernamePasswordCredentials( user, password ) ); // All this bollocks is just for pre-emptive authentication. It used to be a boolean... BasicHttpContext localcontext = new BasicHttpContext(); BasicScheme basicAuth = new BasicScheme(); localcontext.setAttribute( "preemptive-auth", basicAuth ); client.addRequestInterceptor( new PreemptiveAuth(), 0 ); } HttpPost post = new HttpPost( url );