Example usage for org.springframework.security.web.context SaveContextOnUpdateOrErrorResponseWrapper saveContext

List of usage examples for org.springframework.security.web.context SaveContextOnUpdateOrErrorResponseWrapper saveContext

Introduction

In this page you can find the example usage for org.springframework.security.web.context SaveContextOnUpdateOrErrorResponseWrapper saveContext.

Prototype

protected abstract void saveContext(SecurityContext context);

Source Link

Document

Implements the logic for storing the security context.

Usage

From source file:org.springframework.security.web.context.HttpSessionSecurityContextRepository.java

public void saveContext(SecurityContext context, HttpServletRequest request, HttpServletResponse response) {
    SaveContextOnUpdateOrErrorResponseWrapper responseWrapper = WebUtils.getNativeResponse(response,
            SaveContextOnUpdateOrErrorResponseWrapper.class);
    if (responseWrapper == null) {
        throw new IllegalStateException("Cannot invoke saveContext on response " + response
                + ". You must use the HttpRequestResponseHolder.response after invoking loadContext");
    }//from   ww  w  .jav a2 s  . co  m
    // saveContext() might already be called by the response wrapper
    // if something in the chain called sendError() or sendRedirect(). This ensures we
    // only call it
    // once per request.
    if (!responseWrapper.isContextSaved()) {
        responseWrapper.saveContext(context);
    }
}