Package org.jboss.security

Examples of org.jboss.security.SimpleGroup


   {
      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;
         }
      }

      if (roles == null)
      {
         roles =  new SimpleGroup("Roles");
         subject.getPrincipals().add(roles);
      }

      roles.addMember(new SimplePrincipal(role));
View Full Code Here


      while(iter.hasNext())
      {
         Principal p = (Principal)iter.next();
         if(p instanceof SimpleGroup)
         {
            SimpleGroup sg = (SimpleGroup)p;
            ranAsserts = true;
            assertTrue("testRole exists?", sg.isMember(new SimplePrincipal("testRole")));
            assertTrue("testRole2 exists?", sg.isMember(new SimplePrincipal("testRole2")));
            assertTrue("Role4 exists?", sg.isMember(new SimplePrincipal("Role4")));
            if(replaceRole)
              assertFalse("Role3 does not exist?", sg.isMember(new SimplePrincipal("Role3")));
            else
               assertTrue("Role3 exists?", sg.isMember(new SimplePrincipal("Role3")));
         }
      }
      assertTrue("Ran Asserts?",ranAsserts);
   }
View Full Code Here

         while(iter != null && iter.hasNext())
         {
            Principal p = (Principal)iter.next();
            if(p instanceof SimpleGroup)
            {
               SimpleGroup sg = (SimpleGroup)p;
               String name = sg.getName();
               if("Roles".equals(name))
               {
                  Enumeration en = sg.members();
                  while(en.hasMoreElements())
                  {
                    String role = en.nextElement().toString();
                    if(role != null)
                      alist.add(role);
View Full Code Here

      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

      char roleGroupSeperator, AbstractServerLoginModule aslm)
   {
      Logger log = aslm.log;     
      boolean trace = log.isTraceEnabled();
      Enumeration users = roles.propertyNames();
      SimpleGroup rolesGroup = new SimpleGroup("Roles");
      ArrayList groups = new ArrayList();
      groups.add(rolesGroup);
      while (users.hasMoreElements() && targetUser != null)
      {
         String user = (String) users.nextElement();
         String value = roles.getProperty(user);
         if( trace )
            log.trace("Checking user: "+user+", roles string: "+value);
         // See if this entry is of the form targetUser[.GroupName]=roles
         // JBAS-3742 - skip potential '.' in targetUser
         int index = user.indexOf(roleGroupSeperator, targetUser.length());

         boolean isRoleGroup = false;
         boolean userMatch = false;
         if (index > 0 && targetUser.regionMatches(0, user, 0, index) == true)
            isRoleGroup = true;
         else
            userMatch = targetUser.equals(user);

         // Check for username.RoleGroup pattern
         if (isRoleGroup == true)
         {
            String groupName = user.substring(index + 1);
            if (groupName.equals("Roles"))
            {
               if( trace )
                  log.trace("Adding to Roles: "+value);
               parseGroupMembers(rolesGroup, value, aslm);
            }
            else
            {
               if( trace )
                  log.trace("Adding to "+groupName+": "+value);
               SimpleGroup group = new SimpleGroup(groupName);
               parseGroupMembers(group, value, aslm);
               groups.add(group);
            }
         }
         else if (userMatch == true)
View Full Code Here

            if( aslm.getUnauthenticatedIdentity() == null )
               throw new FailedLoginException("No matching username found in Roles");
            /* We are running with an unauthenticatedIdentity so create an
               empty Roles set and return.
            */
            Group[] roleSets = { new SimpleGroup("Roles") };
            return roleSets;
         }

         do
         {
            String name = rs.getString(1);
            String groupName = rs.getString(2);
            if( groupName == null || groupName.length() == 0 )
               groupName = "Roles";
            Group group = (Group) setsMap.get(groupName);
            if( group == null )
            {
               group = new SimpleGroup(groupName);
               setsMap.put(groupName, group);
            }

            try
            {
View Full Code Here

      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

   {
      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;
         }
      }

      if (roles == null)
      {
         roles =  new SimpleGroup("Roles");
         subject.getPrincipals().add(roles);
      }

      roles.addMember(new SimplePrincipal(role));
View Full Code Here

TOP

Related Classes of org.jboss.security.SimpleGroup

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.