Java Code Examples for org.springframework.security.web.context.HttpRequestResponseHolder#getRequest()

The following examples show how to use org.springframework.security.web.context.HttpRequestResponseHolder#getRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisSecurityContextRepository.java    From onetwo with Apache License 2.0 6 votes vote down vote up
@Override
public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder) {
	HttpServletRequest request = requestResponseHolder.getRequest();
	HttpServletResponse response = requestResponseHolder.getResponse();
	HttpSession httpSession = request.getSession(false);
	
	String sid = this.getSessionId(request, true);
	SecurityContext context = readSecurityContextFromSession(request);
	if (context == null) {
		context = SecurityContextHolder.createEmptyContext();
	}

	SaveToSessionResponseWrapper wrappedResponse = new SaveToSessionResponseWrapper(
			response, request, httpSession != null, context, sid);
	requestResponseHolder.setResponse(wrappedResponse);

	if (isServlet3) {
		requestResponseHolder.setRequest(new Servlet3SaveToSessionRequestWrapper(request, wrappedResponse));
	}
	
	return context;
}
 
Example 2
Source File: SecurityRequestPostProcessors.java    From maven-framework-project with MIT License 5 votes vote down vote up
final void save(SecurityContext securityContext, HttpServletRequest request) {
	HttpServletResponse response = new MockHttpServletResponse();

	HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(request, response);
	this.repository.loadContext(requestResponseHolder);

	request = requestResponseHolder.getRequest();
	response = requestResponseHolder.getResponse();

	this.repository.saveContext(securityContext, request, response);
}
 
Example 3
Source File: LdapSecurityRequestPostProcessors.java    From maven-framework-project with MIT License 5 votes vote down vote up
final void save(SecurityContext securityContext, HttpServletRequest request) {
	HttpServletResponse response = new MockHttpServletResponse();

	HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(request, response);
	this.repository.loadContext(requestResponseHolder);

	request = requestResponseHolder.getRequest();
	response = requestResponseHolder.getResponse();

	this.repository.saveContext(securityContext, request, response);
}
 
Example 4
Source File: TokenAwareSecurityContextRepository.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder) {
  HttpServletRequest request = requestResponseHolder.getRequest();
  return getSecurityContextRepository(request).loadContext(requestResponseHolder);
}