2 * Copyright 2005-2010 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;
21 * Interface for user administration. Manages the users and groups.
23 * @author Erik Brakkee
25 public interface UserAdministration {
38 * @throws UserMgtException
39 * In case there is a conflict with an existing user.
41 User createUser(String aUser, String aPassword, Group aGroup)
42 throws UserMgtException;
45 * Creates a new group.
52 * @throws UserMgtException
53 * In case there is a conflict with an existing group.
55 Group createGroup(String aName) throws UserMgtException;
59 * @return Number of users.
65 * @return Number of groups.
70 * Must be called when the user is modified.
75 void userModified(User aUser);
78 * Must be called when the group is modified.
83 void groupModified(Group aGroup);
86 * Gets the user for a given name.
91 * @return User or null if not found.
93 User getUser(String aName);
96 * Gets the group for a given group name.
101 * @return Group or null if not found.
103 Group getGroup(String aName);
108 * @return All known users.
110 Set<User> getUsers();
113 * Gets the users for a given group.
117 * @return Set of users (always non-null).
119 Set<User> getUsers(Group aGroup);
122 * Gets all known groups.
126 Set<Group> getGroups();
132 * User object for which user name must be changed.
136 * @throws UserMgtException
137 * In case the user is not known or the new user name is already
138 * in use by another user.
140 void renameUser(User aUser, String aUserName) throws UserMgtException;
148 * New name for the group.
150 * @throws UserMgtException
151 * In case the new group name is already used by another group
152 * of if the existing group is unknown.
154 void renameGroup(Group aGroup, String aGroupName) throws UserMgtException;
162 * @throws UserMgtException
163 * In case the user does not exist.
165 void removeUser(User aUser) throws UserMgtException;
173 * @throws UserMgtException
174 * In case there are still users that are in the given group.
176 void removeGroup(Group aGroup) throws UserMgtException;
179 * Adds a user to a group.
186 * @throws UserMgtException
187 * In case the user or group or not known or if the user is
188 * already part of the group.
190 void addUserToGroup(User aUser, Group aGroup) throws UserMgtException;
193 * Removes a user from a group.
200 * @throws UserMgtException
201 * In case the user or group are unknown or if the user is not
204 void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException;