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 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 }