public class PreemptiveAuthorizer extends Object implements org.apache.http.HttpRequestInterceptor
To make this work:
context = new BasicHttpContext(); context.setAttribute(ClientContext.AUTH_SCHEME_PREF, Arrays.asList(OAuthSchemeFactory.SCHEME_NAME)); client = new DefaultHttpClient(); client.getAuthSchemes().register(OAuthSchemeFactory.SCHEME_NAME, new OAuthSchemeFactory()); client.getCredentialsProvider().setCredentials(new AuthScope("server.com", 80), new OAuthCredentials(accessor)); client.getParams().setParameter(OAuthSchemeFactory.DEFAULT_REALM, ProtectedResource.REALM); client.addRequestInterceptor(new PreemptiveAuthorizer(), 0);
Constructor and Description |
---|
PreemptiveAuthorizer() |
Modifier and Type | Method and Description |
---|---|
void |
process(org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context)
If no auth scheme has been selected for the given context, consider each of
the preferred auth schemes and select the first one for which an AuthScheme
and matching Credentials are available.
|
public void process(org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException, IOException
process
in interface org.apache.http.HttpRequestInterceptor
org.apache.http.HttpException
IOException
Copyright © 2008–2017 Province of British Columbia. All rights reserved.