1
|
|
/* Generated by AspectJ version 1.0.5 */
|
2
|
|
package org.apache.cactus.client.authentication;
|
3
|
|
import org.apache.cactus.WebRequest;
|
4
|
|
|
5
|
|
/**
|
6
|
|
* This class was designed with the simple assumption that ALL authentication
|
7
|
|
* implementations will have a String <code>Name</code> and a String
|
8
|
|
* <code>Password</code>. Two abstract functions <code>validateName</code> and
|
9
|
|
* <code>validatePassword</code> provide for concrete implementations to
|
10
|
|
* perform character validation. All the work is then done in the
|
11
|
|
* <code>configure</code> abstract function. In the
|
12
|
|
* <code>BasicAuthentication</code> class, for example, the configuring is done
|
13
|
|
* by adding the request property "Authorization" with a value
|
14
|
|
* "Basic <base64encode of 'userid:password'>".
|
15
|
|
*
|
16
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
17
|
|
* @author <a href="mailto:Jason.Robertson@acs-inc.com">Jason Robertson</a>
|
18
|
|
*
|
19
|
|
* @since 1.3
|
20
|
|
*
|
21
|
|
* @version $Id: AbstractAuthentication.html,v 1.1 2003/04/14 12:27:31 sinisa Exp $
|
22
|
|
*/
|
23
|
|
public abstract class AbstractAuthentication {
|
24
|
|
/**
|
25
|
|
* User name part of the Credential
|
26
|
|
*/
|
27
|
|
private String name;
|
28
|
|
/**
|
29
|
|
* Password part of the Credential
|
30
|
|
*/
|
31
|
|
private String password;
|
32
|
|
/**
|
33
|
|
* @param theName user name of the Credential
|
34
|
|
* @param thePassword user password of the Credential
|
35
|
|
*/
|
36
|
5
|
public AbstractAuthentication(String theName, String thePassword) {
|
37
|
5
|
super();
|
38
|
5
|
this.setName(theName);
|
39
|
5
|
this.setPassword(thePassword);
|
40
|
|
}
|
41
|
|
/**
|
42
|
|
* Sets the user name.
|
43
|
|
*
|
44
|
|
* @param theName user name of the Credential
|
45
|
|
*/
|
46
|
5
|
public void setName(String theName) {
|
47
|
5
|
this.validateName(theName);
|
48
|
5
|
this.name = theName;
|
49
|
|
}
|
50
|
|
|
51
|
|
/**
|
52
|
|
* @return the user name of the Credential
|
53
|
|
*/
|
54
|
10
|
public String getName() {
|
55
|
10
|
return this.name;
|
56
|
|
}
|
57
|
|
|
58
|
|
/**
|
59
|
|
* Sets the user password of the Credential.
|
60
|
|
*
|
61
|
|
* @param thePassword the user password of the Credential
|
62
|
|
*/
|
63
|
5
|
public void setPassword(String thePassword) {
|
64
|
5
|
this.validatePassword(thePassword);
|
65
|
5
|
this.password = thePassword;
|
66
|
|
}
|
67
|
|
|
68
|
|
/**
|
69
|
|
* Verify that the user name passed as parameter is a valid user name
|
70
|
|
* for the current authentication scheme.
|
71
|
|
*
|
72
|
|
* @param theName the user name to validate
|
73
|
|
*/
|
74
|
|
protected abstract void validateName(String theName);
|
75
|
|
|
76
|
|
/**
|
77
|
|
* Verify that the user password passed as parameter is a valid user
|
78
|
|
* password for the current authentication scheme.
|
79
|
|
*
|
80
|
|
* @param thePassword the user password to validate
|
81
|
|
*/
|
82
|
|
protected abstract void validatePassword(String thePassword);
|
83
|
|
|
84
|
|
/**
|
85
|
|
* Modify the <code>WebRequest</code> passed as parameter so
|
86
|
|
* that it will carry authentication information.
|
87
|
|
*
|
88
|
|
* @param theRequest the request object that will be sent to the Cactus
|
89
|
|
* Redirector over HTTP
|
90
|
|
*/
|
91
|
|
public abstract void configure(WebRequest theRequest);
|
92
|
|
|
93
|
|
/**
|
94
|
|
* @return the user password of the Credential
|
95
|
|
*/
|
96
|
10
|
protected String getPassword() {
|
97
|
10
|
return this.password;
|
98
|
|
}
|
99
|
|
|
100
|
|
}
|