Example usage for org.springframework.security.web.servletapi SecurityContextHolderAwareRequestWrapper SecurityContextHolderAwareRequestWrapper

List of usage examples for org.springframework.security.web.servletapi SecurityContextHolderAwareRequestWrapper SecurityContextHolderAwareRequestWrapper

Introduction

In this page you can find the example usage for org.springframework.security.web.servletapi SecurityContextHolderAwareRequestWrapper SecurityContextHolderAwareRequestWrapper.

Prototype

public SecurityContextHolderAwareRequestWrapper(HttpServletRequest request, String rolePrefix) 

Source Link

Document

Creates a new instance with AuthenticationTrustResolverImpl .

Usage

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();
}