[seam-commits] Seam SVN: r13204 - examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Jun 16 18:09:53 EDT 2010
Author: lincolnthree
Date: 2010-06-16 18:09:52 -0400 (Wed, 16 Jun 2010)
New Revision: 13204
Removed:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
Log:
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java 2010-06-16 22:04:07 UTC (rev 13203)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java 2010-06-16 22:09:52 UTC (rev 13204)
@@ -1,55 +0,0 @@
-package org.jboss.seam.examples.booking.security;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-
-import org.slf4j.Logger;
-
-/**
- * An observer that monitors authentication events and performs initialization
- * and cleanup.
- *
- * @author Dan Allen
- */
- at RequestScoped
-public class AuthenticationEventListener
-{
- @Inject
- private Logger log;
-
- /**
- * Clear the dummy register user when a login event occurs. Temporary
- * workaround for not being able to clear this out some other way.
- */
- // public void onLogin(@Observes final LoggedInEvent loggedInEvent, final
- // BeanManager manager)
- // {
- // log.info(loggedInEvent.getPrincipal().getName() +
- // " has logged in; clearing instance of @Registered User");
- // Bean<User> registeredUserBean = (Bean<User>) manager.getBeans(User.class,
- // new AnnotationLiteral<Registered>()
- // {
- // }).iterator().next();
- // Context sessionContext = manager.getContext(SessionScoped.class);
- //
- // // TODO - the BeanStore.remove() method is no longer available - find a
- // // workaround
- // // ((AbstractThreadLocalMapContext)
- // // sessionContext).getBeanStore().remove(registeredUserBean);
- // }
-
- /**
- * Observe the logout event and prepare the session to be terminated. We
- * cannot terminate the session immediately or else it will cause any
- * additional session-scoped observers to fail. It's necessary to delegate
- * this task to the Seam HttpSessionManager, which can terminate (i.e.,
- * invalidate) the session when the current request ends.
- */
- // public void onLogout(@Observes final LoggedOutEvent loggedOutEvent, final
- // HttpSessionManager sessionManager)
- // {
- // log.info(loggedOutEvent.getPrincipal().getName() + " has logged out");
- // sessionManager.invalidateAtEndOfRequest();
- // }
-
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-16 22:04:07 UTC (rev 13203)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-16 22:09:52 UTC (rev 13204)
@@ -5,11 +5,11 @@
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+
import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
import org.jboss.seam.international.status.builder.BundleKey;
-
import org.slf4j.Logger;
/**
@@ -23,7 +23,7 @@
{
@Inject
private Logger log;
-
+
@PersistenceContext
private EntityManager em;
@@ -33,23 +33,24 @@
@Inject
private Credentials credentials;
- @Inject @Authenticated
+ @Inject
+ @Authenticated
private Event<User> loginEventSrc;
public boolean authenticate()
{
log.info("Logging in " + credentials.getUsername());
- if (credentials.getUsername() == null || credentials.getPassword() == null)
+ if ((credentials.getUsername() == null) || (credentials.getPassword() == null))
{
messages.info(new BundleKey("messages", "identity.loginFailed"));
return false;
}
User user = em.find(User.class, credentials.getUsername());
- if (user != null && user.getPassword().equals(credentials.getPassword()))
+ if ((user != null) && user.getPassword().equals(credentials.getPassword()))
{
loginEventSrc.fire(user);
- messages.info(new BundleKey("messages", "identity.loggedIn"));
+ messages.info(new BundleKey("messages", "identity.loggedIn"), user.getName());
return true;
}
else
More information about the seam-commits
mailing list