001: /*
002: * Copyright 2002,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina;
018:
019: import java.util.Iterator;
020:
021: /**
022: * <p>Abstract representation of a database of {@link User}s and
023: * {@link Group}s that can be maintained by an application,
024: * along with definitions of corresponding {@link Role}s, and
025: * referenced by a {@link Realm} for authentication and access control.</p>
026: *
027: * @author Craig R. McClanahan
028: * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:39 $
029: * @since 4.1
030: */
031:
032: public interface UserDatabase {
033:
034: // ------------------------------------------------------------- Properties
035:
036: /**
037: * Return the set of {@link Group}s defined in this user database.
038: */
039: public Iterator getGroups();
040:
041: /**
042: * Return the unique global identifier of this user database.
043: */
044: public String getId();
045:
046: /**
047: * Return the set of {@link Role}s defined in this user database.
048: */
049: public Iterator getRoles();
050:
051: /**
052: * Return the set of {@link User}s defined in this user database.
053: */
054: public Iterator getUsers();
055:
056: // --------------------------------------------------------- Public Methods
057:
058: /**
059: * Finalize access to this user database.
060: *
061: * @exception Exception if any exception is thrown during closing
062: */
063: public void close() throws Exception;
064:
065: /**
066: * Create and return a new {@link Group} defined in this user database.
067: *
068: * @param groupname The group name of the new group (must be unique)
069: * @param description The description of this group
070: */
071: public Group createGroup(String groupname, String description);
072:
073: /**
074: * Create and return a new {@link Role} defined in this user database.
075: *
076: * @param rolename The role name of the new role (must be unique)
077: * @param description The description of this role
078: */
079: public Role createRole(String rolename, String description);
080:
081: /**
082: * Create and return a new {@link User} defined in this user database.
083: *
084: * @param username The logon username of the new user (must be unique)
085: * @param password The logon password of the new user
086: * @param fullName The full name of the new user
087: */
088: public User createUser(String username, String password,
089: String fullName);
090:
091: /**
092: * Return the {@link Group} with the specified group name, if any;
093: * otherwise return <code>null</code>.
094: *
095: * @param groupname Name of the group to return
096: */
097: public Group findGroup(String groupname);
098:
099: /**
100: * Return the {@link Role} with the specified role name, if any;
101: * otherwise return <code>null</code>.
102: *
103: * @param rolename Name of the role to return
104: */
105: public Role findRole(String rolename);
106:
107: /**
108: * Return the {@link User} with the specified user name, if any;
109: * otherwise return <code>null</code>.
110: *
111: * @param username Name of the user to return
112: */
113: public User findUser(String username);
114:
115: /**
116: * Initialize access to this user database.
117: *
118: * @exception Exception if any exception is thrown during opening
119: */
120: public void open() throws Exception;
121:
122: /**
123: * Remove the specified {@link Group} from this user database.
124: *
125: * @param group The group to be removed
126: */
127: public void removeGroup(Group group);
128:
129: /**
130: * Remove the specified {@link Role} from this user database.
131: *
132: * @param role The role to be removed
133: */
134: public void removeRole(Role role);
135:
136: /**
137: * Remove the specified {@link User} from this user database.
138: *
139: * @param user The user to be removed
140: */
141: public void removeUser(User user);
142:
143: /**
144: * Save any updated information to the persistent storage location for
145: * this user database.
146: *
147: * @exception Exception if any exception is thrown during saving
148: */
149: public void save() throws Exception;
150:
151: }
|