Unfortunately, it is not possible with default implementations available in Spring Security.
I investigated source code and...
MethodSecurityInterceptor
is responsible for protecting method invocations. It delegates access decisions to AccessDecisionManager
.
I checked every implementation of AccessDecisionManager
available out of box.
- AffirmativeBased
- ConsensusBased
- UnanimousBased
Each of them throws AccessDeniedException
exception in similar way.
case AccessDecisionVoter.ACCESS_DENIED:
throw new AccessDeniedException(
messages.getMessage("AbstractAccessDecisionManager.accessDenied",
"Access is denied")
);
AbstractAccessDecisionManager.accessDenied
is name of the message, which can be localized.
For English it is:
AbstractAccessDecisionManager.accessDenied=Access is denied
There are several languages available out of box, and you can make you own translations, but...
That's all, no more information about reasons of exception.
More information about localization of exception messages:
http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#localization