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.
59 * @return True iff user exists.
61 boolean checkUser(String aUser);
64 * Check if a group exists.
68 * @return True iff group exists.
70 boolean checkGroup(String aGroup);
73 * Checks the password.
76 * User to check password for.
79 * @throws UserMgtException
80 * In case user does not exist.
81 * @return True iff password is ok.
83 boolean checkPassword(String aUser, String aPassword);
86 * Changes the password.
95 * @throws UserMgtException
96 * Inc ase the user does not exist.
97 * @return True if the password was changed.
99 boolean changePassword(String aUser, String aOldPassword,
100 String aNewPassword);
107 * The password to set.
109 * @throws UserMgtException
110 * Inc ase the user does not exist.
112 void setPassword(String aUser, String aPassword);
115 * Checks if the user belongs to the given group.
121 * @return True iff user is in group
122 * @throws UserMgtException
123 * In case the user or group do not exist.
125 boolean isInGroup(String aUser, String aGroup);
129 * @return Number of users.
135 * @return Number of groups.
142 * @return All known users.
144 List<String> getUsers();
147 * Gets the users for a given group.
151 * @return Set of users (always non-null).
153 List<String> getUsers(String aGroup);
160 List<String> getGroups();
163 * Gets all groups for a given user.
169 List<String> getGroups(String aUser);
174 * @param aOldUserName
179 * @throws UserMgtException
180 * In case the user is not known or the new user name is already
181 * in use by another user.
183 void renameUser(String aOldUserName, String aUserName);
191 * New name for the group.
193 * @throws UserMgtException
194 * In case the new group name is already used by another group
195 * of if the existing group is unknown.
197 void renameGroup(String aOldGroup, String aGroupName);
205 * @throws UserMgtException
206 * In case the user does not exist.
208 void removeUser(String aUser);
216 * @throws UserMgtException
217 * In case there are still users that are in the given group.
219 void removeGroup(String aGroup);
222 * Adds a user to a group.
229 * @throws UserMgtException
230 * In case the user or group or not known or if the user is
231 * already part of the group.
233 void addUserToGroup(String aUser, String aGroup);
236 * Removes a user from a group.
243 * @throws UserMgtException
244 * In case the user or group are unknown or if the user is not
247 void removeUserFromGroup(String aUser, String aGroup);