1
2
3 /*
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5 *
6 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
7 *
8 * Portions Copyright Apache Software Foundation.
9 *
10 * The contents of this file are subject to the terms of either the GNU
11 * General Public License Version 2 only ("GPL") or the Common Development
12 * and Distribution License("CDDL") (collectively, the "License"). You
13 * may not use this file except in compliance with the License. You can obtain
14 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
15 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
16 * language governing permissions and limitations under the License.
17 *
18 * When distributing the software, include this License Header Notice in each
19 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
20 * Sun designates this particular file as subject to the "Classpath" exception
21 * as provided by Sun in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the License
23 * Header, with the fields enclosed by brackets [] replaced by your own
24 * identifying information: "Portions Copyrighted [year]
25 * [name of copyright owner]"
26 *
27 * Contributor(s):
28 *
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40
41
42 package org.apache.catalina;
43
44
45 import java.util.Iterator;
46
47
48 /**
49 * <p>Abstract representation of a database of {@link User}s and
50 * {@link Group}s that can be maintained by an application,
51 * along with definitions of corresponding {@link Role}s, and
52 * referenced by a {@link Realm} for authentication and access control.</p>
53 *
54 * @author Craig R. McClanahan
55 * @version $Revision: 1.3 $ $Date: 2007/05/05 05:31:52 $
56 * @since 4.1
57 */
58
59 public interface UserDatabase {
60
61
62 // ------------------------------------------------------------- Properties
63
64
65 /**
66 * Return the set of {@link Group}s defined in this user database.
67 */
68 public Iterator getGroups();
69
70
71 /**
72 * Return the unique global identifier of this user database.
73 */
74 public String getId();
75
76
77 /**
78 * Return the set of {@link Role}s defined in this user database.
79 */
80 public Iterator getRoles();
81
82
83 /**
84 * Return the set of {@link User}s defined in this user database.
85 */
86 public Iterator getUsers();
87
88
89 // --------------------------------------------------------- Public Methods
90
91
92 /**
93 * Finalize access to this user database.
94 *
95 * @exception Exception if any exception is thrown during closing
96 */
97 public void close() throws Exception;
98
99
100 /**
101 * Create and return a new {@link Group} defined in this user database.
102 *
103 * @param groupname The group name of the new group (must be unique)
104 * @param description The description of this group
105 */
106 public Group createGroup(String groupname, String description);
107
108
109 /**
110 * Create and return a new {@link Role} defined in this user database.
111 *
112 * @param rolename The role name of the new role (must be unique)
113 * @param description The description of this role
114 */
115 public Role createRole(String rolename, String description);
116
117
118 /**
119 * Create and return a new {@link User} defined in this user database.
120 *
121 * @param username The logon username of the new user (must be unique)
122 * @param password The logon password of the new user
123 * @param fullName The full name of the new user
124 */
125 public User createUser(String username, String password,
126 String fullName);
127
128
129 /**
130 * Return the {@link Group} with the specified group name, if any;
131 * otherwise return <code>null</code>.
132 *
133 * @param groupname Name of the group to return
134 */
135 public Group findGroup(String groupname);
136
137
138 /**
139 * Return the {@link Role} with the specified role name, if any;
140 * otherwise return <code>null</code>.
141 *
142 * @param rolename Name of the role to return
143 */
144 public Role findRole(String rolename);
145
146
147 /**
148 * Return the {@link User} with the specified user name, if any;
149 * otherwise return <code>null</code>.
150 *
151 * @param username Name of the user to return
152 */
153 public User findUser(String username);
154
155
156 /**
157 * Initialize access to this user database.
158 *
159 * @exception Exception if any exception is thrown during opening
160 */
161 public void open() throws Exception;
162
163
164 /**
165 * Remove the specified {@link Group} from this user database.
166 *
167 * @param group The group to be removed
168 */
169 public void removeGroup(Group group);
170
171
172 /**
173 * Remove the specified {@link Role} from this user database.
174 *
175 * @param role The role to be removed
176 */
177 public void removeRole(Role role);
178
179
180 /**
181 * Remove the specified {@link User} from this user database.
182 *
183 * @param user The user to be removed
184 */
185 public void removeUser(User user);
186
187
188 /**
189 * Save any updated information to the persistent storage location for
190 * this user database.
191 *
192 * @exception Exception if any exception is thrown during saving
193 */
194 public void save() throws Exception;
195
196
197 }