SEC-375: Publish AuthorizationFailureEvent event when AccessDeniedException thrown by AfterInvocationProvider.

This commit is contained in:
Ben Alex 2006-11-12 22:06:37 +00:00
parent b8d0722251
commit 0f517cb8e2
2 changed files with 18 additions and 3 deletions

View File

@ -15,13 +15,19 @@
package org.acegisecurity.event.authorization;
import org.acegisecurity.AccessDecisionManager;
import org.acegisecurity.AccessDeniedException;
import org.acegisecurity.AfterInvocationManager;
import org.acegisecurity.Authentication;
import org.acegisecurity.ConfigAttributeDefinition;
/**
* Indicates a secure object invocation failed because the principal could not be authorized for the request.
* Indicates a secure object invocation failed because the principal could not
* be authorized for the request.
*
* <p>This event might be thrown as a result of either an
* {@link AccessDecisionManager} or an {@link AfterInvocationManager}.
*
* @author Ben Alex
* @version $Id$

View File

@ -148,8 +148,17 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean, A
}
if (afterInvocationManager != null) {
returnedObject = afterInvocationManager.decide(token.getAuthentication(), token.getSecureObject(),
token.getAttr(), returnedObject);
// Attempt after invocation handling
try {
returnedObject = afterInvocationManager.decide(token.getAuthentication(), token.getSecureObject(),
token.getAttr(), returnedObject);
} catch (AccessDeniedException accessDeniedException) {
AuthorizationFailureEvent event = new AuthorizationFailureEvent(token.getSecureObject(),
token.getAttr(), token.getAuthentication(), accessDeniedException);
publishEvent(event);
throw accessDeniedException;
}
}
return returnedObject;