KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > httpclient > auth > AuthScheme


1 /*
2  * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/AuthScheme.java,v 1.4.2.2 2004/02/22 18:21:14 olegk Exp $
3  * $Revision: 1.4.2.2 $
4  * $Date: 2004/02/22 18:21:14 $
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  * [Additional notices, if required by prior licensing conditions]
29  *
30  */

31
32 package org.apache.commons.httpclient.auth;
33
34 import org.apache.commons.httpclient.Credentials;
35
36 /**
37  * <p>
38  * This interface represents an abstract authentication scheme.
39  * </p>
40  * <p>
41  * An authentication scheme should be able to support the following
42  * functions:
43  * <ul>
44  * <li>Provide its textual designation
45  * <li>Provide its parameters, if available
46  * <li>Provide the realm this authentication scheme is applicable to,
47  * if available
48  * <li>Generate authorization string for the given set of credentials,
49  * request method and URI as specificed in the HTTP request line
50  * </ul>
51  * </p>
52  * <p>
53  * Authentication schemes may ignore method name and URI parameters
54  * if they are not relevant for the given authentication mechanism
55  * </p>
56  *
57  * @author <a HREF="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
58  * @author <a HREF="mailto:adrian@ephox.com">Adrian Sutton</a>
59  *
60  * @since 2.0beta1
61  */

62
63 public interface AuthScheme {
64     
65     /**
66      * Returns textual designation of the given authentication scheme.
67      *
68      * @return the name of the given authentication scheme
69      */

70     String JavaDoc getSchemeName();
71
72     /**
73      * Returns authentication parameter with the given name, if available.
74      *
75      * @param name The name of the parameter to be returned
76      *
77      * @return the parameter with the given name
78      */

79     String JavaDoc getParameter(final String JavaDoc name);
80
81     /**
82      * Returns authentication realm. If the concept of an authentication
83      * realm is not applicable to the given authentication scheme, returns
84      * <code>null</code>.
85      *
86      * @return the authentication realm
87      */

88     String JavaDoc getRealm();
89     
90     /**
91      * Returns a String identifying the authentication challenge. This is
92      * used, in combination with the host and port to determine if
93      * authorization has already been attempted or not. Schemes which
94      * require multiple requests to complete the authentication should
95      * return a different value for each stage in the request.
96      *
97      * <p>Additionally, the ID should take into account any changes to the
98      * authentication challenge and return a different value when appropriate.
99      * For example when the realm changes in basic authentication it should be
100      * considered a different authentication attempt and a different value should
101      * be returned.</p>
102      *
103      * @return String a String identifying the authentication challenge. The
104      * returned value may be null.
105      */

106     String JavaDoc getID();
107     
108     /**
109      * Produces an authorization string for the given set of {@link Credentials},
110      * method name and URI using the given authentication scheme.
111      *
112      * @param credentials The set of credentials to be used for athentication
113      * @param method The name of the method that requires authorization.
114      * This parameter may be ignored, if it is irrelevant
115      * or not applicable to the given authentication scheme
116      * @param uri The URI for which authorization is needed.
117      * This parameter may be ignored, if it is irrelevant or not
118      * applicable to the given authentication scheme
119      * @throws AuthenticationException if authorization string cannot
120      * be generated due to an authentication failure
121      *
122      * @return the authorization string
123      *
124      * @see org.apache.commons.httpclient.HttpMethod#getName()
125      * @see org.apache.commons.httpclient.HttpMethod#getPath()
126      */

127     String JavaDoc authenticate(Credentials credentials, String JavaDoc method, String JavaDoc uri)
128       throws AuthenticationException;
129        
130 }
131
Popular Tags