View Javadoc

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