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.security.authentication;
18 import java.util.List;
21 * Interface for user administration. Manages the users and groups.
23 * @author Erik Brakkee
25 public interface UserAdministration {
36 * @throws UserMgtException
37 * In case there is a conflict with an existing user.
39 void createUser(String aUser, String aPassword);
42 * Creates a new group.
49 * @throws UserMgtException
50 * In case there is a conflict with an existing group.
52 void createGroup(String aName);
55 * Checks if a user exists.
56 * @param aUser User to check.
57 * @return True iff user exists.
59 boolean checkUser(String aUser);
63 * Check if a group exists.
64 * @param aGroup Group.
65 * @return True iff group exists.
67 boolean checkGroup(String aGroup);
70 * Checks the password.
73 * User to check password for.
76 * @throws UserMgtException In case user does not exist.
77 * @return True iff password is ok.
79 boolean checkPassword(String aUser, String aPassword);
82 * Changes the password.
91 * @throws UserMgtException Inc ase the user does not exist.
92 * @return True if the password was changed.
94 boolean changePassword(String aUser, String aOldPassword, String aNewPassword);
101 * The password to set.
103 * @throws UserMgtException Inc ase the user does not exist.
105 void setPassword(String aUser, String aPassword);
108 * Checks if the user belongs to the given group.
110 * @param aGroup Group.
111 * @return True iff user is in group
112 * @throws UserMgtException In case the user or group do not exist.
114 boolean isInGroup(String aUser, String aGroup);
118 * @return Number of users.
124 * @return Number of groups.
131 * @return All known users.
133 List<String> getUsers();
136 * Gets the users for a given group.
140 * @return Set of users (always non-null).
142 List<String> getUsers(String aGroup);
149 List<String> getGroups();
152 * Gets all groups for a given user.
157 List<String> getGroups(String aUser);
162 * @param aOldUserName
167 * @throws UserMgtException
168 * In case the user is not known or the new user name is already
169 * in use by another user.
171 void renameUser(String aOldUserName, String aUserName);
179 * New name for the group.
181 * @throws UserMgtException
182 * In case the new group name is already used by another group
183 * of if the existing group is unknown.
185 void renameGroup(String aOldGroup, String aGroupName);
193 * @throws UserMgtException
194 * In case the user does not exist.
196 void removeUser(String aUser);
204 * @throws UserMgtException
205 * In case there are still users that are in the given group.
207 void removeGroup(String aGroup);
210 * Adds a user to a group.
217 * @throws UserMgtException
218 * In case the user or group or not known or if the user is
219 * already part of the group.
221 void addUserToGroup(String aUser, String aGroup);
224 * Removes a user from a group.
231 * @throws UserMgtException
232 * In case the user or group are unknown or if the user is not
235 void removeUserFromGroup(String aUser, String aGroup);