Code example for AuthState

Methods: getAuthScheme

0
			public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
				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) {
						AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
						Credentials creds = credsProvider.getCredentials(authScope);
						if (creds == null) {
							throw new HttpException("No credentials for preemptive authentication");
						} 
						authState.setAuthScheme(authScheme);
						authState.setCredentials(creds);
					} 
				} 
			} 
Contextual code suggestions in your IDE  Get Codota for Java