Package java.security.acl

Examples of java.security.acl.Group


    Set<String> roles = new HashSet<String>();
   
    Set<Principal> principals = this.subject.getPrincipals();
    for(Principal p: principals) {
      if ((p instanceof Group) && p.getName().equals("Roles")){ //$NON-NLS-1$
        Group g = (Group)p;
        Enumeration<? extends Principal> rolesPrinciples = g.members();
        while(rolesPrinciples.hasMoreElements()) {
          roles.add(rolesPrinciples.nextElement().getName())
        }
      }
    }
View Full Code Here


    ArrayList principalRoles = new ArrayList();
    // Retrieve all roles of the user (Roles are members of the Group.class)
    Set principals = subject.getPrincipals(Group.class);
    Iterator iterator = principals.iterator();
    while (iterator.hasNext()) {
      Group group = (Group) iterator.next();
      // Signed group (empty group that contains a signature)?
      if (group instanceof JSigned) {
        continue;
      }
      Enumeration e = group.members();
      while (e.hasMoreElements()) {
        Principal p = (Principal) e.nextElement();
        principalRoles.add(p.getName());
      }
    }
View Full Code Here

  private  byte[] getSignature() {
    // Retrieve signature (members of the Group.class)
    Set principals = subject.getPrincipals(Group.class);
    Iterator iterator = principals.iterator();
    while (iterator.hasNext()) {
      Group group = (Group) iterator.next();
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "getSignature group = " + group.getClass().getName());
      // Signed group (empty group that contains a signature)?
      if (group instanceof JSigned) {
        return ((JSigned) group).getSignature();
      }
    }
View Full Code Here

   
    Set<Principal> principals = getSubject().getPrincipals();
    for(Principal p: principals) {
      // this JBoss specific, but no code level dependencies
      if ((p instanceof Group) && p.getName().equals("Roles")){ //$NON-NLS-1$
        Group g = (Group)p;
        Enumeration<? extends Principal> rolesPrinciples = g.members();
        while(rolesPrinciples.hasMoreElements()) {
          roles.add(rolesPrinciples.nextElement().getName())
        }
      }
    }
View Full Code Here

        // Add principal name
        Principal principal = principals.keySet().iterator().next();
        this.runAsSubject.getPrincipals().add(principal);

        // Add roles for this principal
        Group roles = new JGroup("roles");
        roles.addMember(new JPrincipal(runAsRole));

        // Add list roles for this role
        for (Principal member : principals.get(principal)) {
            roles.addMember(member);
        }

        this.runAsSubject.getPrincipals().add(roles);

    }
View Full Code Here

        // Add principal name
        Principal principalName = new JPrincipal(userName);
        subject.getPrincipals().add(principalName);

        // Add roles for this principal
        Group roles = new JGroup("roles");
        if (roleList != null) {
            for (String role : roleList) {
                roles.addMember(new JPrincipal(role));
            }
        }
        subject.getPrincipals().add(roles);

        return subject;
View Full Code Here

         Subject subject = SecurityAssociation.getSubject();

         if (subject != null)
         {
            // Check the caller's roles
            Group subjectRoles = getSubjectRoles(subject);
            if (subjectRoles != null)
            {
               Iterator iter = roles.iterator();
               while (!hasRole && iter.hasNext())
               {
View Full Code Here

    */
   private Group getSubjectRoles(Subject subject)
   {
      Set subjectGroups = subject.getPrincipals(Group.class);
      Iterator iter = subjectGroups.iterator();
      Group roles = null;
      while (iter.hasNext())
      {
         Group grp = (Group)iter.next();
         String name = grp.getName();
         if (name.equals("Roles"))
         {
            roles = grp;
         }
      }
View Full Code Here

   {
      Set groups = subject.getPrincipals(Group.class);

      if(groups == null || groups.isEmpty())
      {
         Group g = new SimpleGroup("Roles");
         subject.getPrincipals().add(g);
         groups = new HashSet();
         groups.add(g);
      }

      Group roles = null;

      for(Iterator i = groups.iterator(); i.hasNext(); )
      {
         Group g = (Group)i.next();
         if ("Roles".equals(g.getName()))
         {
            roles = g;
         }
      }
View Full Code Here

      System.out.println("Subject: "+subject);

      Set groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains jduke", subject.getPrincipals().contains(new SimplePrincipal("jduke")));
      assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
      Group roles = (Group) groups.iterator().next();
      assertTrue("Echo is a role", roles.isMember(new SimplePrincipal("Echo")));
      assertTrue("TheDuke is a role", roles.isMember(new SimplePrincipal("TheDuke")));

      lc.logout();
   }
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.