1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthScheme.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,130 @@ 1.4 +/* 1.5 + * ==================================================================== 1.6 + * 1.7 + * Licensed to the Apache Software Foundation (ASF) under one or more 1.8 + * contributor license agreements. See the NOTICE file distributed with 1.9 + * this work for additional information regarding copyright ownership. 1.10 + * The ASF licenses this file to You under the Apache License, Version 2.0 1.11 + * (the "License"); you may not use this file except in compliance with 1.12 + * the License. You may obtain a copy of the License at 1.13 + * 1.14 + * http://www.apache.org/licenses/LICENSE-2.0 1.15 + * 1.16 + * Unless required by applicable law or agreed to in writing, software 1.17 + * distributed under the License is distributed on an "AS IS" BASIS, 1.18 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.19 + * See the License for the specific language governing permissions and 1.20 + * limitations under the License. 1.21 + * ==================================================================== 1.22 + * 1.23 + * This software consists of voluntary contributions made by many 1.24 + * individuals on behalf of the Apache Software Foundation. For more 1.25 + * information on the Apache Software Foundation, please see 1.26 + * <http://www.apache.org/>. 1.27 + * 1.28 + */ 1.29 + 1.30 +package ch.boye.httpclientandroidlib.auth; 1.31 + 1.32 +import ch.boye.httpclientandroidlib.Header; 1.33 +import ch.boye.httpclientandroidlib.HttpRequest; 1.34 + 1.35 +/** 1.36 + * This interface represents an abstract challenge-response oriented 1.37 + * authentication scheme. 1.38 + * <p> 1.39 + * An authentication scheme should be able to support the following 1.40 + * functions: 1.41 + * <ul> 1.42 + * <li>Parse and process the challenge sent by the target server 1.43 + * in response to request for a protected resource 1.44 + * <li>Provide its textual designation 1.45 + * <li>Provide its parameters, if available 1.46 + * <li>Provide the realm this authentication scheme is applicable to, 1.47 + * if available 1.48 + * <li>Generate authorization string for the given set of credentials 1.49 + * and the HTTP request in response to the authorization challenge. 1.50 + * </ul> 1.51 + * <p> 1.52 + * Authentication schemes may be stateful involving a series of 1.53 + * challenge-response exchanges. 1.54 + * <p> 1.55 + * IMPORTANT: implementations of this interface MUST also implement {@link ContextAwareAuthScheme} 1.56 + * interface in order to remain API compatible with newer versions of HttpClient. 1.57 + * 1.58 + * @since 4.0 1.59 + */ 1.60 + 1.61 +public interface AuthScheme { 1.62 + 1.63 + /** 1.64 + * Processes the given challenge token. Some authentication schemes 1.65 + * may involve multiple challenge-response exchanges. Such schemes must be able 1.66 + * to maintain the state information when dealing with sequential challenges 1.67 + * 1.68 + * @param header the challenge header 1.69 + */ 1.70 + void processChallenge(final Header header) throws MalformedChallengeException; 1.71 + 1.72 + /** 1.73 + * Returns textual designation of the given authentication scheme. 1.74 + * 1.75 + * @return the name of the given authentication scheme 1.76 + */ 1.77 + String getSchemeName(); 1.78 + 1.79 + /** 1.80 + * Returns authentication parameter with the given name, if available. 1.81 + * 1.82 + * @param name The name of the parameter to be returned 1.83 + * 1.84 + * @return the parameter with the given name 1.85 + */ 1.86 + String getParameter(final String name); 1.87 + 1.88 + /** 1.89 + * Returns authentication realm. If the concept of an authentication 1.90 + * realm is not applicable to the given authentication scheme, returns 1.91 + * <code>null</code>. 1.92 + * 1.93 + * @return the authentication realm 1.94 + */ 1.95 + String getRealm(); 1.96 + 1.97 + /** 1.98 + * Tests if the authentication scheme is provides authorization on a per 1.99 + * connection basis instead of usual per request basis 1.100 + * 1.101 + * @return <tt>true</tt> if the scheme is connection based, <tt>false</tt> 1.102 + * if the scheme is request based. 1.103 + */ 1.104 + boolean isConnectionBased(); 1.105 + 1.106 + /** 1.107 + * Authentication process may involve a series of challenge-response exchanges. 1.108 + * This method tests if the authorization process has been completed, either 1.109 + * successfully or unsuccessfully, that is, all the required authorization 1.110 + * challenges have been processed in their entirety. 1.111 + * 1.112 + * @return <tt>true</tt> if the authentication process has been completed, 1.113 + * <tt>false</tt> otherwise. 1.114 + */ 1.115 + boolean isComplete(); 1.116 + 1.117 + /** 1.118 + * Produces an authorization string for the given set of {@link Credentials}. 1.119 + * 1.120 + * @param credentials The set of credentials to be used for athentication 1.121 + * @param request The request being authenticated 1.122 + * @throws AuthenticationException if authorization string cannot 1.123 + * be generated due to an authentication failure 1.124 + * 1.125 + * @return the authorization string 1.126 + * 1.127 + * @deprecated Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)} 1.128 + */ 1.129 + @Deprecated 1.130 + Header authenticate(Credentials credentials, HttpRequest request) 1.131 + throws AuthenticationException; 1.132 + 1.133 +}