com.fivefaces.structureclient.config.security.RestApiAccessDeniedHandler 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
The newest version!
package com.fivefaces.structureclient.config.security;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Slf4j
@RequiredArgsConstructor
@Component("restApiAccessDeniedHandler")
public class RestApiAccessDeniedHandler implements AccessDeniedHandler {
private final JsonErrorResponseSender responseSender;
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
log.debug("Access is denied: {}", accessDeniedException.getMessage());
responseSender.sendErrorResponse(response, HttpServletResponse.SC_FORBIDDEN, "Access is denied");
}
}