KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > services > UsersRepository


1 /***********************************************************************
2  * Copyright (c) 2000-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17
18 package org.apache.james.services;
19
20 import java.util.Iterator JavaDoc;
21
22 /**
23  * Interface for a repository of users. A repository represents a logical
24  * grouping of users, typically by common purpose. E.g. the users served by an
25  * email server or the members of a mailing list.
26  *
27  *
28  * @version $Revision: 1.6.4.3 $
29  */

30 public interface UsersRepository {
31
32     /**
33      * The component role used by components implementing this service
34      */

35     String JavaDoc ROLE = "org.apache.james.services.UsersRepository";
36
37     String JavaDoc USER = "USER";
38
39     /**
40      * Adds a user to the repository with the specified User object.
41      *
42      * @param user the user to be added
43      *
44      * @return true if succesful, false otherwise
45      * @since James 1.2.2
46      */

47     boolean addUser(User user);
48
49     /**
50      * Adds a user to the repository with the specified attributes. In current
51      * implementations, the Object attributes is generally a String password.
52      *
53      * @param name the name of the user to be added
54      * @param attributes see decription
55      */

56     void addUser(String JavaDoc name, Object JavaDoc attributes);
57
58     /**
59      * Gets the attribute for a user. Not clear on behavior.
60      *
61      * @deprecated As of James 1.2.2 . Use the {@link #getUserByName(String) getUserByName} method.
62      */

63     Object JavaDoc getAttributes(String JavaDoc name);
64
65
66     /**
67      * Get the user object with the specified user name. Return null if no
68      * such user.
69      *
70      * @param name the name of the user to retrieve
71      * @return the user being retrieved, null if the user doesn't exist
72      *
73      * @since James 1.2.2
74      */

75     User getUserByName(String JavaDoc name);
76
77     /**
78      * Get the user object with the specified user name. Match user naems on
79      * a case insensitive basis. Return null if no such user.
80      *
81      * @param name the name of the user to retrieve
82      * @return the user being retrieved, null if the user doesn't exist
83      *
84      * @since James 1.2.2
85      */

86     User getUserByNameCaseInsensitive(String JavaDoc name);
87
88     /**
89      * Returns the user name of the user matching name on an equalsIgnoreCase
90      * basis. Returns null if no match.
91      *
92      * @param name the name to case-correct
93      * @return the case-correct name of the user, null if the user doesn't exist
94      */

95     String JavaDoc getRealName(String JavaDoc name);
96
97     /**
98      * Update the repository with the specified user object. A user object
99      * with this username must already exist.
100      *
101      * @return true if successful.
102      */

103     boolean updateUser(User user);
104
105     /**
106      * Removes a user from the repository
107      *
108      * @param name the user to remove from the repository
109      */

110     void removeUser(String JavaDoc name);
111
112     /**
113      * Returns whether or not this user is in the repository
114      *
115      * @param name the name to check in the repository
116      * @return whether the user is in the repository
117      */

118     boolean contains(String JavaDoc name);
119
120     /**
121      * Returns whether or not this user is in the repository. Names are
122      * matched on a case insensitive basis.
123      *
124      * @param name the name to check in the repository
125      * @return whether the user is in the repository
126      */

127     boolean containsCaseInsensitive(String JavaDoc name);
128
129
130     /**
131      * Tests a user with the appropriate attributes. In current implementations,
132      * this typically means "check the password" where a String password is passed
133      * as the Object attributes.
134      *
135      * @deprecated As of James 1.2.2, use {@link #test(String, String) test(String name, String password)}
136      */

137     boolean test(String JavaDoc name, Object JavaDoc attributes);
138
139     /**
140      * Test if user with name 'name' has password 'password'.
141      *
142      * @param name the name of the user to be tested
143      * @param password the password to be tested
144      *
145      * @return true if the test is successful, false if the user
146      * doesn't exist or if the password is incorrect
147      *
148      * @since James 1.2.2
149      */

150     boolean test(String JavaDoc name, String JavaDoc password);
151
152     /**
153      * Returns a count of the users in the repository.
154      *
155      * @return the number of users in the repository
156      */

157     int countUsers();
158
159     /**
160      * List users in repository.
161      *
162      * @return Iterator over a collection of Strings, each being one user in the repository.
163      */

164     Iterator JavaDoc list();
165
166 }
167
Popular Tags