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

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

Introduction

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

Prototype

public final boolean isContextSaved() 

Source Link

Document

Tells if the response wrapper has called saveContext() because of this wrapper.

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 w ww . j ava2  s.  c o  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);
    }
}