use of org.apache.catalina.UserDatabase in project tomcat by apache.
the class MemoryUserDatabaseMBean method findRole.
/**
* Return the MBean Name for the specified role name (if any);
* otherwise return <code>null</code>.
*
* @param rolename Role name to look up
* @return the role object name
*/
public String findRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return null;
}
try {
ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role);
return oname.toString();
} catch (MalformedObjectNameException e) {
IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for role [" + rolename + "]");
iae.initCause(e);
throw iae;
}
}
use of org.apache.catalina.UserDatabase in project tomcat by apache.
the class MemoryUserDatabaseMBean method createGroup.
// ------------------------------------------------------------- Operations
/**
* Create a new Group and return the corresponding MBean Name.
*
* @param groupname Group name of the new group
* @param description Description of the new group
* @return the new group object name
*/
public String createGroup(String groupname, String description) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.createGroup(groupname, description);
try {
MBeanUtils.createMBean(group);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException("Exception creating group [" + groupname + "] MBean");
iae.initCause(e);
throw iae;
}
return findGroup(groupname);
}
use of org.apache.catalina.UserDatabase 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.UserDatabase in project tomcat by apache.
the class MemoryUserDatabaseMBean method getGroups.
// ------------------------------------------------------------- Attributes
/**
* @return the MBean Names of all groups defined in this database.
*/
public String[] getGroups() {
UserDatabase database = (UserDatabase) this.resource;
ArrayList<String> results = new ArrayList<>();
Iterator<Group> groups = database.getGroups();
while (groups.hasNext()) {
Group group = groups.next();
results.add(findGroup(group.getGroupname()));
}
return results.toArray(new String[results.size()]);
}
use of org.apache.catalina.UserDatabase in project tomcat by apache.
the class MemoryUserDatabaseMBean method findGroup.
/**
* Return the MBean Name for the specified group name (if any);
* otherwise return <code>null</code>.
*
* @param groupname Group name to look up
* @return the group object name
*/
public String findGroup(String groupname) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.findGroup(groupname);
if (group == null) {
return null;
}
try {
ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group);
return oname.toString();
} catch (MalformedObjectNameException e) {
IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for group [" + groupname + "]");
iae.initCause(e);
throw iae;
}
}
Aggregations