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

Shane Bryzak Shane_Bryzak at symantec.com
Mon Jan 29 19:48:53 EST 2007


  User: sbryzak2
  Date: 07/01/29 19:48:53

  Modified:    src/main/org/jboss/seam/security  Identity.java
  Log:
  consolidated isUserInRole() and hasRole()
  
  Revision  Changes    Path
  1.25      +8 -29     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.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- Identity.java	29 Jan 2007 12:44:40 -0000	1.24
  +++ Identity.java	30 Jan 2007 00:48:53 -0000	1.25
  @@ -32,7 +32,6 @@
   import org.drools.WorkingMemory;
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
  -import org.jboss.seam.Seam;
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.In;
   import org.jboss.seam.annotations.Install;
  @@ -133,26 +132,6 @@
      }
   
      /**
  -    * Checks if the authenticated user contains the specified role.
  -    * 
  -    * @param role String
  -    * @return boolean Returns true if the authenticated user contains the role,
  -    *         or false if otherwise.
  -    */
  -   public boolean isUserInRole(String role)
  -   {
  -      for (Group sg : subject.getPrincipals(Group.class))      
  -      {
  -         if ("roles".equals(sg.getName()))
  -         {
  -            return sg.isMember(new SimplePrincipal(role));
  -         }
  -      }
  -      
  -      return false;
  -   }
  -      
  -   /**
       * Performs an authorization check, based on the specified security expression.
       * 
       * @param expr The security expression to evaluate
  @@ -213,18 +192,19 @@
      /**
       * Checks if the authenticated Identity is a member of the specified role.
       * 
  -    * @param name String The name of the role to check
  +    * @param role String The name of the role to check
       * @return boolean True if the user is a member of the specified role
       */
  -   public boolean hasRole(String name)
  +   public boolean hasRole(String role)
      {
  -      if (!Contexts.isSessionContextActive() || !Contexts.getSessionContext().isSet(
  -            Seam.getComponentName(Identity.class)))
  +      for (Group sg : subject.getPrincipals(Group.class))      
         {
  -         return false;
  +         if ("roles".equals(sg.getName()))
  +         {
  +            return sg.isMember(new SimplePrincipal(role));
         }
  -     
  -      return isUserInRole(name);
  +      }
  +      return false;
      }
   
      /**
  @@ -364,7 +344,6 @@
       * @return boolean The result of the expression evaluation
       */
      public boolean evaluateExpression(String expr) 
  -       throws AuthorizationException
      {     
         return (Boolean) new UnifiedELValueBinding(expr).getValue(FacesContext.getCurrentInstance());
      }   
  
  
  



More information about the jboss-cvs-commits mailing list