List of usage examples for org.springframework.security.web.servletapi SecurityContextHolderAwareRequestWrapper SecurityContextHolderAwareRequestWrapper
public SecurityContextHolderAwareRequestWrapper(HttpServletRequest request, String rolePrefix)
From source file:org.ngrinder.common.util.HttpContainerContextTest.java
@Before public void setMockContext() { MockHttpServletRequest req = new MockHttpServletRequest(); req.addHeader("User-Agent", "Win"); SecurityContextHolderAwareRequestWrapper reqWrapper = new SecurityContextHolderAwareRequestWrapper(req, "U"); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(reqWrapper)); }
From source file:org.ngrinder.agent.controller.AgentManagerControllerTest.java
@Before public void setMockRequest() { MockHttpServletRequest req = new MockHttpServletRequest(); req.addHeader("User-Agent", "Win"); SecurityContextHolderAwareRequestWrapper reqWrapper = new SecurityContextHolderAwareRequestWrapper(req, "U"); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(reqWrapper)); }
From source file:org.madsonic.service.SecurityService.java
/** * Returns the name of the currently logged-in user. * * @param request The HTTP request.// w w w . jav a 2s .c o m * @return The name of the logged-in user, or <code>null</code>. */ public String getCurrentUsername(HttpServletRequest request) { return new SecurityContextHolderAwareRequestWrapper(request, null).getRemoteUser(); }