com.mycompany.licit.custom.RESTAuthenticationEntryPoint.java Source code

Java tutorial

Introduction

Here is the source code for com.mycompany.licit.custom.RESTAuthenticationEntryPoint.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.licit.custom;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

/**
 *
 * @author simone
 */
@Component
public class RESTAuthenticationEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest hsr, HttpServletResponse hsr1, AuthenticationException ae)
            throws IOException, ServletException {
        hsr1.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }

}