@Override public Queue<AuthOption> select(final Map<String, Header> challengeHeaders, final HttpHost authhost, final HttpResponse response, final HttpContext context) { final HttpClientContext httpClientContext = HttpClientContext.adapt(context); final AuthState state = httpClientContext.getTargetAuthState(); final Queue<AuthOption> queue = new ArrayDeque<>(); if (state == null || !state.getState().equals(AuthProtocolState.CHALLENGED)) { queue.add(authOption); } else { System.out.println("does this happen?"); } return queue; }
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); final String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase("CONNECT")) { return; } if (request.containsHeader(AUTH.WWW_AUTH_RESP)) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.TARGET_AUTH_STATE); if (authState == null) { this.log.debug("Target auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Target auth state: " + authState.getState()); } process(authState, request, context); }
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); final String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase("CONNECT")) { return; } if (request.containsHeader(AUTH.WWW_AUTH_RESP)) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.TARGET_AUTH_STATE); if (authState == null) { this.log.debug("Target auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Target auth state: " + authState.getState()); } process(authState, request, context); }
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); final String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase("CONNECT")) { return; } if (request.containsHeader(AUTH.WWW_AUTH_RESP)) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.TARGET_AUTH_STATE); if (authState == null) { this.log.debug("Target auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Target auth state: " + authState.getState()); } process(authState, request, context); }
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); final String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase("CONNECT")) { return; } if (request.containsHeader(AUTH.WWW_AUTH_RESP)) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.TARGET_AUTH_STATE); if (authState == null) { this.log.debug("Target auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Target auth state: " + authState.getState()); } process(authState, request, context); }
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) { return; } final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute( ExecutionContext.HTTP_CONNECTION); if (conn == null) { this.log.debug("HTTP connection not set in the context"); return; } final HttpRoute route = conn.getRoute(); if (route.isTunnelled()) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.PROXY_AUTH_STATE); if (authState == null) { this.log.debug("Proxy auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Proxy auth state: " + authState.getState()); } process(authState, request, context); }
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) { return; } final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute( ExecutionContext.HTTP_CONNECTION); if (conn == null) { this.log.debug("HTTP connection not set in the context"); return; } final HttpRoute route = conn.getRoute(); if (route.isTunnelled()) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.PROXY_AUTH_STATE); if (authState == null) { this.log.debug("Proxy auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Proxy auth state: " + authState.getState()); } process(authState, request, context); }
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) { return; } final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute( ExecutionContext.HTTP_CONNECTION); if (conn == null) { this.log.debug("HTTP connection not set in the context"); return; } final HttpRoute route = conn.getRoute(); if (route.isTunnelled()) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.PROXY_AUTH_STATE); if (authState == null) { this.log.debug("Proxy auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Proxy auth state: " + authState.getState()); } process(authState, request, context); }
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); Args.notNull(context, "HTTP context"); if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) { return; } final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute( ExecutionContext.HTTP_CONNECTION); if (conn == null) { this.log.debug("HTTP connection not set in the context"); return; } final HttpRoute route = conn.getRoute(); if (route.isTunnelled()) { return; } // Obtain authentication state final AuthState authState = (AuthState) context.getAttribute( ClientContext.PROXY_AUTH_STATE); if (authState == null) { this.log.debug("Proxy auth state not set in the context"); return; } if (this.log.isDebugEnabled()) { this.log.debug("Proxy auth state: " + authState.getState()); } process(authState, request, context); }
public boolean isAuthenticationRequested( final HttpHost host, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) { if (authStrategy.isAuthenticationRequested(host, response, context)) { this.log.debug("Authentication required"); if (authState.getState() == AuthProtocolState.SUCCESS) { authStrategy.authFailed(host, authState.getAuthScheme(), context); } return true; } else { switch (authState.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); authState.setState(AuthProtocolState.SUCCESS); authStrategy.authSucceeded(host, authState.getAuthScheme(), context); break; case SUCCESS: break; default: authState.setState(AuthProtocolState.UNCHALLENGED); } return false; } }
public boolean isAuthenticationRequested( final HttpHost host, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) { if (authStrategy.isAuthenticationRequested(host, response, context)) { this.log.debug("Authentication required"); if (authState.getState() == AuthProtocolState.SUCCESS) { authStrategy.authFailed(host, authState.getAuthScheme(), context); } return true; } else { switch (authState.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); authState.setState(AuthProtocolState.SUCCESS); authStrategy.authSucceeded(host, authState.getAuthScheme(), context); break; case SUCCESS: break; default: authState.setState(AuthProtocolState.UNCHALLENGED); } return false; } }
public boolean isAuthenticationRequested( final HttpHost host, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) { if (authStrategy.isAuthenticationRequested(host, response, context)) { this.log.debug("Authentication required"); if (authState.getState() == AuthProtocolState.SUCCESS) { authStrategy.authFailed(host, authState.getAuthScheme(), context); } return true; } else { switch (authState.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); authState.setState(AuthProtocolState.SUCCESS); authStrategy.authSucceeded(host, authState.getAuthScheme(), context); break; case SUCCESS: break; default: authState.setState(AuthProtocolState.UNCHALLENGED); } return false; } }
public boolean isAuthenticationRequested( final HttpHost host, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) { if (authStrategy.isAuthenticationRequested(host, response, context)) { this.log.debug("Authentication required"); if (authState.getState() == AuthProtocolState.SUCCESS) { authStrategy.authFailed(host, authState.getAuthScheme(), context); } return true; } else { switch (authState.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); authState.setState(AuthProtocolState.SUCCESS); authStrategy.authSucceeded(host, authState.getAuthScheme(), context); break; case SUCCESS: break; default: authState.setState(AuthProtocolState.UNCHALLENGED); } return false; } }
public boolean isAuthenticationRequested( final HttpHost host, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) { if (authStrategy.isAuthenticationRequested(host, response, context)) { this.log.debug("Authentication required"); if (authState.getState() == AuthProtocolState.SUCCESS) { authStrategy.authFailed(host, authState.getAuthScheme(), context); } return true; } else { switch (authState.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); authState.setState(AuthProtocolState.SUCCESS); authStrategy.authSucceeded(host, authState.getAuthScheme(), context); break; case SUCCESS: break; default: authState.setState(AuthProtocolState.UNCHALLENGED); } return false; } }
public boolean isAuthenticationRequested( final HttpHost host, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) { if (authStrategy.isAuthenticationRequested(host, response, context)) { this.log.debug("Authentication required"); if (authState.getState() == AuthProtocolState.SUCCESS) { authStrategy.authFailed(host, authState.getAuthScheme(), context); } return true; } else { switch (authState.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); authState.setState(AuthProtocolState.SUCCESS); authStrategy.authSucceeded(host, authState.getAuthScheme(), context); break; case SUCCESS: break; default: authState.setState(AuthProtocolState.UNCHALLENGED); } return false; } }
if (targetState != null && targetState.getState() == AuthProtocolState.UNCHALLENGED) { final AuthScheme authScheme = authCache.get(target); if (authScheme != null) { if (proxy != null && proxyState != null && proxyState.getState() == AuthProtocolState.UNCHALLENGED) { final AuthScheme authScheme = authCache.get(proxy); if (authScheme != null) {
/** * Determines if the given HTTP response response represents * an authentication challenge that was sent back as a result * of authentication failure. * * @param authHost authentication host. * @param response HTTP response. * @param context HTTP context. * @return {@code true} if user authentication is required, * {@code false} otherwise. */ @Override public boolean isAuthenticationRequested(final HttpHost authHost, final HttpResponse response, final HttpContext context) { final StatusLine line = response.getStatusLine(); final int code = line.getStatusCode(); final HttpClientContext clientContext = HttpClientContext.adapt(context); final AuthState authState = clientContext.getTargetAuthState(); final AuthProtocolState authProtocolState = authState.getState(); if (code == HttpStatus.SC_UNAUTHORIZED) { if (authProtocolState.equals(AuthProtocolState.CHALLENGED)) { clientContext.getTargetAuthState().setState(AuthProtocolState.FAILURE); authFailed(authHost, authState.getAuthScheme(), context); } return true; } return clientContext.getTargetAuthState() == null; }
AuthScheme authScheme = authState.getAuthScheme(); Credentials creds = authState.getCredentials(); switch (authState.getState()) { // TODO add UNCHALLENGED and HANDSHAKE cases case FAILURE: return;
AuthScheme authScheme = authState.getAuthScheme(); Credentials creds = authState.getCredentials(); switch (authState.getState()) { // TODO add UNCHALLENGED and HANDSHAKE cases case FAILURE: return;
AuthScheme authScheme = authState.getAuthScheme(); Credentials creds = authState.getCredentials(); switch (authState.getState()) { // TODO add UNCHALLENGED and HANDSHAKE cases case FAILURE: return;