I'm trying to log some security information about an EJB based JEE application. Therefore I specifically want to log which method is called at what time and which user is trying to call it.
Currently I have simply written an Interceptor, injected the SessionContext and thus log via SessionContext.getCallerPrincipal() and InvocationContext.getMethod().
The problem is that I also want to log users trying to call methods they are not allowed to use. So if a method is only allowed via @RolesAllowed for the user group "Manager", but a user of the group "Employee" tries to call it, the interceptor logging method is never called, because the application server already restricts the business method call in the first place, so the logging method in my interceptor never gets triggered.
Is there any way to log such information including failed calls due to sucurity restrictions? These method calls out of someones permissions is actually the most interesting thing for me to log.
Thanks a lot for your time.