Author: shane.bryzak(a)jboss.com
Date: 2009-05-05 05:35:08 -0400 (Tue, 05 May 2009)
New Revision: 10784
Modified:
modules/trunk/security/src/main/java/org/jboss/seam/security/Role.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
Log:
fix interceptor
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Role.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Role.java 2009-05-05
09:20:35 UTC (rev 10783)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Role.java 2009-05-05
09:35:08 UTC (rev 10784)
@@ -8,6 +8,8 @@
*/
public class Role extends SimplePrincipal
{
+ private static final long serialVersionUID = 1187276024036531700L;
+
private boolean conditional;
public Role(String name)
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-05
09:20:35 UTC (rev 10783)
+++
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java 2009-05-05
09:35:08 UTC (rev 10784)
@@ -3,7 +3,6 @@
import javax.context.ApplicationScoped;
import javax.event.Observes;
import javax.inject.Current;
-import javax.security.auth.login.LoginException;
import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.international.StatusMessage.Severity;
Modified:
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
---
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2009-05-05
09:20:35 UTC (rev 10783)
+++
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2009-05-05
09:35:08 UTC (rev 10784)
@@ -9,8 +9,11 @@
import java.util.Set;
import javax.inject.Current;
+import javax.inject.manager.Bean;
import javax.inject.manager.Manager;
+import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
import org.jboss.seam.security.annotations.PermissionCheck;
import org.jboss.seam.security.annotations.Restrict;
@@ -147,8 +150,7 @@
}
}
}
-
- /*
+
@AroundInvoke
public Object aroundInvoke(InvocationContext invocation) throws Exception
{
@@ -165,11 +167,8 @@
}
return invocation.proceed();
- }
- */
-
+ }
- /*
private Restriction getRestriction(Method interfaceMethod) throws Exception
{
// see field declaration as to why this is done
@@ -190,21 +189,18 @@
{
Restriction restriction = null;
- Method method = getComponent().getBeanClass().getMethod(
- interfaceMethod.getName(), interfaceMethod.getParameterTypes() );
+ /*Method method = getComponent().getBeanClass().getMethod(
+ interfaceMethod.getName(), interfaceMethod.getParameterTypes() );*/
Restrict restrict = null;
- if ( method.isAnnotationPresent(Restrict.class) )
+ if ( interfaceMethod.isAnnotationPresent(Restrict.class) )
{
- restrict = method.getAnnotation(Restrict.class);
+ restrict = interfaceMethod.getAnnotation(Restrict.class);
}
- else if (
getComponent().getBeanClass().isAnnotationPresent(Restrict.class) )
+ else if (
interfaceMethod.getDeclaringClass().isAnnotationPresent(Restrict.class) )
{
- if ( !getComponent().isLifecycleMethod(method) )
- {
- restrict =
getComponent().getBeanClass().getAnnotation(Restrict.class);
- }
+ restrict =
interfaceMethod.getDeclaringClass().getAnnotation(Restrict.class);
}
if (restrict != null)
@@ -213,8 +209,9 @@
if ( Strings.isEmpty(restrict.value()) )
{
- restriction.setPermissionTarget(getComponent().getName());
- restriction.setPermissionAction(method.getName());
+ Bean<?> bean =
manager.resolveByType(interfaceMethod.getDeclaringClass()).iterator().next();
+ restriction.setPermissionTarget(bean.getName());
+ restriction.setPermissionAction(interfaceMethod.getName());
}
else
{
@@ -222,7 +219,7 @@
}
}
- for (Annotation annotation : method.getDeclaringClass().getAnnotations())
+ for (Annotation annotation :
interfaceMethod.getDeclaringClass().getAnnotations())
{
if (annotation.annotationType().isAnnotationPresent(RoleCheck.class))
{
@@ -231,7 +228,7 @@
}
}
- for (Annotation annotation : method.getAnnotations())
+ for (Annotation annotation : interfaceMethod.getAnnotations())
{
if
(annotation.annotationType().isAnnotationPresent(PermissionCheck.class))
{
@@ -264,9 +261,9 @@
}
}
- for (int i = 0; i < method.getParameterAnnotations().length; i++)
+ for (int i = 0; i < interfaceMethod.getParameterAnnotations().length;
i++)
{
- Annotation[] annotations = method.getParameterAnnotations()[i];
+ Annotation[] annotations =
interfaceMethod.getParameterAnnotations()[i];
for (Annotation annotation : annotations)
{
if
(annotation.annotationType().isAnnotationPresent(PermissionCheck.class))
@@ -287,9 +284,8 @@
}
return restrictions.get(interfaceMethod);
}
+
- */
-
private String getPermissionAction(PermissionCheck check, Annotation annotation)
{
if (!"".equals(check.value()))
@@ -301,11 +297,4 @@
return annotation.annotationType().getSimpleName().toLowerCase();
}
}
-
- /*
- public boolean isInterceptorEnabled()
- {
- return getComponent().isSecure() &&
!getComponent().beanClassHasAnnotation("javax.jws.WebService");
- }
- */
}
Show replies by date