Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | * ==================================================================== |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed to the Apache Software Foundation (ASF) under one or more |
michael@0 | 5 | * contributor license agreements. See the NOTICE file distributed with |
michael@0 | 6 | * this work for additional information regarding copyright ownership. |
michael@0 | 7 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
michael@0 | 8 | * (the "License"); you may not use this file except in compliance with |
michael@0 | 9 | * the License. You may obtain a copy of the License at |
michael@0 | 10 | * |
michael@0 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 12 | * |
michael@0 | 13 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 16 | * See the License for the specific language governing permissions and |
michael@0 | 17 | * limitations under the License. |
michael@0 | 18 | * ==================================================================== |
michael@0 | 19 | * |
michael@0 | 20 | * This software consists of voluntary contributions made by many |
michael@0 | 21 | * individuals on behalf of the Apache Software Foundation. For more |
michael@0 | 22 | * information on the Apache Software Foundation, please see |
michael@0 | 23 | * <http://www.apache.org/>. |
michael@0 | 24 | * |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | package ch.boye.httpclientandroidlib.auth; |
michael@0 | 28 | |
michael@0 | 29 | import ch.boye.httpclientandroidlib.Header; |
michael@0 | 30 | import ch.boye.httpclientandroidlib.HttpRequest; |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * This interface represents an abstract challenge-response oriented |
michael@0 | 34 | * authentication scheme. |
michael@0 | 35 | * <p> |
michael@0 | 36 | * An authentication scheme should be able to support the following |
michael@0 | 37 | * functions: |
michael@0 | 38 | * <ul> |
michael@0 | 39 | * <li>Parse and process the challenge sent by the target server |
michael@0 | 40 | * in response to request for a protected resource |
michael@0 | 41 | * <li>Provide its textual designation |
michael@0 | 42 | * <li>Provide its parameters, if available |
michael@0 | 43 | * <li>Provide the realm this authentication scheme is applicable to, |
michael@0 | 44 | * if available |
michael@0 | 45 | * <li>Generate authorization string for the given set of credentials |
michael@0 | 46 | * and the HTTP request in response to the authorization challenge. |
michael@0 | 47 | * </ul> |
michael@0 | 48 | * <p> |
michael@0 | 49 | * Authentication schemes may be stateful involving a series of |
michael@0 | 50 | * challenge-response exchanges. |
michael@0 | 51 | * <p> |
michael@0 | 52 | * IMPORTANT: implementations of this interface MUST also implement {@link ContextAwareAuthScheme} |
michael@0 | 53 | * interface in order to remain API compatible with newer versions of HttpClient. |
michael@0 | 54 | * |
michael@0 | 55 | * @since 4.0 |
michael@0 | 56 | */ |
michael@0 | 57 | |
michael@0 | 58 | public interface AuthScheme { |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Processes the given challenge token. Some authentication schemes |
michael@0 | 62 | * may involve multiple challenge-response exchanges. Such schemes must be able |
michael@0 | 63 | * to maintain the state information when dealing with sequential challenges |
michael@0 | 64 | * |
michael@0 | 65 | * @param header the challenge header |
michael@0 | 66 | */ |
michael@0 | 67 | void processChallenge(final Header header) throws MalformedChallengeException; |
michael@0 | 68 | |
michael@0 | 69 | /** |
michael@0 | 70 | * Returns textual designation of the given authentication scheme. |
michael@0 | 71 | * |
michael@0 | 72 | * @return the name of the given authentication scheme |
michael@0 | 73 | */ |
michael@0 | 74 | String getSchemeName(); |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * Returns authentication parameter with the given name, if available. |
michael@0 | 78 | * |
michael@0 | 79 | * @param name The name of the parameter to be returned |
michael@0 | 80 | * |
michael@0 | 81 | * @return the parameter with the given name |
michael@0 | 82 | */ |
michael@0 | 83 | String getParameter(final String name); |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * Returns authentication realm. If the concept of an authentication |
michael@0 | 87 | * realm is not applicable to the given authentication scheme, returns |
michael@0 | 88 | * <code>null</code>. |
michael@0 | 89 | * |
michael@0 | 90 | * @return the authentication realm |
michael@0 | 91 | */ |
michael@0 | 92 | String getRealm(); |
michael@0 | 93 | |
michael@0 | 94 | /** |
michael@0 | 95 | * Tests if the authentication scheme is provides authorization on a per |
michael@0 | 96 | * connection basis instead of usual per request basis |
michael@0 | 97 | * |
michael@0 | 98 | * @return <tt>true</tt> if the scheme is connection based, <tt>false</tt> |
michael@0 | 99 | * if the scheme is request based. |
michael@0 | 100 | */ |
michael@0 | 101 | boolean isConnectionBased(); |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | * Authentication process may involve a series of challenge-response exchanges. |
michael@0 | 105 | * This method tests if the authorization process has been completed, either |
michael@0 | 106 | * successfully or unsuccessfully, that is, all the required authorization |
michael@0 | 107 | * challenges have been processed in their entirety. |
michael@0 | 108 | * |
michael@0 | 109 | * @return <tt>true</tt> if the authentication process has been completed, |
michael@0 | 110 | * <tt>false</tt> otherwise. |
michael@0 | 111 | */ |
michael@0 | 112 | boolean isComplete(); |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Produces an authorization string for the given set of {@link Credentials}. |
michael@0 | 116 | * |
michael@0 | 117 | * @param credentials The set of credentials to be used for athentication |
michael@0 | 118 | * @param request The request being authenticated |
michael@0 | 119 | * @throws AuthenticationException if authorization string cannot |
michael@0 | 120 | * be generated due to an authentication failure |
michael@0 | 121 | * |
michael@0 | 122 | * @return the authorization string |
michael@0 | 123 | * |
michael@0 | 124 | * @deprecated Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)} |
michael@0 | 125 | */ |
michael@0 | 126 | @Deprecated |
michael@0 | 127 | Header authenticate(Credentials credentials, HttpRequest request) |
michael@0 | 128 | throws AuthenticationException; |
michael@0 | 129 | |
michael@0 | 130 | } |