Example usage for javax.servlet.http HttpServletResponseWrapper setStatus

List of usage examples for javax.servlet.http HttpServletResponseWrapper setStatus

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponseWrapper setStatus.

Prototype

@Override
public void setStatus(int sc) 

Source Link

Document

The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

Usage

From source file:com.marklogic.samplestack.web.security.SamplestackLogoutSuccessHandler.java

@Override
/**/* ww w .j  a  v  a2 s  .co  m*/
 * Override handler for logout success.
 */
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(response);
    responseWrapper.setStatus(HttpStatus.SC_OK);
}

From source file:com.marklogic.samplestack.web.security.SamplestackAccessDeniedHandler.java

@Override
/**//from w ww. j  a v  a2  s  .c om
 * Handler override to return 403s on the HttpResponse.
 */
public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {
    HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(response);
    responseWrapper.setStatus(HttpStatus.SC_FORBIDDEN);

    Writer out = responseWrapper.getWriter();
    errors.writeJsonResponse(out, HttpStatus.SC_FORBIDDEN, "Forbidden");
    out.close();
}

From source file:com.marklogic.samplestack.web.security.SamplestackAuthenticationEntryPoint.java

@Override
/**/*from w  ww  . j  a v  a  2s  .c o m*/
 * Override handler that returns 401 for any unauthenticated
 * request to a secured endpoint.
 */
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException {
    HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(response);
    responseWrapper.setStatus(HttpStatus.SC_UNAUTHORIZED);

    Writer out = responseWrapper.getWriter();
    errors.writeJsonResponse(out, HttpStatus.SC_UNAUTHORIZED, "Unauthorized");
    out.close();
}

From source file:com.marklogic.samplestack.web.security.SamplestackAuthenticationFailureHandler.java

@Override
/**/* w  w w .java2  s . co  m*/
 * Override handler that returns 401 after failed authentication.
 */
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {

    HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(response);
    responseWrapper.setStatus(HttpStatus.SC_UNAUTHORIZED);

    Writer out = responseWrapper.getWriter();
    errors.writeJsonResponse(out, HttpStatus.SC_UNAUTHORIZED, "Unauthorized");
    out.close();
}