2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.usermgt;
22 * Interface for user administration. Manages the users and groups.
24 * @author Erik Brakkee
26 public interface UserAdministration {
30 * @param aUser Username.
31 * @param aPassword Password.
32 * @param aGroup Group.
36 * @throws UserMgtException In case there is a conflict with an existing
39 User createUser(String aUser, String aPassword, Group aGroup)
40 throws UserMgtException;
43 * Creates a new group.
45 * @param aName Group name.
49 * @throws UserMgtException In case there is a conflict with an existing
52 Group createGroup(String aName) throws UserMgtException;
57 * @return Number of users.
64 * @return Number of groups.
69 * Must be called when the user is modified.
73 void userModified(User aUser);
76 * Must be called when the group is modified.
78 * @param aGroup Group.
80 void groupModified(Group aGroup);
83 * Gets the user for a given name.
85 * @param aName User name.
87 * @return User or null if not found.
89 User getUser(String aName);
92 * Gets the group for a given group name.
94 * @param aName Group name.
96 * @return Group or null if not found.
98 Group getGroup(String aName);
103 * @return DOCUMENT ME!
108 * @return DOCUMENT ME!
112 * @return All known users.
114 Set<User> getUsers();
119 * @param aGroup DOCUMENT ME!
121 * @return DOCUMENT ME!
126 * @param aGroup DOCUMENT ME!
128 * @return DOCUMENT ME!
131 * Gets the users for a given group.
132 * @param aGroup Group.
133 * @return Set of users (always non-null).
135 Set<User> getUsers(Group aGroup);
140 * @return DOCUMENT ME!
145 * @return DOCUMENT ME!
148 * Gets all known groups.
151 Set<Group> getGroups();
156 * @param aUser User object for which user name must be changed.
157 * @param aUserName New user name.
159 * @throws UserMgtException In case the user is not known or the new user
160 * name is already in use by another user.
162 void renameUser(User aUser, String aUserName) throws UserMgtException;
167 * @param aGroup Group to rename.
168 * @param aGroupName New name for the group.
170 * @throws UserMgtException In case the new group name is already used by
171 * another group of if the existing group is unknown.
173 void renameGroup(Group aGroup, String aGroupName) throws UserMgtException;
178 * @param aUser User to remove.
180 * @throws UserMgtException In case the user does not exist.
182 void removeUser(User aUser) throws UserMgtException;
187 * @param aGroup Group to remove.
189 * @throws UserMgtException In case there are still users that are in the
192 void removeGroup(Group aGroup) throws UserMgtException;
195 * Adds a user to a group.
198 * @param aGroup Group.
200 * @throws UserMgtException In case the user or group or not known or if
201 * the user is already part of the group.
203 void addUserToGroup(User aUser, Group aGroup) throws UserMgtException;
206 * Removes a user from a group.
209 * @param aGroup Group
211 * @throws UserMgtException In case the user or group are unknown or if the
212 * user is not part of the group.
214 void removeUserFromGroup(User aUser, Group aGroup)
215 throws UserMgtException;