KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > users > AbstractUser


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.users;
20
21
22 import java.util.Iterator JavaDoc;
23 import org.apache.catalina.Group;
24 import org.apache.catalina.Role;
25 import org.apache.catalina.User;
26
27
28 /**
29  * <p>Convenience base class for {@link User} implementations.</p>
30  *
31  * @author Craig R. McClanahan
32  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
33  * @since 4.1
34  */

35
36 public abstract class AbstractUser implements User {
37
38
39     // ----------------------------------------------------- Instance Variables
40

41
42     /**
43      * The full name of this user.
44      */

45     protected String JavaDoc fullName = null;
46
47
48     /**
49      * The logon password of this user.
50      */

51     protected String JavaDoc password = null;
52
53
54     /**
55      * The logon username of this user.
56      */

57     protected String JavaDoc username = null;
58
59
60     // ------------------------------------------------------------- Properties
61

62
63     /**
64      * Return the full name of this user.
65      */

66     public String JavaDoc getFullName() {
67
68         return (this.fullName);
69
70     }
71
72
73     /**
74      * Set the full name of this user.
75      *
76      * @param fullName The new full name
77      */

78     public void setFullName(String JavaDoc fullName) {
79
80         this.fullName = fullName;
81
82     }
83
84
85     /**
86      * Return the set of {@link Group}s to which this user belongs.
87      */

88     public abstract Iterator JavaDoc getGroups();
89
90
91     /**
92      * Return the logon password of this user, optionally prefixed with the
93      * identifier of an encoding scheme surrounded by curly braces, such as
94      * <code>{md5}xxxxx</code>.
95      */

96     public String JavaDoc getPassword() {
97
98         return (this.password);
99
100     }
101
102
103     /**
104      * Set the logon password of this user, optionally prefixed with the
105      * identifier of an encoding scheme surrounded by curly braces, such as
106      * <code>{md5}xxxxx</code>.
107      *
108      * @param password The new logon password
109      */

110     public void setPassword(String JavaDoc password) {
111
112         this.password = password;
113
114     }
115
116
117     /**
118      * Return the set of {@link Role}s assigned specifically to this user.
119      */

120     public abstract Iterator JavaDoc getRoles();
121
122
123     /**
124      * Return the logon username of this user, which must be unique
125      * within the scope of a {@link org.apache.catalina.UserDatabase}.
126      */

127     public String JavaDoc getUsername() {
128
129         return (this.username);
130
131     }
132
133
134     /**
135      * Set the logon username of this user, which must be unique within
136      * the scope of a {@link org.apache.catalina.UserDatabase}.
137      *
138      * @param username The new logon username
139      */

140     public void setUsername(String JavaDoc username) {
141
142         this.username = username;
143
144     }
145
146
147     // --------------------------------------------------------- Public Methods
148

149
150     /**
151      * Add a new {@link Group} to those this user belongs to.
152      *
153      * @param group The new group
154      */

155     public abstract void addGroup(Group group);
156
157
158     /**
159      * Add a new {@link Role} to those assigned specifically to this user.
160      *
161      * @param role The new role
162      */

163     public abstract void addRole(Role role);
164
165
166     /**
167      * Is this user in the specified {@link Group}?
168      *
169      * @param group The group to check
170      */

171     public abstract boolean isInGroup(Group group);
172
173
174     /**
175      * Is this user specifically assigned the specified {@link Role}? This
176      * method does <strong>NOT</strong> check for roles inherited based on
177      * {@link Group} membership.
178      *
179      * @param role The role to check
180      */

181     public abstract boolean isInRole(Role role);
182
183
184     /**
185      * Remove a {@link Group} from those this user belongs to.
186      *
187      * @param group The old group
188      */

189     public abstract void removeGroup(Group group);
190
191
192     /**
193      * Remove all {@link Group}s from those this user belongs to.
194      */

195     public abstract void removeGroups();
196
197
198     /**
199      * Remove a {@link Role} from those assigned to this user.
200      *
201      * @param role The old role
202      */

203     public abstract void removeRole(Role role);
204
205
206     /**
207      * Remove all {@link Role}s from those assigned to this user.
208      */

209     public abstract void removeRoles();
210
211
212     // ------------------------------------------------------ Principal Methods
213

214
215     /**
216      * Make the principal name the same as the group name.
217      */

218     public String JavaDoc getName() {
219
220         return (getUsername());
221
222     }
223
224
225 }
226
Popular Tags