protected AuthScheme chooseAuthScheme(Map<String, String> challenges, String challengeHeaderKey) { HashSet<String> authSchemesLeftToTry = new HashSet<String>(challenges.keySet()); for (String authSchemeName: new String[]{"digest","basic"}) { if (authSchemesLeftToTry.remove(authSchemeName)) { AuthScheme authScheme = AUTH_SCHEME_REGISTRY.lookup(authSchemeName).create(null);; BasicHeader challenge = new BasicHeader(challengeHeaderKey, challenges.get(authSchemeName)); try { authScheme.processChallenge(challenge); } catch (MalformedChallengeException e) { logger.fine(e.getMessage() + " " + challenge); continue; } if (authScheme.isConnectionBased()) { logger.fine("Connection based " + authScheme); continue; } if (authScheme.getRealm() == null || authScheme.getRealm().length() <= 0) { logger.fine("Empty realm " + authScheme); continue; } return authScheme; } } for (String unsupportedSchemeName: authSchemesLeftToTry) { logger.fine("Unsupported http auth scheme: " + unsupportedSchemeName); } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
return; if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) { try { request.addHeader(authScheme.authenticate(creds, request));
if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) { try { request.addHeader(authScheme.authenticate(creds, request));
Credentials creds = this.proxyAuthState.getCredentials(); if (creds != null) { if (authScope != null || !authScheme.isConnectionBased()) { try { connect.addHeader(authScheme.authenticate(creds, connect));
targetAuthState.invalidate(); AuthScheme authScheme = proxyAuthState.getAuthScheme(); if (authScheme != null && authScheme.isConnectionBased()) { proxyAuthState.invalidate();
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { if (request == null) throw new IllegalArgumentException("HTTP request may not be null"); if (context == null) throw new IllegalArgumentException("HTTP context may not be null"); if (!request.getRequestLine().getMethod().equalsIgnoreCase("CONNECT")) { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); if (authState != null) { AuthScheme authScheme = authState.getAuthScheme(); if (authScheme != null && !authScheme.isConnectionBased()) { try { request.setHeader(authScheme.authenticate(null, request)); } catch (AuthenticationException ignored) { // ignored } } } } } }
protected AuthScheme chooseAuthScheme(Map<String, String> challenges, String challengeHeaderKey) { HashSet<String> authSchemesLeftToTry = new HashSet<String>(challenges.keySet()); for (String authSchemeName: new String[]{"digest","basic"}) { if (authSchemesLeftToTry.remove(authSchemeName)) { AuthScheme authScheme = AUTH_SCHEME_REGISTRY.lookup(authSchemeName).create(null);; BasicHeader challenge = new BasicHeader(challengeHeaderKey, challenges.get(authSchemeName)); try { authScheme.processChallenge(challenge); } catch (MalformedChallengeException e) { logger.fine(e.getMessage() + " " + challenge); continue; } if (authScheme.isConnectionBased()) { logger.fine("Connection based " + authScheme); continue; } if (authScheme.getRealm() == null || authScheme.getRealm().length() <= 0) { logger.fine("Empty realm " + authScheme); continue; } return authScheme; } } for (String unsupportedSchemeName: authSchemesLeftToTry) { logger.fine("Unsupported http auth scheme: " + unsupportedSchemeName); } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthStateHC4 authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
private static Principal getAuthPrincipal(final AuthState authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }
if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) { try { request.addHeader(authScheme.authenticate(creds, request));
private static Principal getAuthPrincipal(final AuthState authState) { final AuthScheme scheme = authState.getAuthScheme(); if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) { final Credentials creds = authState.getCredentials(); if (creds != null) { return creds.getUserPrincipal(); } } return null; }