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

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

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");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy