User: stark   
  Date: 01/03/06 00:35:29

  Modified:    src/main/org/jboss/security/plugins/samples
                        RolesLoginModule.java
  Log:
  Added srp package that was missed. Updated AbstractServerLoginModule to
  support password stacking. Updated RolesLoginModule to use existing
  Groups. Updated JaasSecurityManager to operate correctly as a role-mapping
  only manager when so configured.
  
  Revision  Changes    Path
  1.2       +26 -5     
jbosssx/src/main/org/jboss/security/plugins/samples/RolesLoginModule.java
  
  Index: RolesLoginModule.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jbosssx/src/main/org/jboss/security/plugins/samples/RolesLoginModule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RolesLoginModule.java     2001/03/05 09:53:35     1.1
  +++ RolesLoginModule.java     2001/03/06 08:35:29     1.2
  @@ -10,6 +10,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.security.acl.Group;
  +import java.util.Iterator;
   import java.util.Map;
   import java.util.Properties;
   import java.util.Set;
  @@ -34,7 +35,7 @@
   
   
   @author [EMAIL PROTECTED]
  -@version $Revision: 1.1 $
  +@version $Revision: 1.2 $
   */
   public class RolesLoginModule implements LoginModule
   {
  @@ -78,14 +79,18 @@
               Set principals = subject.getPrincipals();
               // Get the username.Roles for the 'Roles' group
               String key = username + ".Roles";
  -            userRoles = createGroup(key, "Roles");
  +            userRoles = createGroup(key, "Roles", principals);
               principals.add(userRoles);
   
               // Get the username.CallerPrincipal for the 'CallerPrincipal' group
               key = username + ".CallerPrincipal";
  -            callerPrincipal = createGroup(key, "CallerPrincipal");
  +            callerPrincipal = createGroup(key, "CallerPrincipal", principals);
               principals.add(callerPrincipal);
           }
  +        else
  +        {
  +            System.out.println("Warning, no username found, check password-stacking 
option setting");
  +        }
           return committed;
       }
   
  @@ -107,10 +112,26 @@
       }
   // --- End LoginModule interface methods
   
  -    private Group createGroup(String key, String name)
  +    private Group createGroup(String key, String name, Set principals)
       {
  +        // First look for an existing Group by this name
  +        Iterator iter = principals.iterator();
  +        Group group = null;
  +        while( iter.hasNext() && group == null )
  +        {
  +            Object obj = iter.next();
  +            if( obj instanceof Group )
  +            {
  +                group = (Group) obj;
  +                if( group.getName().equals(name) )
  +                    break;
  +                group = null;
  +            }
  +        }
  +
  +        if( group == null )
  +            group = new SimpleGroup(name);
           String value = roles.getProperty(key);
  -        Group group = new SimpleGroup(name);
           if( value != null )
           {
               StringTokenizer tokenizer = new StringTokenizer(value, ",");
  
  
  

Reply via email to