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.
74 * @return The modified user. The user passed in to this call should be considered invalid.
76 void userModified(User aUser);
79 * Must be called when the group is modified.
84 void groupModified(Group aGroup);
87 * Gets the user for a given name.
92 * @return User or null if not found.
94 User getUser(String aName);
97 * Gets the group for a given group name.
102 * @return Group or null if not found.
104 Group getGroup(String aName);
109 * @return All known users.
111 Set<User> getUsers();
114 * Gets the users for a given group.
118 * @return Set of users (always non-null).
120 Set<User> getUsers(Group aGroup);
123 * Gets all known groups.
127 Set<Group> getGroups();
133 * User object for which user name must be changed.
137 * @throws UserMgtException
138 * In case the user is not known or the new user name is already
139 * in use by another user.
141 void renameUser(User aUser, String aUserName) throws UserMgtException;
149 * New name for the group.
151 * @throws UserMgtException
152 * In case the new group name is already used by another group
153 * of if the existing group is unknown.
155 void renameGroup(Group aGroup, String aGroupName) throws UserMgtException;
163 * @throws UserMgtException
164 * In case the user does not exist.
166 void removeUser(User aUser) throws UserMgtException;
174 * @throws UserMgtException
175 * In case there are still users that are in the given group.
177 void removeGroup(Group aGroup) throws UserMgtException;
180 * Adds a user to a group.
187 * @throws UserMgtException
188 * In case the user or group or not known or if the user is
189 * already part of the group.
191 void addUserToGroup(User aUser, Group aGroup) throws UserMgtException;
194 * Removes a user from a group.
201 * @throws UserMgtException
202 * In case the user or group are unknown or if the user is not
205 void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException;