User: starksm 
  Date: 02/02/06 12:03:26

  Modified:    src/main/org/jboss/test Tag: Branch_2_4
                        LoginModulesTest.java UtilTest.java
  Added:       src/main/org/jboss/test Tag: Branch_2_4 PasswordHasher.java
  Log:
  Add test of hashed password with UsersRolesLoginModule and add a utility
  program to generate password hashes.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.5   +46 -2     jbosssx/src/main/org/jboss/test/LoginModulesTest.java
  
  Index: LoginModulesTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosssx/src/main/org/jboss/test/LoginModulesTest.java,v
  retrieving revision 1.6.2.4
  retrieving revision 1.6.2.5
  diff -u -r1.6.2.4 -r1.6.2.5
  --- LoginModulesTest.java     2002/02/05 18:54:02     1.6.2.4
  +++ LoginModulesTest.java     2002/02/06 20:03:26     1.6.2.5
  @@ -48,7 +48,7 @@
   /** Tests of the LoginModule classes.
    
    @author [EMAIL PROTECTED]
  - @version $Revision: 1.6.2.4 $
  + @version $Revision: 1.6.2.5 $
    */
   public class LoginModulesTest extends TestCase
   {
  @@ -199,6 +199,18 @@
            AppConfigurationEntry[] entry = {ace};
            return entry;
         }
  +      AppConfigurationEntry[] testUsersRolesHash()
  +      {
  +         String name = "org.jboss.security.auth.spi.UsersRolesLoginModule";
  +         HashMap options = new HashMap();
  +         options.put("usersProperties", "usersb64.properties");
  +         options.put("hashAlgorithm", "MD5");
  +         options.put("hashEncoding", "base64");
  +         AppConfigurationEntry ace = new AppConfigurationEntry(name,
  +         AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
  +         AppConfigurationEntry[] entry = {ace};
  +         return entry;
  +      }
         AppConfigurationEntry[] testAnonUsersRoles()
         {
            String name = "org.jboss.security.auth.spi.UsersRolesLoginModule";
  @@ -445,7 +457,39 @@
         }
         lc.logout();
      }
  -   
  +
  +   public void testUsersRolesHash() throws Exception
  +   {
  +      System.out.println("testUsersRolesHash");
  +      UsernamePasswordHandler handler = new UsernamePasswordHandler("scott", 
"echoman".toCharArray());
  +      LoginContext lc = new LoginContext("testUsersRolesHash", handler);
  +      lc.login();
  +      Subject subject = lc.getSubject();
  +      Set groups = subject.getPrincipals(Group.class);
  +      assert("Principals contains scott", subject.getPrincipals().contains(new 
SimplePrincipal("scott")));
  +      assert("Principals contains Roles", groups.contains(new 
SimplePrincipal("Roles")));
  +      assert("Principals contains CallerPrincipal", groups.contains(new 
SimplePrincipal("CallerPrincipal")));
  +      Group roles = (Group) groups.iterator().next();
  +      Iterator groupsIter = groups.iterator();
  +      while( groupsIter.hasNext() )
  +      {
  +         roles = (Group) groupsIter.next();
  +         if( roles.getName().equals("Roles") )
  +         {
  +            assert("Echo is a role", roles.isMember(new SimplePrincipal("Echo")));
  +            assert("Java is NOT a role", roles.isMember(new 
SimplePrincipal("Java")) == false);
  +            assert("Coder is NOT a role", roles.isMember(new 
SimplePrincipal("Coder")) == false);
  +         }
  +         else if( roles.getName().equals("CallerPrincipal") )
  +         {
  +            System.out.println("CallerPrincipal is "+roles.members().nextElement());
  +            boolean isMember = roles.isMember(new SimplePrincipal("callerScott"));
  +            assert("CallerPrincipal is callerScott", isMember);
  +         }
  +      }
  +      lc.logout();
  +   }
  +
      public void testAnonUsersRoles() throws Exception
      {
         System.out.println("testAnonUsersRoles");
  
  
  
  1.1.2.2   +4 -4      jbosssx/src/main/org/jboss/test/Attic/UtilTest.java
  
  Index: UtilTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosssx/src/main/org/jboss/test/Attic/UtilTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- UtilTest.java     2001/12/29 04:32:45     1.1.2.1
  +++ UtilTest.java     2002/02/06 20:03:26     1.1.2.2
  @@ -8,7 +8,7 @@
   /** Tests of the org.jboss.security.Util class
    
    @author [EMAIL PROTECTED]
  - @version $Revision: 1.1.2.1 $
  + @version $Revision: 1.1.2.2 $
    */
   public class UtilTest extends TestCase
   {
  @@ -22,7 +22,7 @@
      public void testBase64() throws Exception
      {
         System.out.println("testBase64");
  -      byte[] test = "theduke".getBytes();
  +      byte[] test = "echoman".getBytes();
         String b64_1 = Util.encodeBase64(test);
         System.out.println("b64_1 = "+b64_1);
   
  @@ -32,12 +32,12 @@
         super.assertEquals("encodeBase64 == BASE64Encoder", b64_1, b64_2);
      }
   
  -   /** Compare Util.encodeBase64 against the sun misc class
  +   /** Compare Util.encodeBase16 against the java.math.BigInteger class
       */
      public void testBase16() throws Exception
      {
         System.out.println("testBase16");
  -      byte[] test = "theduke".getBytes();
  +      byte[] test = "echoman".getBytes();
         String b16_1 = Util.encodeBase16(test);
         System.out.println("b16_1 = "+b16_1);
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +54 -0     jbosssx/src/main/org/jboss/test/Attic/PasswordHasher.java
  
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to