[seam-commits] Seam SVN: r10813 - in examples/trunk/booking: ejb-jar and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed May 6 02:46:19 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-05-06 02:46:19 -0400 (Wed, 06 May 2009)
New Revision: 10813

Removed:
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
Modified:
   examples/trunk/booking/ear/
   examples/trunk/booking/ejb-jar/
   examples/trunk/booking/ejb-jar/pom.xml
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
   examples/trunk/booking/war/
Log:
use security module


Property changes on: examples/trunk/booking/ear
___________________________________________________________________
Name: svn:ignore
   - target

   + target
.project
.settings



Property changes on: examples/trunk/booking/ejb-jar
___________________________________________________________________
Name: svn:ignore
   - target

   + target
.settings
.classpath
.project


Modified: examples/trunk/booking/ejb-jar/pom.xml
===================================================================
--- examples/trunk/booking/ejb-jar/pom.xml	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/pom.xml	2009-05-06 06:46:19 UTC (rev 10813)
@@ -98,6 +98,11 @@
          <groupId>${seam.groupId}</groupId>
          <artifactId>seam-faces</artifactId>
       </dependency>
+      
+      <dependency>
+         <groupId>${seam.groupId}</groupId>
+         <artifactId>seam-security</artifactId>
+      </dependency>
 
       <dependency>
          <groupId>${webbeans.groupId}</groupId>

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java	2009-05-06 06:46:19 UTC (rev 10813)
@@ -8,7 +8,8 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.examples.booking.security.Identity;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
 import org.jboss.webbeans.log.Log;
 import org.jboss.webbeans.log.Logger;
 
@@ -24,6 +25,8 @@
    @PersistenceContext EntityManager em;
 
    @Current Identity identity;
+   
+   @Current Credentials credentials;
 
    public
    @Produces
@@ -34,8 +37,8 @@
    {
       if (identity.isLoggedIn())
       {
-         log.info("Producing user from username {0}", identity.getUsername());
-         User candidate = em.find(User.class, identity.getUsername());
+         log.info("Producing user from username {0}", credentials.getUsername());
+         User candidate = em.find(User.class, credentials.getUsername());
          if (candidate != null)
          {
             return new User(candidate.getName(), candidate.getUsername());

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java	2009-05-06 06:46:19 UTC (rev 10813)
@@ -9,10 +9,10 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.examples.booking.security.Credentials;
-import org.jboss.seam.examples.booking.security.Identity;
 import org.jboss.seam.international.StatusMessage;
 import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
 import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
 
 /**
@@ -48,7 +48,7 @@
       {
          em.persist(newUser);
          credentials.setUsername(newUser.getUsername());
-         identity.autoLogin();
+         identity.login();
          registered = true;
          statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
       }

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java	2009-05-06 06:46:19 UTC (rev 10813)
@@ -10,6 +10,6 @@
  */
 public
 @Local
-interface Authenticator {
-   boolean authenticate();
+interface Authenticator extends org.jboss.seam.security.Authenticator {
+   
 }

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java	2009-05-06 06:46:19 UTC (rev 10813)
@@ -5,6 +5,7 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.security.Credentials;
 import org.jboss.webbeans.log.Log;
 import org.jboss.webbeans.log.Logger;
 

Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java	2009-05-06 06:46:19 UTC (rev 10813)
@@ -1,47 +0,0 @@
-package org.jboss.seam.examples.booking.security;
-
-import java.io.Serializable;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-
-/**
- * Holds the user's credentials.
- *
- * @author Dan Allen
- */
-public
- at Named
- at SessionScoped
-class Credentials implements Serializable
-{
-   private String username;
-
-   private String password;
-
-   public String getPassword()
-   {
-      return password;
-   }
-
-   public void setPassword(String password)
-   {
-      this.password = password;
-   }
-
-   public String getUsername()
-   {
-      return username;
-   }
-
-   public void setUsername(String username)
-   {
-      this.username = username;
-   }
-
-   public void clear()
-   {
-      this.username = null;
-      this.password = null;
-   }
-
-}

Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java	2009-05-06 06:45:23 UTC (rev 10812)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java	2009-05-06 06:46:19 UTC (rev 10813)
@@ -1,74 +0,0 @@
-package org.jboss.seam.examples.booking.security;
-
-import java.io.Serializable;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.faces.context.FacesContext;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Manager;
-
-/**
- * @author Dan Allen
- */
-public
- at Named
- at SessionScoped
-class Identity implements Serializable
-{
-   @Current Authenticator authenticator;
-
-   @Current Manager manager;
-
-   private Credentials credentials;
-
-   private boolean loggedIn;
-
-   public Identity() {}
-   
-   public @Initializer Identity(Credentials credentials)
-   {
-      this.credentials = credentials;
-   }
-
-
-   public boolean isLoggedIn()
-   {
-      return loggedIn;
-   }
-
-   public String getUsername()
-   {
-      return credentials.getUsername();
-   }
-
-   public void autoLogin()
-   {
-      loggedIn = true;
-   }
-
-   public void login()
-   {
-      if (authenticator.authenticate())
-      {
-         loggedIn = true;
-         // authenticationEvent.fire(new AuthenticationEvent(credentials), new AnnotationLiteral<Success>() {});
-         return;
-      }
-
-      // authenticationEvent.fire(new AuthenticationEvent(credentials), new AnnotationLiteral<Failed>() {});
-   }
-
-   public void logout()
-   {
-      credentials.clear();
-      loggedIn = false;
-      // FIXME this is a dirty hack to reset a producer
-      FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
-
-//      Set<Bean<User>> candidates = manager.resolveByType(User.class, new AnnotationLiteral<Registered>() {});
-//      assert candidates.size() == 1;
-//      User user = manager.getInstanceByType(User.class, new AnnotationLiteral<Registered>() {});
-//      candidates.iterator().next().destroy(user);
-   }
-}


Property changes on: examples/trunk/booking/war
___________________________________________________________________
Name: svn:ignore
   - target

   + target
.classpath
.project
.settings





More information about the seam-commits mailing list