/** * Remove all the principals from the group * @param grp * @return */ public static Group removePrincipals(Group grp) { HashSet<Principal> removeset = new HashSet<Principal>(); Enumeration<? extends Principal> en = grp.members(); while(en.hasMoreElements()) { removeset.add(en.nextElement()); } for(Principal p:removeset) grp.removeMember(p); return grp; }
/** * Remove all the principals from the group * @param grp * @return */ public static Group removePrincipals(Group grp) { HashSet<Principal> removeset = new HashSet<Principal>(); Enumeration<? extends Principal> en = grp.members(); while(en.hasMoreElements()) { removeset.add(en.nextElement()); } for(Principal p:removeset) grp.removeMember(p); return grp; }
/** * Process the group with the roles that are mapped in the * properies file * @param group Group that needs to be processed * @param props Properties file */ private void processRoles(Group group,Properties props) throws Exception { Enumeration<?> enumer = props.propertyNames(); while(enumer.hasMoreElements()) { String roleKey = (String)enumer.nextElement(); String comma_separated_roles = props.getProperty(roleKey); Principal pIdentity = createIdentity(roleKey); if(group.isMember(pIdentity)) Util.parseGroupMembers(group,comma_separated_roles,this); if(REPLACE_ROLE) group.removeMember(pIdentity); } } }
/** * Removes a role from the authenticated user * * @param role The name of the role to remove */ public void removeRole(String role) { for ( Group sg : getSubject().getPrincipals(Group.class) ) { if ( ROLES_GROUP.equals( sg.getName() ) ) { Enumeration e = sg.members(); while (e.hasMoreElements()) { Principal member = (Principal) e.nextElement(); if (member.getName().equals(role)) { sg.removeMember(member); break; } } } } }
/** * Removes a role from the user's subject and their security context * * @param role The name of the role to remove */ public void removeRole(String role) { for (Group sg : getSubject().getPrincipals(Group.class)) { if (ROLES_GROUP.equals(sg.getName())) { Enumeration e = sg.members(); while (e.hasMoreElements()) { Principal member = (Principal)e.nextElement(); if (member.getName().equals(role)) { sg.removeMember(member); break; } } } } }
/** * Remove the roles from the Group * @param roles Group of roles * @param removeRoles * @return Group with roles removed */ public static Group removeRoles(Group roles, String[] removeRoles) { //Assume that the roles all belong to the same principal class Class<?> pClass = getPrincipalClass(roles); for(String str:removeRoles) { roles.removeMember(instantiatePrincipal(pClass,str)); } return roles; }
/** * Remove the roles from the Group * @param roles Group of roles * @param removeRoles * @return Group with roles removed */ public static Group removeRoles(Group roles, String[] removeRoles) { //Assume that the roles all belong to the same principal class Class<?> pClass = getPrincipalClass(roles); for(String str:removeRoles) { roles.removeMember(instantiatePrincipal(pClass,str)); } return roles; }
/** * Process the group with the roles that are mapped in the * properies file * @param group Group that needs to be processed * @param props Properties file */ private void processRoles(Group group,Properties props) //throws Exception { Enumeration<?> enumer = props.propertyNames(); while(enumer.hasMoreElements()) { String roleKey = (String)enumer.nextElement(); String comma_separated_roles = props.getProperty(roleKey); try { Principal pIdentity = createIdentity(roleKey); if (group != null) { if(group.isMember(pIdentity)) Util.parseGroupMembers(group,comma_separated_roles,this); if(REPLACE_ROLE) group.removeMember(pIdentity); } } catch(Exception e) { PicketBoxLogger.LOGGER.debugFailureToCreatePrincipal(roleKey, e); } } } }
callerGroup.removeMember(p);
} finally { if (runAsAdded) { rolesGroup.removeMember(runAsPrincipal);
} finally { if (runAsAdded) { rolesGroup.removeMember(runAsPrincipal);