michael@0: /* michael@0: * ==================================================================== michael@0: * michael@0: * Licensed to the Apache Software Foundation (ASF) under one or more michael@0: * contributor license agreements. See the NOTICE file distributed with michael@0: * this work for additional information regarding copyright ownership. michael@0: * The ASF licenses this file to You under the Apache License, Version 2.0 michael@0: * (the "License"); you may not use this file except in compliance with michael@0: * the License. You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: * ==================================================================== michael@0: * michael@0: * This software consists of voluntary contributions made by many michael@0: * individuals on behalf of the Apache Software Foundation. For more michael@0: * information on the Apache Software Foundation, please see michael@0: * . michael@0: * michael@0: */ michael@0: michael@0: package ch.boye.httpclientandroidlib.auth; michael@0: michael@0: import ch.boye.httpclientandroidlib.Header; michael@0: import ch.boye.httpclientandroidlib.HttpRequest; michael@0: michael@0: /** michael@0: * This interface represents an abstract challenge-response oriented michael@0: * authentication scheme. michael@0: *

michael@0: * An authentication scheme should be able to support the following michael@0: * functions: michael@0: *

michael@0: *

michael@0: * Authentication schemes may be stateful involving a series of michael@0: * challenge-response exchanges. michael@0: *

michael@0: * IMPORTANT: implementations of this interface MUST also implement {@link ContextAwareAuthScheme} michael@0: * interface in order to remain API compatible with newer versions of HttpClient. michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: michael@0: public interface AuthScheme { michael@0: michael@0: /** michael@0: * Processes the given challenge token. Some authentication schemes michael@0: * may involve multiple challenge-response exchanges. Such schemes must be able michael@0: * to maintain the state information when dealing with sequential challenges michael@0: * michael@0: * @param header the challenge header michael@0: */ michael@0: void processChallenge(final Header header) throws MalformedChallengeException; michael@0: michael@0: /** michael@0: * Returns textual designation of the given authentication scheme. michael@0: * michael@0: * @return the name of the given authentication scheme michael@0: */ michael@0: String getSchemeName(); michael@0: michael@0: /** michael@0: * Returns authentication parameter with the given name, if available. michael@0: * michael@0: * @param name The name of the parameter to be returned michael@0: * michael@0: * @return the parameter with the given name michael@0: */ michael@0: String getParameter(final String name); michael@0: michael@0: /** michael@0: * Returns authentication realm. If the concept of an authentication michael@0: * realm is not applicable to the given authentication scheme, returns michael@0: * null. michael@0: * michael@0: * @return the authentication realm michael@0: */ michael@0: String getRealm(); michael@0: michael@0: /** michael@0: * Tests if the authentication scheme is provides authorization on a per michael@0: * connection basis instead of usual per request basis michael@0: * michael@0: * @return true if the scheme is connection based, false michael@0: * if the scheme is request based. michael@0: */ michael@0: boolean isConnectionBased(); michael@0: michael@0: /** michael@0: * Authentication process may involve a series of challenge-response exchanges. michael@0: * This method tests if the authorization process has been completed, either michael@0: * successfully or unsuccessfully, that is, all the required authorization michael@0: * challenges have been processed in their entirety. michael@0: * michael@0: * @return true if the authentication process has been completed, michael@0: * false otherwise. michael@0: */ michael@0: boolean isComplete(); michael@0: michael@0: /** michael@0: * Produces an authorization string for the given set of {@link Credentials}. michael@0: * michael@0: * @param credentials The set of credentials to be used for athentication michael@0: * @param request The request being authenticated michael@0: * @throws AuthenticationException if authorization string cannot michael@0: * be generated due to an authentication failure michael@0: * michael@0: * @return the authorization string michael@0: * michael@0: * @deprecated Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)} michael@0: */ michael@0: @Deprecated michael@0: Header authenticate(Credentials credentials, HttpRequest request) michael@0: throws AuthenticationException; michael@0: michael@0: }