|
28 | 28 | import cz.msebera.android.httpclient.auth.AuthState;
|
29 | 29 | import cz.msebera.android.httpclient.auth.Credentials;
|
30 | 30 | import cz.msebera.android.httpclient.client.CredentialsProvider;
|
31 |
| -import cz.msebera.android.httpclient.client.protocol.ClientContext; |
| 31 | +import cz.msebera.android.httpclient.client.protocol.HttpClientContext; |
32 | 32 | import cz.msebera.android.httpclient.impl.auth.BasicScheme;
|
33 |
| -import cz.msebera.android.httpclient.protocol.ExecutionContext; |
34 | 33 | import cz.msebera.android.httpclient.protocol.HttpContext;
|
| 34 | +import cz.msebera.android.httpclient.protocol.HttpCoreContext; |
35 | 35 |
|
36 | 36 | public class PreemptiveAuthorizationHttpRequestInterceptor implements HttpRequestInterceptor {
|
37 | 37 |
|
38 |
| - public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { |
39 |
| - AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); |
| 38 | + public void process(final HttpRequest request, final HttpContext context) { |
| 39 | + AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE); |
40 | 40 | CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
|
41 |
| - ClientContext.CREDS_PROVIDER); |
42 |
| - HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); |
| 41 | + HttpClientContext.CREDS_PROVIDER); |
| 42 | + HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST); |
43 | 43 |
|
44 | 44 | if (authState.getAuthScheme() == null) {
|
45 | 45 | AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
|
46 | 46 | Credentials creds = credsProvider.getCredentials(authScope);
|
47 | 47 | if (creds != null) {
|
48 |
| - authState.setAuthScheme(new BasicScheme()); |
49 |
| - authState.setCredentials(creds); |
| 48 | + authState.update(new BasicScheme(), creds); |
50 | 49 | }
|
51 | 50 | }
|
52 | 51 | }
|
|
0 commit comments