Example usage for javax.servlet.http HttpServletResponse SC_UNAUTHORIZED

List of usage examples for javax.servlet.http HttpServletResponse SC_UNAUTHORIZED

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse SC_UNAUTHORIZED.

Prototype

int SC_UNAUTHORIZED

To view the source code for javax.servlet.http HttpServletResponse SC_UNAUTHORIZED.

Click Source Link

Document

Status code (401) indicating that the request requires HTTP authentication.

Usage

From source file:no.smint.anthropos.authentication.TokenEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    //response.sendRedirect("/api/login");
}

From source file:fr.mael.microrss.web.LoginEntryPoint.java

public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    if (isAjaxAndException(request, authException)) {
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    } else {//from www  .  j av  a 2  s .c  o m
        super.commence(request, response, authException);
    }

}

From source file:com.lennonjesus.auth.security.Http401UnauthorizedEntryPoint.java

/**
 * Always returns a 401 error code to the client.
 *///  w  w w .j  a  va  2  s . c  o m
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2)
        throws IOException, ServletException {
    log.debug("Pre-authenticated entry point called. Rejecting access:" + request.getRequestURL());
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied");
}

From source file:opensnap.security.NoOpAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authentication Failed: " + exception.getMessage());
}

From source file:com.ram.topup.api.ws.security.filter.UnauthorizedEntryPoint.java

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

    response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
            "Unauthorized: Authentication token was either missing or invalid.");
}

From source file:com.rockagen.gnext.service.spring.security.extension.ExAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}

From source file:com.sentinel.rest.handlers.HttpAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    LOG.trace("Method: commence called.");

    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
    LOG.trace("Method: commence finished.");
}

From source file:com.artivisi.spring.security.RestAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ae)
        throws IOException, ServletException {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}

From source file:com.tamnd.app.config.security.AuthFailure.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    if (exception instanceof BadCredentialsException) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    } else if (exception instanceof UsernameNotFoundException) {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    } else {//w w  w.j  av  a  2  s .  c o m
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}

From source file:io.github.jhipster.security.AjaxAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {

    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authentication failed");
}