1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 }