I have a web application with Spring MVC 3.2 and Spring Security 3.1
I use basic role security and implemented UserDetailsService and UserDetails to provide GrantedAuthority.
I have enabled global method protection using jsr250 annotations
Everything that works here works as expected when subscribing to access to a custom method limited to declared roles.
I have one more requirement for running certain methods, called during application initialization, as a special user with a "system role" ideally along JavaEE RunAs strings. I am not sure how to do this in Spring Security.
Should I try to create a PreAuthenticatedAuthenticationToken
with some composed values ββand a "system role" authority.
Then I could do something like SecurityContextHolder.getContext().setAuthentication(token);
upon application initialization.
Alternatively, I should try to use RunAsManager. This is similar to what I need, but I did not find simple examples of how I could use it.
I'm new to Spring Security, and I'm not sure how best to proceed.
source share