Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 */
28 package ch.boye.httpclientandroidlib.auth.params;
30 import ch.boye.httpclientandroidlib.annotation.Immutable;
32 import ch.boye.httpclientandroidlib.params.HttpParams;
33 import ch.boye.httpclientandroidlib.protocol.HTTP;
35 /**
36 * An adaptor for manipulating HTTP authentication parameters
37 * in {@link HttpParams}.
38 *
39 * @since 4.0
40 *
41 * @see AuthPNames
42 */
43 @Immutable
44 public final class AuthParams {
46 private AuthParams() {
47 super();
48 }
50 /**
51 * Obtains the charset for encoding
52 * {@link ch.boye.httpclientandroidlib.auth.Credentials}.If not configured,
53 * {@link HTTP#DEFAULT_PROTOCOL_CHARSET}is used instead.
54 *
55 * @return The charset
56 */
57 public static String getCredentialCharset(final HttpParams params) {
58 if (params == null) {
59 throw new IllegalArgumentException("HTTP parameters may not be null");
60 }
61 String charset = (String) params.getParameter
62 (AuthPNames.CREDENTIAL_CHARSET);
63 if (charset == null) {
64 charset = HTTP.DEFAULT_PROTOCOL_CHARSET;
65 }
66 return charset;
67 }
70 /**
71 * Sets the charset to be used when encoding
72 * {@link ch.boye.httpclientandroidlib.auth.Credentials}.
73 *
74 * @param charset The charset
75 */
76 public static void setCredentialCharset(final HttpParams params, final String charset) {
77 if (params == null) {
78 throw new IllegalArgumentException("HTTP parameters may not be null");
79 }
80 params.setParameter(AuthPNames.CREDENTIAL_CHARSET, charset);
81 }
83 }