ClientContext.AUTHSCHEME_REGISTRY);
if (registry == null) {
this.log.debug("Auth scheme registry not set in the context");
return options;
}
CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
ClientContext.CREDS_PROVIDER);
if (credsProvider == null) {
this.log.debug("Credentials provider not set in the context");
return options;
}
@SuppressWarnings("unchecked")
List<String> authPrefs = (List<String>) response.getParams().getParameter(this.prefParamName);
if (authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
if (this.log.isDebugEnabled()) {
this.log.debug("Authentication schemes in the order of preference: " + authPrefs);
}
for (String id: authPrefs) {
Header challenge = challenges.get(id.toLowerCase(Locale.US));
if (challenge != null) {
try {
AuthScheme authScheme = registry.getAuthScheme(id, response.getParams());
authScheme.processChallenge(challenge);
AuthScope authScope = new AuthScope(
authhost.getHostName(),
authhost.getPort(),
authScheme.getRealm(),
authScheme.getSchemeName());
Credentials credentials = credsProvider.getCredentials(authScope);
if (credentials != null) {
options.add(new AuthOption(authScheme, credentials));
}
} catch (IllegalStateException e) {
if (this.log.isWarnEnabled()) {