authState.setAuthScope(authScope); authState.setCredentials(creds);
authState.setAuthScope(authScope); authState.setCredentials(creds);
targetAuthState.setAuthScope(null); proxyAuthState.setAuthScope(null); this.targetAuthState.setAuthScope(null); this.proxyAuthState.setAuthScope(null);
this.targetAuthState.setAuthScope(null); this.proxyAuthState.setAuthScope(null);
this.proxyAuthState.setAuthScope(null);
this.proxyAuthState.setAuthScope(null);
@Override public void process(org.apache.http.HttpRequest request, HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); authState.setAuthScope(org.apache.http.auth.AuthScope.ANY); authState.setCredentials(new UsernamePasswordCredentials(username,password)); authState.setAuthScheme(new BasicScheme()); } }
private StringBuffer readFromServer(String url) { DefaultHttpClient httpclient = new DefaultHttpClient(); HttpRequestInterceptor preemptiveAuth = new HttpRequestInterceptor() { public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); if (authState.getAuthScheme() == null) { Credentials credentials = new UsernamePasswordCredentials( Constants.SERVER_USERNAME, Constants.SERVER_PASSWORD); authState.setAuthScheme(new BasicScheme()); authState.setAuthScope(AuthScope.ANY); authState.setCredentials(credentials); } } }; httpclient.addRequestInterceptor(preemptiveAuth, 0); HttpGet httpget = new HttpGet(url); HttpResponse response; InputStream instream = null; StringBuffer result = new StringBuffer(); try { response = httpclient.execute(httpget);
httclient.addRequestInterceptor(new HttpRequestInterceptor() { public void process(HttpRequest arg0, HttpContext context) throws HttpException, IOException { AuthState state = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); if (state.getAuthScheme() == null) { BasicScheme scheme = new BasicScheme(); CredentialsProvider credentialsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER); Credentials credentials = credentialsProvider.getCredentials(AuthScope.ANY); if (credentials == null) { System.out.println("Credential >>" + credentials); throw new HttpException(); } state.setAuthScope(AuthScope.ANY); state.setAuthScheme(scheme); state.setCredentials(credentials); } } }, 0);
authState.setAuthScope(authScope); authState.setCredentials(creds);
authState.setAuthScope(authScope); authState.setCredentials(creds);
authState.setAuthScope(authScope); authState.setCredentials(creds);
authState.setAuthScope(authScope); authState.setCredentials(creds);
authState.setAuthScope(authScope); authState.setCredentials(creds);
this.targetAuthState.setAuthScope(null); this.proxyAuthState.setAuthScope(null);
this.targetAuthState.setAuthScope(null); this.proxyAuthState.setAuthScope(null);
this.targetAuthState.setAuthScope(null); this.proxyAuthState.setAuthScope(null);
this.proxyAuthState.setAuthScope(null);
this.proxyAuthState.setAuthScope(null);
this.proxyAuthState.setAuthScope(null);