Methods Summary |
---|
public synchronized boolean | addUser(org.apache.james.services.User user)Update the repository with the specified user object. A user object
with this username must already exist.
String username = user.getUserName();
if (contains(username)) {
return false;
}
try {
or.put(username, user);
} catch (Exception e) {
throw new RuntimeException("Exception caught while storing user: " + e );
}
return true;
|
public void | addUser(java.lang.String name, java.lang.Object attributes)
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 void | configure(org.apache.avalon.framework.configuration.Configuration configuration)
destination = configuration.getChild( "destination" ).getAttribute( "URL" );
if (!destination.endsWith(File.separator)) {
destination += File.separator;
}
|
public boolean | contains(java.lang.String name)
return or.containsKey(name);
|
public boolean | containsCaseInsensitive(java.lang.String name)
Iterator it = list();
while (it.hasNext()) {
if (name.equalsIgnoreCase((String)it.next())) {
return true;
}
}
return false;
|
public int | countUsers()
int count = 0;
for (Iterator it = list(); it.hasNext(); it.next()) {
count++;
}
return count;
|
public java.lang.String | getRealName(java.lang.String name)
Iterator it = list();
while (it.hasNext()) {
String temp = (String) it.next();
if (name.equalsIgnoreCase(temp)) {
return temp;
}
}
return null;
|
public synchronized org.apache.james.services.User | getUserByName(java.lang.String name)
if (contains(name)) {
try {
return (User)or.get(name);
} catch (Exception e) {
throw new RuntimeException("Exception while retrieving user: "
+ e.getMessage());
}
} else {
return null;
}
|
public org.apache.james.services.User | getUserByNameCaseInsensitive(java.lang.String name)
String realName = getRealName(name);
if (realName == null ) {
return null;
}
return getUserByName(realName);
|
public void | initialize()
try {
//prepare Configurations for object and stream repositories
final DefaultConfiguration objectConfiguration
= new DefaultConfiguration( "repository",
"generated:UsersFileRepository.compose()" );
objectConfiguration.setAttribute( "destinationURL", destination );
objectConfiguration.setAttribute( "type", "OBJECT" );
objectConfiguration.setAttribute( "model", "SYNCHRONOUS" );
or = (ObjectRepository)store.select( objectConfiguration );
if (getLogger().isDebugEnabled()) {
StringBuffer logBuffer =
new StringBuffer(192)
.append(this.getClass().getName())
.append(" created in ")
.append(destination);
getLogger().debug(logBuffer.toString());
}
} catch (Exception e) {
if (getLogger().isErrorEnabled()) {
getLogger().error("Failed to initialize repository:" + e.getMessage(), e );
}
throw e;
}
|
public java.util.Iterator | list()List users in repository.
return or.list();
|
public synchronized void | removeUser(java.lang.String name)
or.remove(name);
|
public void | service(org.apache.avalon.framework.service.ServiceManager componentManager)
try {
store = (Store)componentManager.lookup( Store.ROLE );
} catch (Exception e) {
final String message = "Failed to retrieve Store component:" + e.getMessage();
getLogger().error( message, e );
throw new ServiceException ("", message, e );
}
|
public boolean | test(java.lang.String name, java.lang.String password)
User user;
try {
if (contains(name)) {
user = (User) or.get(name);
} else {
return false;
}
} catch (Exception e) {
throw new RuntimeException("Exception retrieving User" + e);
}
return user.verifyPassword(password);
|
public boolean | updateUser(org.apache.james.services.User user)
String username = user.getUserName();
if (!contains(username)) {
return false;
}
try {
or.put(username, user);
} catch (Exception e) {
throw new RuntimeException("Exception caught while storing user: " + e );
}
return true;
|