|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractAuthentication.java | - | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* ====================================================================
|
|
3 |
*
|
|
4 |
* The Apache Software License, Version 1.1
|
|
5 |
*
|
|
6 |
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
|
7 |
* reserved.
|
|
8 |
*
|
|
9 |
* Redistribution and use in source and binary forms, with or without
|
|
10 |
* modification, are permitted provided that the following conditions
|
|
11 |
* are met:
|
|
12 |
*
|
|
13 |
* 1. Redistributions of source code must retain the above copyright
|
|
14 |
* notice, this list of conditions and the following disclaimer.
|
|
15 |
*
|
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer in
|
|
18 |
* the documentation and/or other materials provided with the
|
|
19 |
* distribution.
|
|
20 |
*
|
|
21 |
* 3. The end-user documentation included with the redistribution, if
|
|
22 |
* any, must include the following acknowlegement:
|
|
23 |
* "This product includes software developed by the
|
|
24 |
* Apache Software Foundation (http://www.apache.org/)."
|
|
25 |
* Alternately, this acknowlegement may appear in the software itself,
|
|
26 |
* if and wherever such third-party acknowlegements normally appear.
|
|
27 |
*
|
|
28 |
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
|
|
29 |
* Foundation" must not be used to endorse or promote products
|
|
30 |
* derived from this software without prior written permission. For
|
|
31 |
* written permission, please contact apache@apache.org.
|
|
32 |
*
|
|
33 |
* 5. Products derived from this software may not be called "Apache"
|
|
34 |
* nor may "Apache" appear in their names without prior written
|
|
35 |
* permission of the Apache Group.
|
|
36 |
*
|
|
37 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
38 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
39 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
40 |
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
41 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
42 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
43 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
44 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
45 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
46 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
47 |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
48 |
* SUCH DAMAGE.
|
|
49 |
* ====================================================================
|
|
50 |
*
|
|
51 |
* This software consists of voluntary contributions made by many
|
|
52 |
* individuals on behalf of the Apache Software Foundation. For more
|
|
53 |
* information on the Apache Software Foundation, please see
|
|
54 |
* <http://www.apache.org/>.
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
package org.apache.cactus.client.authentication;
|
|
58 |
|
|
59 |
/**
|
|
60 |
* This class was designed with the simple assumption that ALL authentication
|
|
61 |
* implementations will have a String <code>Name</code> and a String
|
|
62 |
* <code>Password</code>. Two abstract functions <code>validateName</code> and
|
|
63 |
* <code>validatePassword</code> provide for concrete implementations to
|
|
64 |
* perform character validation. All the work is then done in the
|
|
65 |
* <code>configure</code> abstract function. In the
|
|
66 |
* <code>BasicAuthentication</code> class, for example, the configuring is done
|
|
67 |
* by adding the request property "Authorization" with a value
|
|
68 |
* "Basic <base64encode of 'userid:password'>".
|
|
69 |
*
|
|
70 |
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
|
71 |
* @author <a href="mailto:Jason.Robertson@acs-inc.com">Jason Robertson</a>
|
|
72 |
* @author <a href="mailto:cmlenz@apache.org">Christopher Lenz</a>
|
|
73 |
*
|
|
74 |
* @since 1.3
|
|
75 |
*
|
|
76 |
* @version $Id: AbstractAuthentication.java,v 1.10 2003/06/15 16:28:00 cmlenz Exp $
|
|
77 |
*/
|
|
78 |
public abstract class AbstractAuthentication implements Authentication |
|
79 |
{ |
|
80 |
/**
|
|
81 |
* User name part of the Credential
|
|
82 |
*/
|
|
83 |
protected String name;
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Password part of the Credential
|
|
87 |
*/
|
|
88 |
protected String password;
|
|
89 |
|
|
90 |
/**
|
|
91 |
* @param theName user name of the Credential
|
|
92 |
* @param thePassword user password of the Credential
|
|
93 |
*/
|
|
94 | 0 |
public AbstractAuthentication(String theName, String thePassword)
|
95 |
{ |
|
96 | 0 |
setName(theName); |
97 | 0 |
setPassword(thePassword); |
98 |
} |
|
99 |
|
|
100 |
/**
|
|
101 |
* Sets the user name.
|
|
102 |
*
|
|
103 |
* @param theName user name of the Credential
|
|
104 |
*/
|
|
105 | 0 |
public final void setName(String theName) |
106 |
{ |
|
107 | 0 |
validateName(theName); |
108 | 0 |
this.name = theName;
|
109 |
} |
|
110 |
|
|
111 |
/**
|
|
112 |
* @return the user name of the Credential
|
|
113 |
*/
|
|
114 | 0 |
public final String getName()
|
115 |
{ |
|
116 | 0 |
return this.name; |
117 |
} |
|
118 |
|
|
119 |
/**
|
|
120 |
* Sets the user password of the Credential.
|
|
121 |
*
|
|
122 |
* @param thePassword the user password of the Credential
|
|
123 |
*/
|
|
124 | 0 |
public final void setPassword(String thePassword) |
125 |
{ |
|
126 | 0 |
validatePassword(thePassword); |
127 | 0 |
this.password = thePassword;
|
128 |
} |
|
129 |
|
|
130 |
/**
|
|
131 |
* @return the user password of the Credential
|
|
132 |
*/
|
|
133 | 0 |
protected final String getPassword()
|
134 |
{ |
|
135 | 0 |
return this.password; |
136 |
} |
|
137 |
|
|
138 |
/**
|
|
139 |
* Verify that the user name passed as parameter is a valid user name
|
|
140 |
* for the current authentication scheme.
|
|
141 |
*
|
|
142 |
* @param theName the user name to validate
|
|
143 |
*/
|
|
144 |
protected abstract void validateName(String theName); |
|
145 |
|
|
146 |
/**
|
|
147 |
* Verify that the user password passed as parameter is a valid user
|
|
148 |
* password for the current authentication scheme.
|
|
149 |
*
|
|
150 |
* @param thePassword the user password to validate
|
|
151 |
*/
|
|
152 |
protected abstract void validatePassword(String thePassword); |
|
153 |
|
|
154 |
} |
|
155 |
|
|