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.
17 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.
34 * @throws UserMgtException In case there is a conflict with an existing user.
36 User createUser(String aUser, String aPassword, Group aGroup) throws UserMgtException;
39 * Creates a new group.
40 * @param aName Group name.
42 * @throws UserMgtException In case there is a conflict with an existing group.
44 Group createGroup(String aName) throws UserMgtException;
47 * @return Number of users.
52 * @return Number of groups.
57 * Must be called when the user is modified.
60 void userModified(User aUser);
63 * Must be called when the group is modified.
64 * @param aGroup Group.
66 void groupModified(Group aGroup);
69 * Gets the user for a given name.
70 * @param aName User name.
71 * @return User or null if not found.
73 User getUser(String aName);
76 * Gets the group for a given group name.
77 * @param aName Group name.
78 * @return Group or null if not found.
80 Group getGroup(String aName);
84 * @return All known users.
89 * Gets the users for a given group.
90 * @param aGroup Group.
91 * @return Set of users (always non-null).
93 Set<User> getUsers(Group aGroup);
96 * Gets all known groups.
99 Set<Group> getGroups();
103 * @param aUser User object for which user name must be changed.
104 * @param aUserName New user name.
105 * @throws UserMgtException In case the user is not known or the new user
106 * name is already in use by another user.
108 void renameUser(User aUser, String aUserName) throws UserMgtException;
112 * @param aGroup Group to rename.
113 * @param aGroupName New name for the group.
114 * @throws UserMgtException In case the new group name is already used by
115 * another group of if the existing group is unknown.
117 void renameGroup(Group aGroup, String aGroupName) throws UserMgtException;
121 * @param aUser User to remove.
122 * @throws UserMgtException In case the user does not exist.
124 void removeUser(User aUser) throws UserMgtException;
128 * @param aGroup Group to remove.
129 * @throws UserMgtException In case there are still users that are in the given group.
131 void removeGroup(Group aGroup) throws UserMgtException;
134 * Adds a user to a group.
136 * @param aGroup Group.
137 * @throws UserMgtException In case the user or group or not known or if the user
138 * is already part of the group.
140 void addUserToGroup(User aUser, Group aGroup) throws UserMgtException;
143 * Removes a user from a group.
145 * @param aGroup Group
146 * @throws UserMgtException In case the user or group are unknown or if the user
147 * is not part of the group.
149 void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException;