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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Aug 4 19:25:48 EDT 2008


Author: shane.bryzak at jboss.com
Date: 2008-08-04 19:25:48 -0400 (Mon, 04 Aug 2008)
New Revision: 8572

Modified:
   trunk/src/main/org/jboss/seam/Component.java
   trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java
Log:
enable security interceptor for role annotations

Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java	2008-08-04 16:50:04 UTC (rev 8571)
+++ trunk/src/main/org/jboss/seam/Component.java	2008-08-04 23:25:48 UTC (rev 8572)
@@ -85,6 +85,7 @@
 import org.jboss.seam.annotations.intercept.Interceptors;
 import org.jboss.seam.annotations.security.PermissionCheck;
 import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.annotations.security.RoleCheck;
 import org.jboss.seam.annotations.web.RequestParameter;
 import org.jboss.seam.async.AsynchronousInterceptor;
 import org.jboss.seam.bpm.BusinessProcessInterceptor;
@@ -1096,11 +1097,21 @@
          return;
       }
       
+      for (Annotation annotation : getBeanClass().getAnnotations())
+      {
+         if (annotation.annotationType().isAnnotationPresent(RoleCheck.class))
+         {
+            secure = true;
+            return;
+         }
+      }
+      
       for (Method method : getBeanClass().getMethods())
       {
          for (Annotation annotation : method.getAnnotations())
          {
-            if (annotation.annotationType().isAnnotationPresent(PermissionCheck.class))
+            if (annotation.annotationType().isAnnotationPresent(PermissionCheck.class) ||
+                  annotation.annotationType().isAnnotationPresent(RoleCheck.class))
             {
                secure = true;
                return;
@@ -1116,6 +1127,7 @@
                   secure = true;
                   return;
                }
+               
             }
          }
       }

Modified: trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java	2008-08-04 16:50:04 UTC (rev 8571)
+++ trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java	2008-08-04 23:25:48 UTC (rev 8572)
@@ -172,6 +172,15 @@
                         restrict.value() : createDefaultExpr(method));
                }
                
+               for (Annotation annotation : method.getDeclaringClass().getAnnotations())
+               {
+                  if (annotation.annotationType().isAnnotationPresent(RoleCheck.class))
+                  {
+                     if (restriction == null) restriction = new Restriction();
+                     restriction.addRoleRestriction(annotation.annotationType().getSimpleName().toLowerCase());
+                  }
+               }
+               
                for (Annotation annotation : method.getAnnotations())
                {
                   if (annotation.annotationType().isAnnotationPresent(PermissionCheck.class))




More information about the seam-commits mailing list