use of org.apache.http.auth.AuthOption in project iaf by ibissource.
the class OAuthPreferringAuthenticationStrategy method select.
// private boolean refreshTokenOn401; // retrying unchallenged request/responses might cause endless authentication loops
@Override
public Queue<AuthOption> select(Map<String, Header> challenges, HttpHost authhost, HttpResponse response, HttpContext context) throws MalformedChallengeException {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
this.log.debug("Credentials provider not set in the context");
return options;
}
final AuthScope authScope = new AuthScope(authhost, "", OAuthAuthenticationScheme.SCHEME_NAME);
final Credentials credentials = credsProvider.getCredentials(authScope);
if (credentials != null) {
// always add OAuth as an authentication option, if any challenges are returned by server
options.add(new AuthOption(new OAuthAuthenticationScheme(), credentials));
}
options.addAll(super.select(challenges, authhost, response, clientContext));
return options;
}
Aggregations