001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.services;
019:
020: import java.util.Iterator;
021:
022: /**
023: * Interface for a repository of users. A repository represents a logical
024: * grouping of users, typically by common purpose. E.g. the users served by an
025: * email server or the members of a mailing list.
026: *
027: *
028: * @version $Revision: 494012 $
029: */
030: public interface UsersRepository {
031:
032: /**
033: * The component role used by components implementing this service
034: */
035: String ROLE = "org.apache.james.services.UsersRepository";
036:
037: String USER = "USER";
038:
039: /**
040: * Adds a user to the repository with the specified User object.
041: *
042: * @param user the user to be added
043: *
044: * @return true if succesful, false otherwise
045: * @since James 1.2.2
046: */
047: boolean addUser(User user);
048:
049: /**
050: * Adds a user to the repository with the specified attributes. In current
051: * implementations, the Object attributes is generally a String password.
052: *
053: * @param name the name of the user to be added
054: * @param attributes see decription
055: */
056: void addUser(String name, Object attributes);
057:
058: /**
059: * Adds a user to the repository with the specified password
060: *
061: * @param username the username of the user to be added
062: * @param password the password of the user to add
063: * @return true if succesful, false otherwise
064: *
065: * @since James 2.3.0
066: */
067: boolean addUser(String username, String password);
068:
069: /**
070: * Get the user object with the specified user name. Return null if no
071: * such user.
072: *
073: * @param name the name of the user to retrieve
074: * @return the user being retrieved, null if the user doesn't exist
075: *
076: * @since James 1.2.2
077: */
078: User getUserByName(String name);
079:
080: /**
081: * Get the user object with the specified user name. Match user naems on
082: * a case insensitive basis. Return null if no such user.
083: *
084: * @param name the name of the user to retrieve
085: * @return the user being retrieved, null if the user doesn't exist
086: *
087: * @since James 1.2.2
088: */
089: User getUserByNameCaseInsensitive(String name);
090:
091: /**
092: * Returns the user name of the user matching name on an equalsIgnoreCase
093: * basis. Returns null if no match.
094: *
095: * @param name the name to case-correct
096: * @return the case-correct name of the user, null if the user doesn't exist
097: */
098: String getRealName(String name);
099:
100: /**
101: * Update the repository with the specified user object. A user object
102: * with this username must already exist.
103: *
104: * @return true if successful.
105: */
106: boolean updateUser(User user);
107:
108: /**
109: * Removes a user from the repository
110: *
111: * @param name the user to remove from the repository
112: */
113: void removeUser(String name);
114:
115: /**
116: * Returns whether or not this user is in the repository
117: *
118: * @param name the name to check in the repository
119: * @return whether the user is in the repository
120: */
121: boolean contains(String name);
122:
123: /**
124: * Returns whether or not this user is in the repository. Names are
125: * matched on a case insensitive basis.
126: *
127: * @param name the name to check in the repository
128: * @return whether the user is in the repository
129: */
130: boolean containsCaseInsensitive(String name);
131:
132: /**
133: * Test if user with name 'name' has password 'password'.
134: *
135: * @param name the name of the user to be tested
136: * @param password the password to be tested
137: *
138: * @return true if the test is successful, false if the user
139: * doesn't exist or if the password is incorrect
140: *
141: * @since James 1.2.2
142: */
143: boolean test(String name, String password);
144:
145: /**
146: * Returns a count of the users in the repository.
147: *
148: * @return the number of users in the repository
149: */
150: int countUsers();
151:
152: /**
153: * List users in repository.
154: *
155: * @return Iterator over a collection of Strings, each being one user in the repository.
156: */
157: Iterator list();
158:
159: }
|