I am currently implementing REST API using Jersey (JAX-RS impelemntation) and some parts of Spring.
I already implemented stateless authentication with Spring Security using custom filter and custom AuthenticationEntryPoint, the problem is, how can I obtain current user in my JAX-RS classes.
I know that in Spring MVC it is possible to inject Principal object into controller methods, but what about JAX-RS classes? I want to avoid polluting my classes with SecurityContextHolder.getContext().getAuthentication().
One way is to create custom class that will be an adapter to this static call, and inject it into every service class I need, or maybe there is this kind of adapter already exposed in Spring Security? Apart from my proposal, is there some 'better' way of obtaining currently logged user in my situation?