Example usage for java.security.acl Group removeMember

List of usage examples for java.security.acl Group removeMember

Introduction

In this page you can find the example usage for java.security.acl Group removeMember.

Prototype

public boolean removeMember(Principal user);

Source Link

Document

Removes the specified member from the group.

Usage

From source file:org.betaconceptframework.astroboa.context.SecurityContext.java

public boolean removeRole(String role) {

    if (StringUtils.isBlank(role)) {
        return false;
    }/*  w ww.j  a v a 2s.com*/

    boolean roleHasBeenRemoved = false;

    Set<Group> groups = subject.getPrincipals(Group.class);

    if (groups != null) {

        String nameOfGroupWhichContainsTheRoles = AstroboaPrincipalName.Roles.toString();

        for (Group group : groups) {
            if (StringUtils.equals(nameOfGroupWhichContainsTheRoles, group.getName())) {
                final CmsPrincipal rolePrincipal = new CmsPrincipal(role);

                if (group.isMember(rolePrincipal)) {
                    roleHasBeenRemoved = group.removeMember(rolePrincipal);
                    break;
                }
            }
        }
    }

    //remove role from the list as well
    if (roleHasBeenRemoved && this.roles.contains(role)) {
        this.roles.remove(role);
    }

    return roleHasBeenRemoved;

}