deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-636 integration of AccessDeniedException with ExceptionToCatchEvent
Date Wed, 11 Jun 2014 16:15:16 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master b7a142d39 -> 241484f54


DELTASPIKE-636 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/241484f5
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/241484f5
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/241484f5

Branch: refs/heads/master
Commit: 241484f54ced11b26f269bfb5f3bc1eca6cf3d93
Parents: b7a142d
Author: gpetracek <gpetracek@apache.org>
Authored: Wed Jun 11 18:12:31 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Wed Jun 11 18:12:31 2014 +0200

----------------------------------------------------------------------
 .../deltaspike/security/impl/extension/Authorizer.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/241484f5/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java
b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java
index bf90867..b60e88d 100644
--- a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java
@@ -36,6 +36,7 @@ import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.util.Nonbinding;
 import javax.interceptor.InvocationContext;
 
+import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
 import org.apache.deltaspike.core.util.metadata.builder.InjectableMethod;
 import org.apache.deltaspike.security.api.authorization.AccessDeniedException;
 import org.apache.deltaspike.security.api.authorization.SecurityBindingType;
@@ -196,7 +197,15 @@ class Authorizer
                 }
             });
 
-            throw new AccessDeniedException(violations);
+            AccessDeniedException accessDeniedException = new AccessDeniedException(violations);
+            ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(accessDeniedException);
+            exceptionToCatchEvent.setOptional(true);
+            beanManager.fireEvent(exceptionToCatchEvent);
+
+            if (!exceptionToCatchEvent.isHandled())
+            {
+                throw accessDeniedException;
+            }
         }
     }
 


Mime
View raw message