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:com.telefonica.euro_iaas.sdc.puppetwrapper.auth.RestAuthenticationEntryPoint.java

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

    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}

From source file:fi.helsinki.opintoni.security.AuthFailureHandler.java

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

    PrintWriter writer = response.getWriter();
    writer.write(exception.getMessage());
    writer.flush();//from www  .j  a  v a 2  s  .  c  o m
}

From source file:com.thinkberg.moxo.dav.UnlockHandler.java

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    FileObject object = getResourceManager().getFileObject(request.getPathInfo());
    String lockTokenHeader = request.getHeader("Lock-Token");
    String lockToken = lockTokenHeader.substring(1, lockTokenHeader.length() - 1);
    log("UNLOCK(" + lockToken + ")");

    if (LockManager.getInstance().releaseLock(object, lockToken)) {
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {//from  w  w w. j av a2s.com
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}

From source file:com.github.iexel.fontus.web.security.RestAuthenticationEntryPoint.java

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

    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
}

From source file:no.dusken.momus.authentication.TokenEntryPoint.java

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

From source file:es.ucm.fdi.dalgs.rest.security.RestAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest arg0, HttpServletResponse arg1, AuthenticationException arg2)
        throws IOException, ServletException {
    arg1.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");

}

From source file:com.erudika.para.security.SimpleAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    if (isRestRequest(request)) {
        RestUtils.returnStatusResponse(response, HttpServletResponse.SC_UNAUTHORIZED, exception.getMessage());
    } else {//from   ww w . j  a  v  a  2 s.  c o m
        super.onAuthenticationFailure(request, response, exception);
    }
}

From source file:org.awesomeagile.webapp.security.AwesomeAgileAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.addHeader("WWW-Authenticate", "AwesomeAgile");
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
}

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

/**
 * Always returns a 401 error code to the client.
 *//*from   w ww . java  2s .c o  m*/
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2)
        throws IOException, ServletException {

    log.debug("Pre-authenticated entry point called. Rejecting access");
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied");
}

From source file:de.hska.ld.core.config.security.AjaxAuthenticationFailureHandler.java

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

    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}