2
* $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/RFC2617Scheme.java,v 1.4.2.1 2004/02/22 18:21:15 olegk Exp $
4
* $Date: 2004/02/22 18:21:15 $
6
* ====================================================================
8
* Copyright 2002-2004 The Apache Software Foundation
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
14
* http://www.apache.org/licenses/LICENSE-2.0
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
* ====================================================================
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/>.
28
* [Additional notices, if required by prior licensing conditions]
32
package org.apache.commons.httpclient.auth;
38
* Abstract authentication scheme class that lays foundation for all
39
* RFC 2617 compliant authetication schemes and provides capabilities common
40
* to all authentication schemes defined in RFC 2617.
43
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
45
public abstract class RFC2617Scheme extends AuthSchemeBase {
48
* Authentication parameter map.
50
private Map params = null;
53
* Default constructor for RFC2617 compliant authetication schemes.
55
* @param challenge authentication challenge
57
* @throws MalformedChallengeException is thrown if the authentication challenge
60
public RFC2617Scheme(final String challenge) throws MalformedChallengeException {
62
String s = AuthChallengeParser.extractScheme(challenge);
63
if (!s.equalsIgnoreCase(getSchemeName())) {
64
throw new MalformedChallengeException(
65
"Invalid " + getSchemeName() + " challenge: " + challenge);
67
this.params = AuthChallengeParser.extractParams(challenge);
71
* Returns authentication parameters map. Keys in the map are lower-cased.
73
* @return the map of authentication parameters
75
protected Map getParameters() {
80
* Returns authentication parameter with the given name, if available.
82
* @param name The name of the parameter to be returned
84
* @return the parameter with the given name
86
public String getParameter(String name) {
88
throw new IllegalArgumentException("Parameter name may not be null");
90
return (String) this.params.get(name.toLowerCase());
94
* Returns authentication realm. The realm may not be null.
96
* @return the authentication realm
98
public String getRealm() {
99
return getParameter("realm");
103
* Returns a String identifying the authentication challenge. This is
104
* used, in combination with the host and port to determine if
105
* authorization has already been attempted or not. Schemes which
106
* require multiple requests to complete the authentication should
107
* return a different value for each stage in the request.
109
* <p>Additionally, the ID should take into account any changes to the
110
* authentication challenge and return a different value when appropriate.
111
* For example when the realm changes in basic authentication it should be
112
* considered a different authentication attempt and a different value should
115
* <p>This method simply returns the realm for the challenge.</p>
117
* @return String a String identifying the authentication challenge. The
118
* returned value may be null.
120
public String getID() {