Removed DOCUMENT ME comments that were generated and applied source code
[utils] / security / src / main / java / org / wamblee / usermgt / UserAdministration.java
1 /*
2  * Copyright 2005 the original author or authors.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.wamblee.usermgt;
17
18 import java.util.Set;
19
20 /**
21  * Interface for user administration. Manages the users and groups.
22  * 
23  * @author Erik Brakkee
24  */
25 public interface UserAdministration {
26     /**
27      * Creates a new user.
28      * 
29      * @param aUser
30      *            Username.
31      * @param aPassword
32      *            Password.
33      * @param aGroup
34      *            Group.
35      * 
36      * @return User.
37      * 
38      * @throws UserMgtException
39      *             In case there is a conflict with an existing user.
40      */
41     User createUser(String aUser, String aPassword, Group aGroup)
42         throws UserMgtException;
43
44     /**
45      * Creates a new group.
46      * 
47      * @param aName
48      *            Group name.
49      * 
50      * @return Group
51      * 
52      * @throws UserMgtException
53      *             In case there is a conflict with an existing group.
54      */
55     Group createGroup(String aName) throws UserMgtException;
56
57     /**
58      * 
59      * @return Number of users.
60      */
61     int getUserCount();
62
63     /**
64      * 
65      * @return Number of groups.
66      */
67     int getGroupCount();
68
69     /**
70      * Must be called when the user is modified.
71      * 
72      * @param aUser
73      *            User.
74      */
75     void userModified(User aUser);
76
77     /**
78      * Must be called when the group is modified.
79      * 
80      * @param aGroup
81      *            Group.
82      */
83     void groupModified(Group aGroup);
84
85     /**
86      * Gets the user for a given name.
87      * 
88      * @param aName
89      *            User name.
90      * 
91      * @return User or null if not found.
92      */
93     User getUser(String aName);
94
95     /**
96      * Gets the group for a given group name.
97      * 
98      * @param aName
99      *            Group name.
100      * 
101      * @return Group or null if not found.
102      */
103     Group getGroup(String aName);
104
105     /**
106      * Get the users.
107      * 
108      * @return All known users.
109      */
110     Set<User> getUsers();
111
112     /**
113      * Gets the users for a given group.
114      * 
115      * @param aGroup
116      *            Group.
117      * @return Set of users (always non-null).
118      */
119     Set<User> getUsers(Group aGroup);
120
121     /**
122      * Gets all known groups.
123      * 
124      * @return Groups.
125      */
126     Set<Group> getGroups();
127
128     /**
129      * Renames a user.
130      * 
131      * @param aUser
132      *            User object for which user name must be changed.
133      * @param aUserName
134      *            New user name.
135      * 
136      * @throws UserMgtException
137      *             In case the user is not known or the new user name is already
138      *             in use by another user.
139      */
140     void renameUser(User aUser, String aUserName) throws UserMgtException;
141
142     /**
143      * Renames a group.
144      * 
145      * @param aGroup
146      *            Group to rename.
147      * @param aGroupName
148      *            New name for the group.
149      * 
150      * @throws UserMgtException
151      *             In case the new group name is already used by another group
152      *             of if the existing group is unknown.
153      */
154     void renameGroup(Group aGroup, String aGroupName) throws UserMgtException;
155
156     /**
157      * Removes the user.
158      * 
159      * @param aUser
160      *            User to remove.
161      * 
162      * @throws UserMgtException
163      *             In case the user does not exist.
164      */
165     void removeUser(User aUser) throws UserMgtException;
166
167     /**
168      * Removes the group.
169      * 
170      * @param aGroup
171      *            Group to remove.
172      * 
173      * @throws UserMgtException
174      *             In case there are still users that are in the given group.
175      */
176     void removeGroup(Group aGroup) throws UserMgtException;
177
178     /**
179      * Adds a user to a group.
180      * 
181      * @param aUser
182      *            User.
183      * @param aGroup
184      *            Group.
185      * 
186      * @throws UserMgtException
187      *             In case the user or group or not known or if the user is
188      *             already part of the group.
189      */
190     void addUserToGroup(User aUser, Group aGroup) throws UserMgtException;
191
192     /**
193      * Removes a user from a group.
194      * 
195      * @param aUser
196      *            User
197      * @param aGroup
198      *            Group
199      * 
200      * @throws UserMgtException
201      *             In case the user or group are unknown or if the user is not
202      *             part of the group.
203      */
204     void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException;
205 }