[jboss-cvs] jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace ...

Shane Bryzak Shane_Bryzak at symantec.com
Sat Dec 30 20:26:42 EST 2006


  User: sbryzak2
  Date: 06/12/30 20:26:42

  Modified:    examples/seamspace/src/org/jboss/seam/example/seamspace 
                        AuthenticatorAction.java
  Log:
  use login module instead of auth provider
  
  Revision  Changes    Path
  1.3       +63 -34    jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/AuthenticatorAction.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AuthenticatorAction.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/AuthenticatorAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- AuthenticatorAction.java	14 Dec 2006 04:12:21 -0000	1.2
  +++ AuthenticatorAction.java	31 Dec 2006 01:26:42 -0000	1.3
  @@ -1,14 +1,17 @@
   package org.jboss.seam.example.seamspace;
   
  +import java.util.Map;
  +
   import javax.persistence.EntityManager;
   import javax.persistence.NoResultException;
  +import javax.security.auth.Subject;
  +import javax.security.auth.callback.CallbackHandler;
  +import javax.security.auth.login.LoginException;
  +import javax.security.auth.spi.LoginModule;
   
   import org.jboss.seam.annotations.In;
   import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.security.Identity;
   import org.jboss.seam.security.AuthenticationException;
  -import org.jboss.seam.security.UsernamePasswordToken;
  -import org.jboss.seam.security.provider.AuthenticationProvider;
   import org.jboss.seam.security.Role;
   
   /**
  @@ -17,20 +20,39 @@
    * @author Shane Bryzak
    */
   @Name("authenticatorAction")
  -public class AuthenticatorAction implements AuthenticationProvider
  +public class AuthenticatorAction implements LoginModule
   {
  +   private Subject subject;
  +   
     @In(create=true)
       private EntityManager entityManager;
   
  -  public Identity authenticate(Identity authentication)
  -      throws AuthenticationException
  +  public boolean abort() throws LoginException
  +   {
  +      // TODO Auto-generated method stub
  +      return false;
  +   }
  +
  +   public boolean commit() throws LoginException
  +   {
  +      // TODO Auto-generated method stub
  +      return false;
  +   }
  +
  +   public void initialize(Subject subject, CallbackHandler callbackHandler, 
  +         Map<String, ?> sharedState, Map<String, ?> options)
  +   {
  +      this.subject = subject;     
  +   }
  +
  +   public boolean login() throws LoginException
     {
       try
       {
         Member member = (Member) entityManager.createQuery(
             "from Member where username = :username and password = :password")
  -          .setParameter("username", authentication.getPrincipal().toString())
  -          .setParameter("password", authentication.getCredentials())
  +//            .setParameter("username", auth.getPrincipal().toString())
  +//            .setParameter("password", auth.getCredentials())
             .getSingleResult();
   
         Role[] roles = new Role[member.getRoles().size()];
  @@ -38,8 +60,9 @@
         for (MemberRole mr : member.getRoles())
           roles[idx++] = new Role(mr.getName());
   
  -      return new UsernamePasswordToken(authentication.getPrincipal(),
  -                                       authentication.getCredentials(), roles);
  +//        return new UsernamePasswordToken(authentication.getPrincipal(),
  +//                                         authentication.getCredentials(), roles);
  +        return true;
       }
       catch (NoResultException ex)
       {
  @@ -50,4 +73,10 @@
         throw new AuthenticationException("Unknown authentication error", ex);
       }
     }
  +
  +   public boolean logout() throws LoginException
  +   {
  +      // TODO Auto-generated method stub
  +      return false;
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list