View Javadoc

1   /*
2    * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/auth/CredentialsProvider.java,v 1.6 2004/07/05 22:46:59 olegk Exp $
3    * $Revision: 357669 $
4    * $Date: 2005-12-19 04:19:10 -0500 (Mon, 19 Dec 2005) $
5    *
6    * ====================================================================
7    *
8    *  Copyright 2002-2004 The Apache Software Foundation
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   * ====================================================================
22   *
23   * This software consists of voluntary contributions made by many
24   * individuals on behalf of the Apache Software Foundation.  For more
25   * information on the Apache Software Foundation, please see
26   * <http://www.apache.org/>.
27   *
28   */
29  
30  package org.apache.commons.httpclient.auth;
31  
32  import org.apache.commons.httpclient.Credentials;
33  
34  /***
35   * <p>
36   * Credentials provider interface can be used to provide {@link 
37   * org.apache.commons.httpclient.HttpMethod HTTP method} with a means to request
38   * authentication credentials if no credentials have been given or given
39   * credentials are incorrect.
40   * </p>
41   * <p>
42   * HttpClient makes no provisions to check whether the same credentials have
43   * been tried already. It is a responsibility of the custom credentials provider
44   * to keep track of authentication attempts and to ensure that credentials known
45   * to be invalid are not retried. HttpClient will simply store the set of
46   * credentials returned by the custom credentials provider in the
47   * {@link org.apache.commons.httpclient.HttpState http state} object and will
48   * attempt to use these credentials for all subsequent requests with the given
49   * authentication scope.
50   * </p>
51   * <p>
52   * Classes implementing this interface must synchronize access to shared data as
53   * methods of this interfrace may be executed from multiple threads
54   * </p>
55   * 
56   * 
57   * @author Ortwin Glueck
58   * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
59   * 
60   * @since 3.0
61   */
62  public interface CredentialsProvider {
63  
64      /***
65       * Sets the credentials provider parameter.
66       * <p>
67       * This parameter expects a value of type {@link CredentialsProvider}.
68       * </p>
69       */ 
70      public static final String PROVIDER = "http.authentication.credential-provider";
71      
72      /***
73       * Requests additional {@link Credentials authentication credentials}.
74       * 
75       * @param scheme the {@link AuthScheme authentication scheme}
76       * @param host the authentication host
77       * @param port the port of the authentication host
78       * @param proxy <tt>true</tt> if authenticating with a proxy,
79       *              <tt>false</tt> otherwise
80       */ 
81      public Credentials getCredentials(
82          final AuthScheme scheme, 
83          final String host, 
84          int port, 
85          boolean proxy) throws CredentialsNotAvailableException; 
86  
87  }