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 public interface UserAdministration {
28 * @param aUser Username.
29 * @param aPassword Password.
30 * @param aGroup Group.
32 * @throws UserMgtException In case there is a conflict with an existing user.
34 User createUser(String aUser, String aPassword, Group aGroup) throws UserMgtException;
37 * Creates a new group.
38 * @param aName Group name.
40 * @throws UserMgtException In case there is a conflict with an existing group.
42 Group createGroup(String aName) throws UserMgtException;
45 * @return Number of users.
50 * @return Number of groups.
55 * Must be called when the user is modified.
58 void userModified(User aUser);
61 * Must be called when the group is modified.
62 * @param aGroup Group.
64 void groupModified(Group aGroup);
67 * Gets the user for a given name.
68 * @param aName User name.
69 * @return User or null if not found.
71 User getUser(String aName);
74 * Gets the group for a given group name.
75 * @param aName Group name.
76 * @return Group or null if not found.
78 Group getGroup(String aName);
82 * @return All known users.
87 * Gets the users for a given group.
88 * @param aGroup Group.
89 * @return Set of users (always non-null).
91 Set<User> getUsers(Group aGroup);
94 * Gets all known groups.
97 Set<Group> getGroups();
101 * @param aUser User object for which user name must be changed.
102 * @param aUserName New user name.
103 * @throws UserMgtException In case the user is not known or the new user
104 * name is already in use by another user.
106 void renameUser(User aUser, String aUserName) throws UserMgtException;
110 * @param aGroup Group to rename.
111 * @param aGroupName New name for the group.
112 * @throws UserMgtException In case the new group name is already used by
113 * another group of if the existing group is unknown.
115 void renameGroup(Group aGroup, String aGroupName) throws UserMgtException;
119 * @param aUser User to remove.
120 * @throws UserMgtException In case the user does not exist.
122 void removeUser(User aUser) throws UserMgtException;
126 * @param aGroup Group to remove.
127 * @throws UserMgtException In case there are still users that are in the given group.
129 void removeGroup(Group aGroup) throws UserMgtException;
132 * Adds a user to a group.
134 * @param aGroup Group.
135 * @throws UserMgtException In case the user or group or not known or if the user
136 * is already part of the group.
138 void addUserToGroup(User aUser, Group aGroup) throws UserMgtException;
141 * Removes a user from a group.
143 * @param aGroup Group
144 * @throws UserMgtException In case the user or group are unknown or if the user
145 * is not part of the group.
147 void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException;