6c04196c8b8d24a60a0cc764a4c008c533275c53
[utils] / security / src / main / java / org / wamblee / usermgt / UserSet.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 /**
22  * Represents a set of users.
23  * Typical implementations would be an implementation based on a static configuration file or 
24  * an implementation backed by a database.  
25  *
26  * @author Erik Brakkee
27  */
28 public interface UserSet {
29     /**
30      * Creates a user.
31      *
32      * @param aUsername User name.
33      * @param aPassword Password.
34      * @param aGroup Group.
35      *
36      * @return New user.
37      *
38      * @throws UserMgtException In case the user cannot be created.
39      */
40     User createUser(String aUsername, String aPassword, Group aGroup)
41         throws UserMgtException;
42
43     /**
44      * Must be called whenever a user object has been modified to
45      * notify the user set.
46      *
47      * @param aUser Modified user.
48      */
49     void userModified(User aUser);
50
51     /**
52      * Finds  user.
53      *
54      * @param aName Username.
55      *
56      * @return User or null if not found.
57      */
58     User find(String aName);
59
60     /**
61      * Checks if a user exists.
62      *
63      * @param aUser User.
64      *
65      * @return True iff the user exists.
66      */
67     boolean contains(User aUser);
68
69     /**
70      * Adds a user. If the user already exists, the user details are
71      * updated with that of the specified user object.
72      *
73      * @param aUser User to add.
74      *
75      * @return DOCUMENT ME!
76      */
77     boolean add(User aUser);
78
79     /**
80      * Removes a user. If the user does not exist, nothing happens.
81      *
82      * @param aUser
83      *
84      * @return DOCUMENT ME!
85      */
86     boolean remove(User aUser);
87
88     /**
89      * DOCUMENT ME!
90      *
91      * @return DOCUMENT ME!
92      */
93 /**
94      * DOCUMENT ME!
95      *
96      * @return DOCUMENT ME!
97      */
98 /**
99      * Lists the current users. 
100      * @return Users. 
101      */
102     Set<User> list();
103
104     /**
105      * DOCUMENT ME!
106      *
107      * @param aGroup DOCUMENT ME!
108      *
109      * @return DOCUMENT ME!
110      */
111 /**
112      * DOCUMENT ME!
113      *
114      * @param aGroup DOCUMENT ME!
115      *
116      * @return DOCUMENT ME!
117      */
118 /**
119      * Lists the users belonging to a particular group. 
120      * @param aGroup Group. 
121      * @return Groups. 
122      */
123     Set<User> list(Group aGroup);
124
125     /**
126      * DOCUMENT ME!
127      *
128      * @return The number of users.
129      */
130     int size();
131 }