com.fivefaces.structureclient.config.security.RestApiAuthenticationEntryPoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-structure-client Show documentation
Show all versions of common-structure-client Show documentation
structure Client for Five Faces
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");
}
}