|
1 /* |
|
2 * ==================================================================== |
|
3 * Licensed to the Apache Software Foundation (ASF) under one |
|
4 * or more contributor license agreements. See the NOTICE file |
|
5 * distributed with this work for additional information |
|
6 * regarding copyright ownership. The ASF licenses this file |
|
7 * to you under the Apache License, Version 2.0 (the |
|
8 * "License"); you may not use this file except in compliance |
|
9 * with the License. You may obtain a copy of the License at |
|
10 * |
|
11 * http://www.apache.org/licenses/LICENSE-2.0 |
|
12 * |
|
13 * Unless required by applicable law or agreed to in writing, |
|
14 * software distributed under the License is distributed on an |
|
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
16 * KIND, either express or implied. See the License for the |
|
17 * specific language governing permissions and limitations |
|
18 * under the License. |
|
19 * ==================================================================== |
|
20 * |
|
21 * This software consists of voluntary contributions made by many |
|
22 * individuals on behalf of the Apache Software Foundation. For more |
|
23 * information on the Apache Software Foundation, please see |
|
24 * <http://www.apache.org/>. |
|
25 * |
|
26 */ |
|
27 |
|
28 package ch.boye.httpclientandroidlib.client.protocol; |
|
29 |
|
30 import java.util.List; |
|
31 |
|
32 import ch.boye.httpclientandroidlib.annotation.NotThreadSafe; |
|
33 |
|
34 import ch.boye.httpclientandroidlib.auth.AuthSchemeRegistry; |
|
35 import ch.boye.httpclientandroidlib.client.CookieStore; |
|
36 import ch.boye.httpclientandroidlib.client.CredentialsProvider; |
|
37 import ch.boye.httpclientandroidlib.cookie.CookieSpecRegistry; |
|
38 import ch.boye.httpclientandroidlib.params.HttpParams; |
|
39 import ch.boye.httpclientandroidlib.protocol.HttpContext; |
|
40 |
|
41 /** |
|
42 * Configuration facade for {@link HttpContext} instances. |
|
43 * |
|
44 * @since 4.0 |
|
45 */ |
|
46 @NotThreadSafe |
|
47 public class ClientContextConfigurer implements ClientContext { |
|
48 |
|
49 private final HttpContext context; |
|
50 |
|
51 public ClientContextConfigurer (final HttpContext context) { |
|
52 if (context == null) |
|
53 throw new IllegalArgumentException("HTTP context may not be null"); |
|
54 this.context = context; |
|
55 } |
|
56 |
|
57 public void setCookieSpecRegistry(final CookieSpecRegistry registry) { |
|
58 this.context.setAttribute(COOKIESPEC_REGISTRY, registry); |
|
59 } |
|
60 |
|
61 public void setAuthSchemeRegistry(final AuthSchemeRegistry registry) { |
|
62 this.context.setAttribute(AUTHSCHEME_REGISTRY, registry); |
|
63 } |
|
64 |
|
65 public void setCookieStore(final CookieStore store) { |
|
66 this.context.setAttribute(COOKIE_STORE, store); |
|
67 } |
|
68 |
|
69 public void setCredentialsProvider(final CredentialsProvider provider) { |
|
70 this.context.setAttribute(CREDS_PROVIDER, provider); |
|
71 } |
|
72 |
|
73 /** |
|
74 * @deprecated (4.1-alpha1) Use {@link HttpParams#setParameter(String, Object)} to set the parameters |
|
75 * {@link ch.boye.httpclientandroidlib.auth.params.AuthPNames#TARGET_AUTH_PREF AuthPNames#TARGET_AUTH_PREF} and |
|
76 * {@link ch.boye.httpclientandroidlib.auth.params.AuthPNames#PROXY_AUTH_PREF AuthPNames#PROXY_AUTH_PREF} instead |
|
77 */ |
|
78 @Deprecated |
|
79 public void setAuthSchemePref(final List<String> list) { |
|
80 this.context.setAttribute(AUTH_SCHEME_PREF, list); |
|
81 } |
|
82 |
|
83 } |