Search in sources :

Example 16 with Group

use of org.apache.catalina.Group in project tomcat by apache.

the class MemoryUserCreationFactory method createObject.

@Override
public Object createObject(Attributes attributes) {
    String groupname = attributes.getValue("groupname");
    if (groupname == null) {
        groupname = attributes.getValue("name");
    }
    String description = attributes.getValue("description");
    String roles = attributes.getValue("roles");
    Group group = database.createGroup(groupname, description);
    if (roles != null) {
        while (roles.length() > 0) {
            String rolename = null;
            int comma = roles.indexOf(',');
            if (comma >= 0) {
                rolename = roles.substring(0, comma).trim();
                roles = roles.substring(comma + 1);
            } else {
                rolename = roles.trim();
                roles = "";
            }
            if (rolename.length() > 0) {
                Role role = database.findRole(rolename);
                if (role == null) {
                    role = database.createRole(rolename, null);
                }
                group.addRole(role);
            }
        }
    }
    return (group);
}
Also used : Role(org.apache.catalina.Role) Group(org.apache.catalina.Group)

Aggregations

Group (org.apache.catalina.Group)16 User (org.apache.catalina.User)8 Role (org.apache.catalina.Role)7 MalformedObjectNameException (javax.management.MalformedObjectNameException)6 ArrayList (java.util.ArrayList)5 ObjectName (javax.management.ObjectName)4 UserDatabase (org.apache.catalina.UserDatabase)4 MBeanException (javax.management.MBeanException)2 RuntimeOperationsException (javax.management.RuntimeOperationsException)2 NamingException (javax.naming.NamingException)1 OperationNotSupportedException (javax.naming.OperationNotSupportedException)1