本文整理汇总了Java中org.springframework.security.web.context.HttpRequestResponseHolder.setResponse方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestResponseHolder.setResponse方法的具体用法?Java HttpRequestResponseHolder.setResponse怎么用?Java HttpRequestResponseHolder.setResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.web.context.HttpRequestResponseHolder
的用法示例。
在下文中一共展示了HttpRequestResponseHolder.setResponse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadContext
import org.springframework.security.web.context.HttpRequestResponseHolder; //导入方法依赖的package包/类
/**
* Obtains the security context for the supplied request. For an unauthenticated user, an empty context
* implementation should be returned. This method should not return null.
* <p>
* The use of the <tt>HttpRequestResponseHolder</tt> parameter allows implementations to return wrapped versions of
* the request or response (or both), allowing them to access implementation-specific state for the request.
* The values obtained from the holder will be passed on to the filter chain and also to the <tt>saveContext</tt>
* method when it is finally called. Implementations may wish to return a subclass of
* {@link SaveContextOnUpdateOrErrorResponseWrapper} as the response object, which guarantees that the context is
* persisted when an error or redirect occurs.
*
* @param requestResponseHolder holder for the current request and response for which the context should be loaded.
*
* @return The security context which should be used for the current request, never null.
*/
@Override
public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder) {
HttpServletRequest request = requestResponseHolder.getRequest();
HttpServletResponse response = requestResponseHolder.getResponse();
requestResponseHolder.setResponse(new SaveToCookieResponseWrapper(request, response));
Cookie authenticationCookie = getAuthenticationCookie(request);
if (authenticationCookie == null) {
return SecurityContextHolder.createEmptyContext();
}
String serialisedAuthentication = tokenEncryption.decryptAndVerify(authenticationCookie.getValue());
if (serialisedAuthentication == null) {
response.addCookie(createExpireAuthenticationCookie(request));
return SecurityContextHolder.createEmptyContext();
}
Authentication authentication = authenticationSerializer.deserialize(serialisedAuthentication);
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
securityContext.setAuthentication(authentication);
return securityContext;
}
示例2: loadContext
import org.springframework.security.web.context.HttpRequestResponseHolder; //导入方法依赖的package包/类
@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;
}
示例3: loadContext
import org.springframework.security.web.context.HttpRequestResponseHolder; //导入方法依赖的package包/类
@Override
public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder) {
SaveToCookieResponseWrapper responseWrapper = new SaveToCookieResponseWrapper(requestResponseHolder.getRequest(), requestResponseHolder.getResponse(), true);
requestResponseHolder.setResponse(responseWrapper);
return securityContextSerializer.deserialize(requestResponseHolder.getRequest(), requestResponseHolder.getResponse());
}
开发者ID:AusDTO,项目名称:citizenship-appointment-server,代码行数:7,代码来源:CookieBasedSecurityContextRepository.java
示例4: wrapResponse
import org.springframework.security.web.context.HttpRequestResponseHolder; //导入方法依赖的package包/类
private void wrapResponse(HttpRequestResponseHolder requestResponseHolder) {
requestResponseHolder.setResponse(new SecurityContextRepositoryResponseWrapper(
requestResponseHolder.getRequest(), requestResponseHolder.getResponse(), this));
}