/** * Handle authentication. * We do not know, necessarily, * which scheme(s) will be * encountered, so most testing * occurs in HTTPAuthProvider * * @return an authprovider encapsulting the request */ synchronized protected AuthScope setAuthentication() throws HTTPException { String surl = session.getURL(); // Creat a authscope from the url AuthScope scope; String[] principalp = new String[1]; if(surl == null) scope = HTTPAuthScope.ANY; else scope = HTTPAuthScope.urlToScope(HTTPAuthPolicy.BASIC, surl, principalp); // Provide a credentials (provider) to enact the process // We use the a caching instance so we can intercept getCredentials // requests to check the cache. HTTPCachingProvider hap = new HTTPCachingProvider(this.session.getAuthStore(), scope, principalp[0]); // New in httpclient 4.2; will need to change in 4.3 this.session.setAuthentication(hap); return scope; }