SEC-375: Publish AuthorizationFailureEvent event when AccessDeniedException thrown by AfterInvocationProvider.
This commit is contained in:
parent
b8d0722251
commit
0f517cb8e2
|
@ -15,13 +15,19 @@
|
||||||
|
|
||||||
package org.acegisecurity.event.authorization;
|
package org.acegisecurity.event.authorization;
|
||||||
|
|
||||||
|
import org.acegisecurity.AccessDecisionManager;
|
||||||
import org.acegisecurity.AccessDeniedException;
|
import org.acegisecurity.AccessDeniedException;
|
||||||
|
import org.acegisecurity.AfterInvocationManager;
|
||||||
import org.acegisecurity.Authentication;
|
import org.acegisecurity.Authentication;
|
||||||
import org.acegisecurity.ConfigAttributeDefinition;
|
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
|
* @author Ben Alex
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
|
|
@ -148,8 +148,17 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean, A
|
||||||
}
|
}
|
||||||
|
|
||||||
if (afterInvocationManager != null) {
|
if (afterInvocationManager != null) {
|
||||||
returnedObject = afterInvocationManager.decide(token.getAuthentication(), token.getSecureObject(),
|
// Attempt after invocation handling
|
||||||
token.getAttr(), returnedObject);
|
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;
|
return returnedObject;
|
||||||
|
|
Loading…
Reference in New Issue