Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
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.client;
30 import java.util.Map;
32 import ch.boye.httpclientandroidlib.Header;
33 import ch.boye.httpclientandroidlib.HttpResponse;
34 import ch.boye.httpclientandroidlib.auth.AuthScheme;
35 import ch.boye.httpclientandroidlib.auth.AuthenticationException;
36 import ch.boye.httpclientandroidlib.auth.MalformedChallengeException;
37 import ch.boye.httpclientandroidlib.protocol.HttpContext;
39 /**
40 /**
41 * A handler for determining if an HTTP response represents an authentication
42 * challenge that was sent back to the client as a result of authentication
43 * failure.
44 * <p>
45 * Implementations of this interface must be thread-safe. Access to shared
46 * data must be synchronized as methods of this interface may be executed
47 * from multiple threads.
48 *
49 * @since 4.0
50 */
51 public interface AuthenticationHandler {
53 /**
54 * Determines if the given HTTP response response represents
55 * an authentication challenge that was sent back as a result
56 * of authentication failure
57 * @param response HTTP response.
58 * @param context HTTP context.
59 * @return <code>true</code> if user authentication is required,
60 * <code>false</code> otherwise.
61 */
62 boolean isAuthenticationRequested(
63 HttpResponse response,
64 HttpContext context);
66 /**
67 * Extracts from the given HTTP response a collection of authentication
68 * challenges, each of which represents an authentication scheme supported
69 * by the authentication host.
70 *
71 * @param response HTTP response.
72 * @param context HTTP context.
73 * @return a collection of challenges keyed by names of corresponding
74 * authentication schemes.
75 * @throws MalformedChallengeException if one of the authentication
76 * challenges is not valid or malformed.
77 */
78 Map<String, Header> getChallenges(
79 HttpResponse response,
80 HttpContext context) throws MalformedChallengeException;
82 /**
83 * Selects one authentication challenge out of all available and
84 * creates and generates {@link AuthScheme} instance capable of
85 * processing that challenge.
86 * @param challenges collection of challenges.
87 * @param response HTTP response.
88 * @param context HTTP context.
89 * @return authentication scheme to use for authentication.
90 * @throws AuthenticationException if an authentication scheme
91 * could not be selected.
92 */
93 AuthScheme selectScheme(
94 Map<String, Header> challenges,
95 HttpResponse response,
96 HttpContext context) throws AuthenticationException;
98 }