All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fivefaces.structureclient.config.security.RestApiAuthenticationEntryPoint Maven / Gradle / Ivy

There is a newer version: 1.0.62
Show newest version
package com.fivefaces.structureclient.config.security;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component("restApiAuthenticationEntryPoint")
@RequiredArgsConstructor
@Slf4j
public final class RestApiAuthenticationEntryPoint implements AuthenticationEntryPoint {

    private final JsonErrorResponseSender responseSender;

    @Override
    public void commence(final HttpServletRequest request, final HttpServletResponse response,
                         final AuthenticationException authException) throws IOException {
        log.debug("TP Api Authentication failure: {}", authException.getMessage());
        responseSender.sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized access");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy