Java Code Examples for org.apache.catalina.Group#addRole()

The following examples show how to use org.apache.catalina.Group#addRole() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupMBean.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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("Invalid role name '" + rolename + "'");
    }
    group.addRole(role);
}
 
Example 2
Source File: MemoryUserDatabase.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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;
}
 
Example 3
Source File: GroupMBean.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * 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
            ("Invalid role name '" + rolename + "'");
    }
    group.addRole(role);

}
 
Example 4
Source File: MemoryUserDatabase.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: GroupMBean.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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
            ("Invalid role name '" + rolename + "'");
    }
    group.addRole(role);

}
 
Example 6
Source File: MemoryUserDatabase.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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);
}