use of org.apache.catalina.Group in project tomcat by apache.
the class DataSourceUserDatabaseMBean method addGroupRole.
/**
* Add role to a group.
* @param groupname The group name
* @param rolename The role name
*/
public void addGroupRole(String groupname, String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.findGroup(groupname);
Role role = database.findRole(rolename);
if (group != null && role != null) {
group.addRole(role);
}
}
use of org.apache.catalina.Group in project tomcat by apache.
the class GroupMBean method getRoles.
/**
* @return the MBean Names of all authorized roles for this group.
*/
public String[] getRoles() {
Group group = (Group) this.resource;
List<String> results = new ArrayList<>();
Iterator<Role> roles = group.getRoles();
while (roles.hasNext()) {
Role role = null;
try {
role = roles.next();
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role);
results.add(oname.toString());
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException(sm.getString("userMBean.createError.role", role), e);
}
}
return results.toArray(new String[0]);
}
use of org.apache.catalina.Group in project tomcat by apache.
the class GroupMBean method addRole.
/**
* Add a new {@link Role} to those this group belongs to.
*
* @param rolename Role name of the new role
*/
public void addRole(String rolename) {
Group group = (Group) this.resource;
if (group == null) {
return;
}
Role role = group.getUserDatabase().findRole(rolename);
if (role == null) {
throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename));
}
group.addRole(role);
}
use of org.apache.catalina.Group in project tomcat by apache.
the class GroupMBean method removeRole.
/**
* Remove a {@link Role} from those this group belongs to.
*
* @param rolename Role name of the old role
*/
public void removeRole(String rolename) {
Group group = (Group) this.resource;
if (group == null) {
return;
}
Role role = group.getUserDatabase().findRole(rolename);
if (role == null) {
throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename));
}
group.removeRole(role);
}
use of org.apache.catalina.Group in project tomcat by apache.
the class SparseUserDatabaseMBean method getGroups.
// ------------------------------------------------------------- Attributes
/**
* @return the MBean Names of all groups defined in this database.
*/
public String[] getGroups() {
UserDatabase database = (UserDatabase) this.resource;
List<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[0]);
}
Aggregations