Java Code Examples for org.apache.catalina.User#removeRole()

The following examples show how to use org.apache.catalina.User#removeRole() . 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: MemoryUserDatabase.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
@Override
public void removeRole(Role role) {
    readLock.lock();
    try {
        Iterator<Group> groups = getGroups();
        while (groups.hasNext()) {
            Group group = groups.next();
            group.removeRole(role);
        }
        Iterator<User> users = getUsers();
        while (users.hasNext()) {
            User user = users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    } finally {
        readLock.unlock();
    }
}
 
Example 2
Source File: MemoryUserDatabase.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
@Override
public void removeRole(Role role) {

    synchronized (roles) {
        Iterator<Group> groups = getGroups();
        while (groups.hasNext()) {
            Group group = groups.next();
            group.removeRole(role);
        }
        Iterator<User> users = getUsers();
        while (users.hasNext()) {
            User user = users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    }

}
 
Example 3
Source File: MemoryUserDatabase.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
@Override
public void removeRole(Role role) {

    synchronized (roles) {
        Iterator<Group> groups = getGroups();
        while (groups.hasNext()) {
            Group group = groups.next();
            group.removeRole(role);
        }
        Iterator<User> users = getUsers();
        while (users.hasNext()) {
            User user = users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    }

}
 
Example 4
Source File: UserMBean.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Remove a {@link Role} from those this user belongs to.
 *
 * @param rolename Role name of the old role
 */
public void removeRole(String rolename) {

    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
    }
    user.removeRole(role);
}
 
Example 5
Source File: UserMBean.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Remove a {@link Role} from those this user belongs to.
 *
 * @param rolename Role name of the old role
 */
public void removeRole(String rolename) {

    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException
            ("Invalid role name '" + rolename + "'");
    }
    user.removeRole(role);

}
 
Example 6
Source File: UserMBean.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Remove a {@link Role} from those this user belongs to.
 *
 * @param rolename Role name of the old role
 */
public void removeRole(String rolename) {

    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException
            ("Invalid role name '" + rolename + "'");
    }
    user.removeRole(role);

}