deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [2/2] git commit: DELTASPIKE-449 integration of AccessDeniedException with ExceptionToCatchEvent
Date Tue, 29 Apr 2014 06:26:55 GMT
DELTASPIKE-449 integration of AccessDeniedException with ExceptionToCatchEvent


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/43b7fd02
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/43b7fd02
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/43b7fd02

Branch: refs/heads/master
Commit: 43b7fd02e39a7bbfa1429c242534f881e46fc1fb
Parents: 61aaa25
Author: gpetracek <gpetracek@apache.org>
Authored: Mon Apr 28 11:21:02 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Tue Apr 29 08:25:38 2014 +0200

----------------------------------------------------------------------
 .../authorization/SecuredAnnotationAuthorizer.java    | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/43b7fd02/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/authorization/SecuredAnnotationAuthorizer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/authorization/SecuredAnnotationAuthorizer.java
b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/authorization/SecuredAnnotationAuthorizer.java
index 951c0fe..409b300 100644
--- a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/authorization/SecuredAnnotationAuthorizer.java
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/authorization/SecuredAnnotationAuthorizer.java
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.security.impl.authorization;
 
+import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.security.api.authorization.AccessDecisionState;
 import org.apache.deltaspike.security.api.authorization.AccessDecisionVoter;
@@ -30,6 +31,7 @@ import org.apache.deltaspike.security.impl.util.SecurityUtils;
 import org.apache.deltaspike.security.spi.authorization.EditableAccessDecisionVoterContext;
 
 import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
 import javax.interceptor.InvocationContext;
 import java.lang.annotation.Annotation;
@@ -49,6 +51,9 @@ public class SecuredAnnotationAuthorizer
     @Inject
     private AccessDecisionVoterContext voterContext;
 
+    @Inject
+    private BeanManager beanManager;
+
     @Secures
     @Secured({ })
     @SuppressWarnings("UnusedDeclaration")
@@ -137,7 +142,14 @@ public class SecuredAnnotationAuthorizer
                             ((EditableAccessDecisionVoterContext) voterContext).addViolation(securityViolation);
                         }
                     }
-                    throw new AccessDeniedException(violations);
+                    AccessDeniedException accessDeniedException = new AccessDeniedException(violations);
+                    ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(accessDeniedException);
+                    this.beanManager.fireEvent(exceptionToCatchEvent);
+
+                    if (!exceptionToCatchEvent.isHandled())
+                    {
+                        throw accessDeniedException;
+                    }
                 }
             }
         }


Mime
View raw message