private HttpServletRequest wrapTheRequest ( final ServletRequest request , final AuthPrincipal principal ) { HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper ( ( HttpServletRequest ) request ) { @ Override public Principal getUserPrincipal ( ) { return principal ; } @ Override public boolean isUserInRole ( String role ) { return principal . getRoles ( ) . contains ( role ) ; } @ Override public String getRemoteUser ( ) { return principal . getName ( ) ; } } ; return wrapper ; }
Wrap the request to provide the principal .