Package java.security.acl

Examples of java.security.acl.Group


      subject.getPrincipals().add(userPrincipal);
    }

    String roles = (String) options.get(ROLES_OPT + suffix);
    if (roles != null) {
      Group rolesGroup = new SimpleGroup(SecurityHelper.ROLES_GROUP_NAME);
      String[] rolesArray = roles.split(",");
      for (String role : rolesArray) {
        rolesGroup.addMember(new SimplePrincipal(role));
      }
      subject.getPrincipals().add(rolesGroup);
    }

    // in any case, clean out state
View Full Code Here


        grantedRoles.remove(role);
        ungrantedRoles.add(role.substring(1));
      }
    }

    Group subjectRoles = getRolesGroup(subject);
    if (subjectRoles != null) {
      boolean granted = false;
      if (!grantedRoles.isEmpty()) {
        for (String grantedRole : grantedRoles) {
          if (subjectRoles.isMember(new SimplePrincipal(grantedRole))) {
            granted = true;
            break;
          }
        }
      }
      if (!granted && !ungrantedRoles.isEmpty()) {
        granted = true;
        for (String ungrantedRole : ungrantedRoles) {
          if (subjectRoles.isMember(new SimplePrincipal(ungrantedRole))) {
            granted = false;
            break;
          }
        }
      }
View Full Code Here

    }
    return false;
  }

  private static Group getRolesGroup(Subject subject) {
    Group subjectRoles = null;
    if (subject != null) {
      for (Principal p : subject.getPrincipals()) {
        if (p instanceof Group
            && ROLES_GROUP_NAME.equalsIgnoreCase(p.getName())) {
          subjectRoles = (Group) p;
View Full Code Here

   *          the subject to extract the roles for.
   * @return the roles list.
   */
  public static List<String> getRoles(Subject subject) {
    List<String> roles = new ArrayList<String>();
    Group subjectRoles = getRolesGroup(subject);
    if (subjectRoles != null) {
      for (Enumeration<? extends Principal> rolesEnum = subjectRoles.members(); rolesEnum
          .hasMoreElements();) {
        roles.add(rolesEnum.nextElement().getName());
      }
    }
    return roles;
View Full Code Here

      if (principals == null || principals.size() == 0)
        return null;
     
      Principal userPrincipal = null;
      Group roles = null;

      for (Principal loginPrincipal : principals) {
        if ("roles".equals(loginPrincipal.getName())
            && loginPrincipal instanceof Group) {
          roles = (Group) loginPrincipal;
View Full Code Here

      {
         return getRoleNames("Roles");
      }
      public String[] getRoleNames(String roleGroup)
      {
         Group group = (Group) roleGroups.get(roleGroup);
         String[] names = {};
         if( group != null )
         {
            ArrayList tmp = new ArrayList();
            Enumeration iter = group.members();
            while( iter.hasMoreElements() )
            {
               Principal p = (Principal) iter.nextElement();
               tmp.add(p.getName());
            }
View Full Code Here

         }
         return names;
      }
      public void addRole(String roleName, String roleGroup)
      {
         Group group = (Group) roleGroups.get(roleGroup);
         if( group == null )
         {
            group = new SimpleGroup(roleGroup);
            roleGroups.put(roleGroup, group);
         }
         SimplePrincipal role = new SimplePrincipal(roleName);
         group.addMember(role);
      }
View Full Code Here

        return identity;
    }

    @Override
    protected Group[] getRoleSets() throws LoginException {
        Group roles = new SimpleGroup("Roles");
        Group callerPrincipal = new SimpleGroup("CallerPrincipal");
        Group[] groups = { roles, callerPrincipal };
        callerPrincipal.addMember(getIdentity());
        return groups;
    }
View Full Code Here

        return identity;
    }

    @Override
    protected Group[] getRoleSets() throws LoginException {
        Group roles = new SimpleGroup("Roles");
        Group callerPrincipal = new SimpleGroup("CallerPrincipal");
        Group[] groups = { roles, callerPrincipal };
        callerPrincipal.addMember(getIdentity());
        return groups;
    }
View Full Code Here

   public boolean commit() throws LoginException
   {       
      subject.getPrincipals().add(new SimplePrincipal(username));
     
      Group roleGroup = null;
     
      for ( Group g : subject.getPrincipals(Group.class) )     
      {
         if ( ROLES_GROUP.equalsIgnoreCase( g.getName() ) )
         {
            roleGroup = g;
            break;
         }
      }

      if (roleGroup == null) roleGroup = new SimpleGroup(ROLES_GROUP);

      for (String role : roles)
      {
         roleGroup.addMember(new SimplePrincipal(role));
      }
     
      subject.getPrincipals().add(roleGroup);
     
      return true;
View Full Code Here

TOP

Related Classes of java.security.acl.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.