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;
20
21
22 import java.util.Iterator;
23
24
25 /**
26 * <p>Abstract representation of a database of {@link User}s and
27 * {@link Group}s that can be maintained by an application,
28 * along with definitions of corresponding {@link Role}s, and
29 * referenced by a {@link Realm} for authentication and access control.</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 interface UserDatabase {
37
38
39 // ------------------------------------------------------------- Properties
40
41
42 /**
43 * Return the set of {@link Group}s defined in this user database.
44 */
45 public Iterator getGroups();
46
47
48 /**
49 * Return the unique global identifier of this user database.
50 */
51 public String getId();
52
53
54 /**
55 * Return the set of {@link Role}s defined in this user database.
56 */
57 public Iterator getRoles();
58
59
60 /**
61 * Return the set of {@link User}s defined in this user database.
62 */
63 public Iterator getUsers();
64
65
66 // --------------------------------------------------------- Public Methods
67
68
69 /**
70 * Finalize access to this user database.
71 *
72 * @exception Exception if any exception is thrown during closing
73 */
74 public void close() throws Exception;
75
76
77 /**
78 * Create and return a new {@link Group} defined in this user database.
79 *
80 * @param groupname The group name of the new group (must be unique)
81 * @param description The description of this group
82 */
83 public Group createGroup(String groupname, String description);
84
85
86 /**
87 * Create and return a new {@link Role} defined in this user database.
88 *
89 * @param rolename The role name of the new role (must be unique)
90 * @param description The description of this role
91 */
92 public Role createRole(String rolename, String description);
93
94
95 /**
96 * Create and return a new {@link User} defined in this user database.
97 *
98 * @param username The logon username of the new user (must be unique)
99 * @param password The logon password of the new user
100 * @param fullName The full name of the new user
101 */
102 public User createUser(String username, String password,
103 String fullName);
104
105
106 /**
107 * Return the {@link Group} with the specified group name, if any;
108 * otherwise return <code>null</code>.
109 *
110 * @param groupname Name of the group to return
111 */
112 public Group findGroup(String groupname);
113
114
115 /**
116 * Return the {@link Role} with the specified role name, if any;
117 * otherwise return <code>null</code>.
118 *
119 * @param rolename Name of the role to return
120 */
121 public Role findRole(String rolename);
122
123
124 /**
125 * Return the {@link User} with the specified user name, if any;
126 * otherwise return <code>null</code>.
127 *
128 * @param username Name of the user to return
129 */
130 public User findUser(String username);
131
132
133 /**
134 * Initialize access to this user database.
135 *
136 * @exception Exception if any exception is thrown during opening
137 */
138 public void open() throws Exception;
139
140
141 /**
142 * Remove the specified {@link Group} from this user database.
143 *
144 * @param group The group to be removed
145 */
146 public void removeGroup(Group group);
147
148
149 /**
150 * Remove the specified {@link Role} from this user database.
151 *
152 * @param role The role to be removed
153 */
154 public void removeRole(Role role);
155
156
157 /**
158 * Remove the specified {@link User} from this user database.
159 *
160 * @param user The user to be removed
161 */
162 public void removeUser(User user);
163
164
165 /**
166 * Save any updated information to the persistent storage location for
167 * this user database.
168 *
169 * @exception Exception if any exception is thrown during saving
170 */
171 public void save() throws Exception;
172
173
174 }