Example usage for org.springframework.security.web.authentication LoginUrlAuthenticationEntryPoint commence

List of usage examples for org.springframework.security.web.authentication LoginUrlAuthenticationEntryPoint commence

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication LoginUrlAuthenticationEntryPoint commence.

Prototype

public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException 

Source Link

Document

Performs the redirect (or forward) to the login form URL.

Usage

From source file:org.cloudfoundry.identity.uaa.security.CsrfAwareEntryPointAndDeniedHandler.java

protected void internalHandle(HttpServletRequest request, HttpServletResponse response, Exception exception)
        throws IOException, ServletException {
    AuthenticationException authEx = (exception instanceof AuthenticationException)
            ? (AuthenticationException) exception
            : new InternalAuthenticationServiceException("Access denied.", exception);

    if (wantJson(request)) {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        response.setContentType(MediaType.APPLICATION_JSON_VALUE);
        response.getWriter().append(String.format("{\"error\":\"%s\"}", exception.getMessage()));
    } else {/*from w ww  .j a  va2s. co m*/
        LoginUrlAuthenticationEntryPoint entryPoint = getLoginUrlAuthenticationEntryPoint(exception);
        entryPoint.commence(request, response, authEx);
    }
}