[jboss-cvs] jboss-seam/src/main/org/jboss/seam/security ...

Shane Bryzak sbryzak at redhat.com
Wed Nov 7 03:47:28 EST 2007


  User: sbryzak2
  Date: 07/11/07 03:47:28

  Modified:    src/main/org/jboss/seam/security   FacesSecurityEvents.java
                        Identity.java
  Log:
  use constants for event keys
  
  Revision  Changes    Path
  1.2       +6 -6      jboss-seam/src/main/org/jboss/seam/security/FacesSecurityEvents.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FacesSecurityEvents.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/FacesSecurityEvents.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- FacesSecurityEvents.java	6 Nov 2007 08:56:24 -0000	1.1
  +++ FacesSecurityEvents.java	7 Nov 2007 08:47:28 -0000	1.2
  @@ -36,7 +36,7 @@
         return "org.jboss.seam.security.username";
      }   
      
  -   @Observer("org.jboss.seam.security.initIdentity")
  +   @Observer(Identity.EVENT_INIT_IDENTITY)
      public void initCredentialsFromCookie()
      {       
         FacesContext ctx = FacesContext.getCurrentInstance();
  @@ -58,13 +58,13 @@
         setDirty();
      }
      
  -   @Observer("org.jboss.seam.security.credentialsUpdated")
  +   @Observer(Identity.EVENT_CREDENTIALS_UPDATED)
      public void credentialsUpdated()
      {
         setDirty();
      }
      
  -   @Observer("org.jboss.seam.postAuthenticate")
  +   @Observer(Identity.EVENT_POST_AUTHENTICATE)
      public void postAuthenticate()
      {
         // Password is set to null during authentication, so we set dirty
  @@ -74,13 +74,13 @@
         setCookieValueIfEnabled( Identity.instance().getUsername() );      
      }
      
  -   @Observer("org.jboss.seam.security.rememberMe")
  +   @Observer(Identity.EVENT_REMEMBER_ME)
      public void postRememberMe()
      {
         setCookieEnabled(Identity.instance().isRememberMe());
      }     
      
  -   @Observer("org.jboss.seam.security.loginFailed")
  +   @Observer(Identity.EVENT_LOGIN_FAILED)
      public void addLoginFailedMessage(LoginException ex)
      {
         FacesMessages.instance().addFromResourceBundleOrDefault(
  @@ -105,7 +105,7 @@
         return "org.jboss.seam.loginFailed";
      }
   
  -   @Observer("org.jboss.seam.security.loginSuccessful")
  +   @Observer(Identity.EVENT_LOGIN_SUCCESSFUL)
      public void addLoginSuccessfulMessage()
      {
         FacesMessages.instance().addFromResourceBundleOrDefault(
  
  
  
  1.104     +28 -14    jboss-seam/src/main/org/jboss/seam/security/Identity.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Identity.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/Identity.java,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -b -r1.103 -r1.104
  --- Identity.java	6 Nov 2007 15:12:24 -0000	1.103
  +++ Identity.java	7 Nov 2007 08:47:28 -0000	1.104
  @@ -58,6 +58,17 @@
   @Startup
   public class Identity implements Serializable
   {  
  +   public static final String EVENT_INIT_IDENTITY = "org.jboss.seam.security.initIdentity";
  +   public static final String EVENT_LOGIN_SUCCESSFUL = "org.jboss.seam.security.loginSuccessful";
  +   public static final String EVENT_LOGIN_FAILED = "org.jboss.seam.security.loginFailed";
  +   public static final String EVENT_NOT_LOGGED_IN = "org.jboss.seam.security.notLoggedIn";
  +   public static final String EVENT_NOT_AUTHORIZED = "org.jboss.seam.security.notAuthorized";
  +   public static final String EVENT_PRE_AUTHENTICATE = "org.jboss.seam.security.preAuthenticate";
  +   public static final String EVENT_POST_AUTHENTICATE = "org.jboss.seam.security.postAuthenticate";
  +   public static final String EVENT_LOGGED_OUT = "org.jboss.seam.security.loggedOut";
  +   public static final String EVENT_CREDENTIALS_UPDATED = "org.jboss.seam.security.credentialsUpdated";
  +   public static final String EVENT_REMEMBER_ME = "org.jboss.seam.security.rememberMe";
  +   
      private static boolean securityEnabled = true;
      
      public static final String ROLES_GROUP = "Roles";
  @@ -93,7 +104,7 @@
      public void create()
      {     
         subject = new Subject();
  -      Events.instance().raiseEvent("org.jboss.seam.security.initIdentity");
  +      Events.instance().raiseEvent(EVENT_INIT_IDENTITY);
      }
      
      public static boolean isSecurityEnabled()
  @@ -186,14 +197,14 @@
         {
            if ( !isLoggedIn() )
            {
  -            Events.instance().raiseEvent("org.jboss.seam.notLoggedIn");
  +            Events.instance().raiseEvent(EVENT_NOT_LOGGED_IN);
               log.debug(String.format(
                  "Error evaluating expression [%s] - User not logged in", expr));
               throw new NotLoggedInException();
            }
            else
            {
  -            Events.instance().raiseEvent("org.jboss.seam.notAuthorized");
  +            Events.instance().raiseEvent(EVENT_NOT_AUTHORIZED);
               throw new AuthorizationException(String.format(
                  "Authorization check failed for expression [%s]", expr));
            }
  @@ -209,7 +220,7 @@
            {
               log.debug("Login successful for: " + getUsername());
            }
  -         Events.instance().raiseEvent("org.jboss.seam.security.loginSuccessful");
  +         Events.instance().raiseEvent(EVENT_LOGIN_SUCCESSFUL);
            return "loggedIn";
         }
         catch (LoginException ex)
  @@ -218,7 +229,7 @@
            {
                log.debug("Login failed for: " + getUsername(), ex);
            }
  -         Events.instance().raiseEvent("org.jboss.seam.security.loginFailed", ex);
  +         Events.instance().raiseEvent(EVENT_LOGIN_FAILED, ex);
            return null;
         }
      }
  @@ -267,7 +278,7 @@
      {
         unAuthenticate();
         preAuthenticationRoles.clear();
  -      Events.instance().raiseEvent("org.jboss.seam.preAuthenticate");
  +      Events.instance().raiseEvent(EVENT_PRE_AUTHENTICATE);
      }   
      
      protected void postAuthenticate()
  @@ -296,7 +307,7 @@
         
         password = null;
   
  -      Events.instance().raiseEvent("org.jboss.seam.postAuthenticate");
  +      Events.instance().raiseEvent(EVENT_POST_AUTHENTICATE);
      }
      
      /**
  @@ -334,7 +345,7 @@
      {
         principal = null;
         Session.instance().invalidate();
  -      Events.instance().raiseEvent("org.jboss.seam.loggedOut");
  +      Events.instance().raiseEvent(EVENT_LOGGED_OUT);
      }
   
      /**
  @@ -429,7 +440,7 @@
         {
            if ( !isLoggedIn() )
            {
  -            Events.instance().raiseEvent("org.jboss.seam.notLoggedIn");
  +            Events.instance().raiseEvent(EVENT_NOT_LOGGED_IN);
               throw new NotLoggedInException();
            }
            else
  @@ -457,7 +468,7 @@
         {
            if ( !isLoggedIn() )
            {
  -            Events.instance().raiseEvent("org.jboss.seam.notLoggedIn");
  +            Events.instance().raiseEvent(EVENT_NOT_LOGGED_IN);
               throw new NotLoggedInException();
            }
            else
  @@ -536,7 +547,7 @@
         if (this.username != username && (this.username == null || !this.username.equals(username)))
         {
            this.username = username;
  -         Events.instance().raiseEvent("org.jboss.seam.security.credentialsUpdated");
  +         Events.instance().raiseEvent(EVENT_CREDENTIALS_UPDATED);
         }
      }
      
  @@ -550,7 +561,7 @@
         if (this.password != password && (this.password == null || !this.password.equals(password)))
         {
            this.password = password;
  -         Events.instance().raiseEvent("org.jboss.seam.security.credentialsUpdated");
  +         Events.instance().raiseEvent(EVENT_CREDENTIALS_UPDATED);
         }      
      }
      
  @@ -571,8 +582,11 @@
      
      public void setRememberMe(boolean remember)
      {
  +      if (this.rememberMe != remember)
  +      {
         this.rememberMe = remember;
  -      Events.instance().raiseEvent("org.jboss.seam.security.rememberMe");
  +         Events.instance().raiseEvent(EVENT_REMEMBER_ME);
  +      }
      }
      
      public String getJaasConfigName()
  
  
  



More information about the jboss-cvs-commits mailing list