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 import org.wamblee.security.authentication.UserMgtException.Reason;
24 * Interface for user administration. Manages the users and groups.
26 * @author Erik Brakkee
28 public interface UserAdministration {
39 * @throws UserMgtException
40 * In case there is a conflict with an existing user.
42 void createUser(String aUser, String aPassword);
45 * Creates a new group.
52 * @throws UserMgtException
53 * In case there is a conflict with an existing group.
55 void createGroup(String aName);
58 * Checks if a user exists.
59 * @param aUser User to check.
60 * @return True iff user exists.
62 boolean checkUser(String aUser);
66 * Check if a group exists.
67 * @param aGroup Group.
68 * @return True iff group exists.
70 boolean checkGroup(String aGroup);
73 * Checks the password.
76 * User to check password for.
79 * @throws UserMgtException In case user does not exist.
80 * @return True iff password is ok.
82 boolean checkPassword(String aUser, String aPassword);
85 * Changes the password.
94 * @throws UserMgtException Inc ase the user does not exist.
95 * @return True if the password was changed.
97 boolean changePassword(String aUser, String aOldPassword, String aNewPassword);
104 * The password to set.
106 * @throws UserMgtException Inc ase the user does not exist.
108 void setPassword(String aUser, String aPassword);
111 * Checks if the user belongs to the given group.
113 * @param aGroup Group.
114 * @return True iff user is in group
115 * @throws UserMgtException In case the user or group do not exist.
117 boolean isInGroup(String aUser, String aGroup);
121 * @return Number of users.
127 * @return Number of groups.
134 * @return All known users.
136 List<String> getUsers();
139 * Gets the users for a given group.
143 * @return Set of users (always non-null).
145 List<String> getUsers(String aGroup);
152 List<String> getGroups();
155 * Gets all groups for a given user.
160 List<String> getGroups(String aUser);
165 * @param aOldUserName
170 * @throws UserMgtException
171 * In case the user is not known or the new user name is already
172 * in use by another user.
174 void renameUser(String aOldUserName, String aUserName);
182 * New name for the group.
184 * @throws UserMgtException
185 * In case the new group name is already used by another group
186 * of if the existing group is unknown.
188 void renameGroup(String aOldGroup, String aGroupName);
196 * @throws UserMgtException
197 * In case the user does not exist.
199 void removeUser(String aUser);
207 * @throws UserMgtException
208 * In case there are still users that are in the given group.
210 void removeGroup(String aGroup);
213 * Adds a user to a group.
220 * @throws UserMgtException
221 * In case the user or group or not known or if the user is
222 * already part of the group.
224 void addUserToGroup(String aUser, String aGroup);
227 * Removes a user from a group.
234 * @throws UserMgtException
235 * In case the user or group are unknown or if the user is not
238 void removeUserFromGroup(String aUser, String aGroup);