Package java.security.acl

Examples of java.security.acl.Group.addMember()


    public void testUserInRole2() {
        Subject s = new Subject();
        Principal p = new SimplePrincipal("Barry");
        s.getPrincipals().add(p);
        Group group = new SimpleGroup("Roles", p);
        group.addMember(new SimpleGroup("friend"));
        s.getPrincipals().add(group);
        assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
    }
   
    @Test
View Full Code Here


        Subject s = new Subject();
        Principal p = new SimplePrincipal("Barry");
        s.getPrincipals().add(p);
        Group group = new SimpleGroup("Roles", p);
        Group subgroup = new SimpleGroup("subgroup");
        subgroup.addMember(new SimpleGroup("friend"));
        group.addMember(subgroup);
        s.getPrincipals().add(group);
        assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
    }
View Full Code Here

    public void testAddRemoveMembers() {
       
        Group group = new SimpleGroup("group");  
        assertFalse(group.members().hasMoreElements());
       
        group.addMember(new SimpleGroup("group", "friend"));
       
        Enumeration<? extends Principal> members = group.members();
        assertEquals(new SimpleGroup("group", "friend"), members.nextElement());
        assertFalse(members.hasMoreElements());
       
View Full Code Here

    public void testUserInRole2() {
        Subject s = new Subject();
        Principal p = new SimplePrincipal("Barry");
        s.getPrincipals().add(p);
        Group group = new SimpleGroup("Roles", p);
        group.addMember(new SimpleGroup("friend"));
        s.getPrincipals().add(group);
        assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
    }
   
    @Test
View Full Code Here

        Subject s = new Subject();
        Principal p = new SimplePrincipal("Barry");
        s.getPrincipals().add(p);
        Group group = new SimpleGroup("Roles", p);
        Group subgroup = new SimpleGroup("subgroup");
        subgroup.addMember(new SimpleGroup("friend"));
        group.addMember(subgroup);
        s.getPrincipals().add(group);
        assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
    }
   
View Full Code Here

   }
  
   protected ProtectionDomain getProtectionDomain(String username, String role) throws Exception
   {
      Group gp = new SimpleGroup("Roles");
      gp.addMember(new SimplePrincipal(role));
      Principal sp = new SimplePrincipal(username);
      prepareAndSetAuthenticatedSubject(sp,gp);
      return new ProtectionDomain(null,null,null,new Principal[] { sp,gp} );
   }
  
View Full Code Here

         {
            group = new SimpleGroup(roleGroup);
            roleGroups.put(roleGroup, group);
         }
         SimplePrincipal role = new SimplePrincipal(roleName);
         group.addMember(role);
      }
      public int compareTo(Object obj)
      {
         Users.User u = (Users.User) obj;
         return name.compareTo(u.name);
View Full Code Here

         Group[] groups = {roles, callerPrincipal};
         log.info("Getting roles for user=" + getUsername());
         // Add the Echo role
         roles.addMember(new SimplePrincipal("Echo"));
         // Add the custom principal for the caller
         callerPrincipal.addMember(caller);
         return groups;
      }
      catch (Exception e)
      {
         log.error("Failed to obtain groups for user=" + getUsername(), e);
View Full Code Here

    public void testUserInRole2() {
        Subject s = new Subject();
        Principal p = new SimplePrincipal("Barry");
        s.getPrincipals().add(p);
        Group group = new SimpleGroup("Roles", p);
        group.addMember(new SimpleGroup("friend"));
        s.getPrincipals().add(group);
        assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
    }
   
    @Test
View Full Code Here

        Subject s = new Subject();
        Principal p = new SimplePrincipal("Barry");
        s.getPrincipals().add(p);
        Group group = new SimpleGroup("Roles", p);
        Group subgroup = new SimpleGroup("subgroup");
        subgroup.addMember(new SimpleGroup("friend"));
        group.addMember(subgroup);
        s.getPrincipals().add(group);
        assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
    }
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.