Methods Summary |
---|
public boolean | addUser(org.apache.james.services.User user)Adds a user to the repository with the specified User object.
Users names must be unique-case-insensitive in the repository.
String username = user.getUserName();
if ( containsCaseInsensitive(username) ) {
return false;
}
doAddUser(user);
return true;
|
public void | addUser(java.lang.String name, java.lang.Object attributes)Adds a user to the repository with the specified attributes. In current
implementations, the Object attributes is generally a String password.
if (attributes instanceof String) {
User newbie = new DefaultUser(name, "SHA");
newbie.setPassword( (String) attributes );
addUser(newbie);
} else {
throw new RuntimeException("Improper use of deprecated method"
+ " - use addUser(User user)");
}
|
public boolean | addUser(java.lang.String username, java.lang.String password)
User newbie = new DefaultJamesUser(username, "SHA");
newbie.setPassword(password);
return addUser(newbie);
|
public boolean | contains(java.lang.String name)Returns whether or not this user is in the repository
User user = getUserByName(name, false);
return ( user != null );
|
public boolean | containsCaseInsensitive(java.lang.String name)Returns whether or not this user is in the repository. Names are
matched on a case insensitive basis.
User user = getUserByName( name, true );
return ( user != null );
|
public int | countUsers()Returns a count of the users in the repository.
List usernames = listUserNames();
return usernames.size();
|
protected abstract void | doAddUser(org.apache.james.services.User user)Adds a user to the underlying Repository.
The user name must not clash with an existing user.
|
protected abstract void | doRemoveUser(org.apache.james.services.User user)Removes a user from the underlying repository.
If the user doesn't exist, returns ok.
|
protected abstract void | doUpdateUser(org.apache.james.services.User user)Updates a user record to match the supplied User.
|
public java.lang.String | getRealName(java.lang.String name)Returns the user name of the user matching name on an equalsIgnoreCase
basis. Returns null if no match.
// Get the user by name, ignoring case, and return the correct name.
User user = getUserByName(name, true);
if ( user == null ) {
return null;
} else {
return user.getUserName();
}
|
public org.apache.james.services.User | getUserByName(java.lang.String name)Get the user object with the specified user name. Return null if no
such user.
return getUserByName(name, false);
|
protected org.apache.james.services.User | getUserByName(java.lang.String name, boolean ignoreCase)Gets a user by name, ignoring case if specified.
This implementation gets the entire set of users,
and scrolls through searching for one matching name .
// Just iterate through all of the users until we find one matching.
Iterator users = listAllUsers();
while ( users.hasNext() ) {
User user = (User)users.next();
String username = user.getUserName();
if (( !ignoreCase && username.equals(name) ) ||
( ignoreCase && username.equalsIgnoreCase(name) )) {
return user;
}
}
// Not found - return null
return null;
|
public org.apache.james.services.User | getUserByNameCaseInsensitive(java.lang.String name)Get the user object with the specified user name. Match user naems on
a case insensitive basis. Return null if no such user.
return getUserByName(name, true);
|
public java.util.Iterator | list()List users in repository.
return listUserNames().iterator();
|
protected abstract java.util.Iterator | listAllUsers()Returns a list populated with all of the Users in the repository.
|
protected java.util.List | listUserNames()Produces the complete list of User names, with correct case.
Iterator users = listAllUsers();
List userNames = new LinkedList();
while ( users.hasNext() ) {
User user = (User)users.next();
userNames.add(user.getUserName());
}
return userNames;
|
public void | removeUser(java.lang.String name)Removes a user from the repository
User user = getUserByName(name);
if ( user != null ) {
doRemoveUser(user);
}
|
public boolean | test(java.lang.String name, java.lang.String password)Test if user with name 'name' has password 'password'.
User user = getUserByName(name, false);
if ( user == null ) {
return false;
} else {
return user.verifyPassword(password);
}
|
public boolean | updateUser(org.apache.james.services.User user)Update the repository with the specified user object. A user object
with this username must already exist.
// Return false if it's not found.
if ( ! contains(user.getUserName()) ) {
return false;
}
else {
doUpdateUser(user);
return true;
}
|