[seam-commits] Seam SVN: r11049 - in modules/trunk/security/src/main/java/org/jboss/seam/security: events and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri May 29 15:43:11 EDT 2009


Author: dan.j.allen
Date: 2009-05-29 15:43:10 -0400 (Fri, 29 May 2009)
New Revision: 11049

Added:
   modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java
Removed:
   modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java
Modified:
   modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
Log:
reenable security messages and allow the keys, severity and default messages to be overridden


Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java	2009-05-29 18:51:54 UTC (rev 11048)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java	2009-05-29 19:43:10 UTC (rev 11049)
@@ -1,92 +1,125 @@
 package org.jboss.seam.security;
 
 import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Current;
 import javax.event.Observes;
 
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.international.StatusMessage.Severity;
+import org.jboss.seam.security.events.AlreadyLoggedInEvent;
+import org.jboss.seam.security.events.LoggedInEvent;
+import org.jboss.seam.security.events.LoginFailedEvent;
+import org.jboss.seam.security.events.NotLoggedInEvent;
 import org.jboss.seam.security.events.PostAuthenticateEvent;
 
 /**
- * Produces FacesMessages in response of certain security events, and helps to decouple the
- * Identity component from JSF.
+ * Produces FacesMessages in response of certain security events, and helps to
+ * decouple the Identity component from JSF.
  * 
  * @author Shane Bryzak
  */
+public
 @ApplicationScoped
-public class SecurityEventMessages
+class SecurityEventMessages
 {
+   private static final String LOGIN_FAILED_MESSAGE_KEY = "org.jboss.seam.loginFailed";
+   private static final String LOGIN_SUCCESSFUL_MESSAGE_KEY = "org.jboss.seam.loginSuccessful";
+   private static final String ALREADY_LOGGED_IN_MESSAGE_KEY = "org.jboss.seam.alreadyLoggedIn";
+   private static final String NOT_LOGGED_IN_MESSAGE_KEY = "org.jboss.seam.notLoggedIn";
+   
+   private static final String DEFAULT_LOGIN_FAILED_MESSAGE = "Login failed.";
+   private static final String DEFAULT_LOGIN_SUCCESSFUL_MESSAGE = "Welcome, {0}.";
+   private static final String DEFAULT_ALREADY_LOGGED_IN_MESSAGE = "You're already logged in. Please log out first if you wish to log in again.";
+   private static final String DEFAULT_NOT_LOGGED_IN_MESSAGE = "Please log in first";
+   
+   @Current StatusMessages statusMessages;
+   @Current Credentials credentials;
+
    public void postAuthenticate(@Observes PostAuthenticateEvent event)
    {
-      //org.jboss.security.saml.SSOManager.processManualLoginNotification(
-            //ServletContexts.instance().getRequest(), identity.getPrincipal().getName());
+      // org.jboss.security.saml.SSOManager.processManualLoginNotification(
+      // ServletContexts.instance().getRequest(),
+      // identity.getPrincipal().getName());
    }
+
+   public void addLoginFailedMessage(@Observes LoginFailedEvent event)
+   {
+      statusMessages.addFromResourceBundleOrDefault(getLoginFailedMessageSeverity(), getLoginFailedMessageKey(), getDefaultLoginFailedMessage(), event.getLoginException());
+   }
    
-   /*
-   @Current StatusMessages statusMessages;
-   @Current Credentials credentials;
+   public void addLoginSuccessMessage(@Observes LoggedInEvent event)
+   {
+      statusMessages.addFromResourceBundleOrDefault(getLoginSuccessfulMessageSeverity(), getLoginSuccessfulMessageKey(), getDefaultLoginSuccessfulMessage(), credentials.getUsername());
+   }
    
-   public void addLoginFailedMessage(@Observes LoginFailedEvent event)
+   public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
    {
-      statusMessages.addFromResourceBundleOrDefault(
-               getLoginFailedMessageSeverity(),
-               getLoginFailedMessageKey(),
-               getLoginFailedMessage(),
-               event.getLoginException());
+      statusMessages.addFromResourceBundleOrDefault(getAlreadyLoggedInMessageSeverity(), getAlreadyLoggedInMessageKey(), getDefaultAlreadyLoggedInMessage());
    }
-
-   public String getLoginFailedMessage()
+   
+   public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
    {
-      return "Login failed";
+      statusMessages.addFromResourceBundleOrDefault(getNotLoggedInMessageSeverity(), getNotLoggedInMessageKey(), getDefaultNotLoggedInMessage());
    }
-
+   
    public Severity getLoginFailedMessageSeverity()
    {
       return Severity.INFO;
    }
-
+   
    public String getLoginFailedMessageKey()
    {
-      return "org.jboss.seam.loginFailed";
+      return LOGIN_FAILED_MESSAGE_KEY;
    }
 
-   public void addLoginSuccessfulMessage(@Observes LoggedInEvent event)
+   public String getDefaultLoginFailedMessage()
    {
-      statusMessages.addFromResourceBundleOrDefault(
-               getLoginSuccessfulMessageSeverity(),
-               getLoginSuccessfulMessageKey(),
-               getLoginSuccessfulMessage(),
-               credentials.getUsername());
+      return DEFAULT_LOGIN_FAILED_MESSAGE;
    }
    
-   public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
+   public Severity getLoginSuccessfulMessageSeverity()
    {
-      statusMessages.addFromResourceBundleOrDefault( Severity.WARN,
-            "org.jboss.seam.NotLoggedIn",
-            "Please log in first"
-         );
+      return Severity.INFO;
    }
+   
+   public String getLoginSuccessfulMessageKey()
+   {
+      return LOGIN_SUCCESSFUL_MESSAGE_KEY;
+   }
 
-   public Severity getLoginSuccessfulMessageSeverity()
+   public String getDefaultLoginSuccessfulMessage()
    {
+      return DEFAULT_LOGIN_SUCCESSFUL_MESSAGE;
+   }
+   
+   public Severity getAlreadyLoggedInMessageSeverity()
+   {
       return Severity.INFO;
    }
-
-   public String getLoginSuccessfulMessage()
+   
+   public String getAlreadyLoggedInMessageKey()
    {
-      return "Welcome, #0";
+      return ALREADY_LOGGED_IN_MESSAGE_KEY;
    }
-
-   public String getLoginSuccessfulMessageKey()
+   
+   public String getDefaultAlreadyLoggedInMessage()
    {
-      return "org.jboss.seam.loginSuccessful";
+      return DEFAULT_ALREADY_LOGGED_IN_MESSAGE;
    }
    
-   public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
+   public Severity getNotLoggedInMessageSeverity()
    {
-      statusMessages.addFromResourceBundleOrDefault ( Severity.WARN,
-         "org.jboss.seam.AlreadyLoggedIn",
-         "You are already logged in, please log out first if you wish to log in again"
-      );
+      return Severity.WARN;
    }
    
-   */
+   public String getNotLoggedInMessageKey()
+   {
+      return NOT_LOGGED_IN_MESSAGE_KEY;
+   }
+   
+   public String getDefaultNotLoggedInMessage()
+   {
+      return DEFAULT_NOT_LOGGED_IN_MESSAGE;
+   }
+
 }

Deleted: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java	2009-05-29 18:51:54 UTC (rev 11048)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java	2009-05-29 19:43:10 UTC (rev 11049)
@@ -1,35 +0,0 @@
-package org.jboss.seam.security;
-
-/**
- * Delegating wrapper for EL security functions.
- * 
- * @author Shane Bryzak
- */
-public class SecurityFunctions
-{
-   // TODO enable
-   /*
-   public static boolean hasRole(String name)
-   {
-      return Identity.instance().hasRole(name);
-   }
-   
-   public static boolean hasPermission(String name, String action, Object arg)
-   {
-      if (arg != null)
-      {
-         return Identity.instance().hasPermission(name, action, arg);
-      }
-      else
-      {
-         return Identity.instance().hasPermission(name, action);
-      }
-   }
-   
-   public static boolean hasPermission(Object target, String action)
-   {
-      return Identity.instance().hasPermission(target, action);
-   }
-   
-   */
-}

Deleted: modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java	2009-05-29 18:51:54 UTC (rev 11048)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java	2009-05-29 19:43:10 UTC (rev 11049)
@@ -1,11 +0,0 @@
-package org.jboss.seam.security.events;
-
-/**
- * This event is fired when an already authenticated user attempts to authenticate again
- *  
- * @author Shane Bryzak
- */
-public class AlreadyLoggedInEvent
-{
-
-}

Copied: modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java (from rev 11044, modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java)
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/AlreadyLoggedInEvent.java	2009-05-29 19:43:10 UTC (rev 11049)
@@ -0,0 +1,11 @@
+package org.jboss.seam.security.events;
+
+/**
+ * This event is fired when an already authenticated user attempts to authenticate again
+ *  
+ * @author Shane Bryzak
+ */
+public class AlreadyLoggedInEvent
+{
+
+}




More information about the seam-commits mailing list