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

Gavin King gavin.king at jboss.com
Tue Feb 13 01:17:38 EST 2007


  User: gavin   
  Date: 07/02/13 01:17:38

  Modified:    src/main/org/jboss/seam/interceptors 
                        SecurityInterceptor.java
  Log:
  JBSEAM-836
  
  Revision  Changes    Path
  1.28      +20 -24    jboss-seam/src/main/org/jboss/seam/interceptors/SecurityInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SecurityInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/SecurityInterceptor.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -b -r1.27 -r1.28
  --- SecurityInterceptor.java	9 Feb 2007 03:44:22 -0000	1.27
  +++ SecurityInterceptor.java	13 Feb 2007 06:17:38 -0000	1.28
  @@ -2,12 +2,12 @@
   
   import java.lang.reflect.Method;
   
  -import org.jboss.seam.Seam;
   import org.jboss.seam.annotations.AroundInvoke;
   import org.jboss.seam.annotations.Interceptor;
   import org.jboss.seam.annotations.security.Restrict;
   import org.jboss.seam.intercept.InvocationContext;
   import org.jboss.seam.security.Identity;
  +import org.jboss.seam.util.Strings;
   
   /**
    * Provides authorization services for component invocations.
  @@ -23,28 +23,31 @@
      @AroundInvoke
      public Object aroundInvoke(InvocationContext invocation) throws Exception
      {
  -      Restrict r = null;
  -
         Method method = invocation.getMethod();
  -
  -      if (method.isAnnotationPresent(Restrict.class))
  +      Restrict restrict = getRestriction(method);
  +      if (restrict != null)
         {
  -         r = method.getAnnotation(Restrict.class);
  +         String expr = !Strings.isEmpty( restrict.value() ) ? 
  +                  restrict.value() : createDefaultExpr(method);
  +         Identity.instance().checkRestriction(expr);
         }
  -      else if (method.getDeclaringClass().isAnnotationPresent(Restrict.class))
  -      {
  -         r = method.getDeclaringClass().getAnnotation(Restrict.class);
  +      return invocation.proceed();
         }
   
  -      if (r != null)
  +   private Restrict getRestriction(Method method)
         {
  -         String expr = r.value() != null && !"".equals(r.value()) ? r.value() : 
  -            createDefaultExpr(method);         
  -         
  -         Identity.instance().checkRestriction(expr);
  +      if ( method.isAnnotationPresent(Restrict.class) )
  +      {
  +         return method.getAnnotation(Restrict.class);
  +      }
  +      else if ( method.getDeclaringClass().isAnnotationPresent(Restrict.class) )
  +      {
  +         if ( !getComponent().isLifecycleMethod(method) )
  +         {
  +            return method.getDeclaringClass().getAnnotation(Restrict.class);
         }
  -
  -      return invocation.proceed();
  +      }
  +      return null;
      }
      
      /**
  @@ -56,13 +59,6 @@
       */
      private String createDefaultExpr(Method method)
      {
  -      String name = Seam.getComponentName(method.getDeclaringClass());
  -      if (name == null)
  -      {
  -         throw new IllegalArgumentException(String.format(
  -                  "Method %s is not a component method", method));
  -      }
  -      
  -      return String.format("#{s:hasPermission('%s','%s', null)}", name, method.getName());
  +      return String.format( "#{s:hasPermission('%s','%s', null)}", getComponent().getName(), method.getName() );
      }
   }
  
  
  



More information about the jboss-cvs-commits mailing list