use of org.apache.catalina.User in project tomcat by apache.
the class DataSourceUserDatabaseMBean method createUser.
/**
* Create a new User and return the corresponding name.
*
* @param username User name of the new user
* @param password Password for the new user
* @param fullName Full name for the new user
* @return the new user name
*/
public String createUser(String username, String password, String fullName) {
UserDatabase database = (UserDatabase) this.resource;
User user = database.createUser(username, password, fullName);
return user.getUsername();
}
use of org.apache.catalina.User in project tomcat by apache.
the class MemoryUserDatabaseMBean method removeUser.
/**
* Remove an existing user and destroy the corresponding MBean.
*
* @param username User name to remove
*/
public void removeUser(String username) {
UserDatabase database = (UserDatabase) this.resource;
User user = database.findUser(username);
if (user == null) {
return;
}
try {
MBeanUtils.destroyMBean(user);
database.removeUser(user);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException("Exception destroying user [" + username + "] MBean");
iae.initCause(e);
throw iae;
}
}
use of org.apache.catalina.User in project tomcat by apache.
the class MemoryUserDatabaseMBean method createUser.
/**
* Create a new User and return the corresponding MBean Name.
*
* @param username User name of the new user
* @param password Password for the new user
* @param fullName Full name for the new user
* @return the new user object name
*/
public String createUser(String username, String password, String fullName) {
UserDatabase database = (UserDatabase) this.resource;
User user = database.createUser(username, password, fullName);
try {
MBeanUtils.createMBean(user);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException("Exception creating user [" + username + "] MBean");
iae.initCause(e);
throw iae;
}
return findUser(username);
}
use of org.apache.catalina.User in project tomcat by apache.
the class MemoryUserDatabaseMBean method getUsers.
/**
* @return the MBean Names of all users defined in this database.
*/
public String[] getUsers() {
UserDatabase database = (UserDatabase) this.resource;
ArrayList<String> results = new ArrayList<>();
Iterator<User> users = database.getUsers();
while (users.hasNext()) {
User user = users.next();
results.add(findUser(user.getUsername()));
}
return results.toArray(new String[results.size()]);
}
use of org.apache.catalina.User in project tomcat70 by apache.
the class MemoryGroup method getUsers.
/**
* Return the set of {@link org.apache.catalina.User}s that are members of this group.
*/
@Override
public Iterator<User> getUsers() {
ArrayList<User> results = new ArrayList<User>();
Iterator<User> users = database.getUsers();
while (users.hasNext()) {
User user = users.next();
if (user.isInGroup(this)) {
results.add(user);
}
}
return (results.iterator());
}
Aggregations