29 lines
942 B
Java
29 lines
942 B
Java
|
package stirling.software.SPDF.config;
|
||
|
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.stereotype.Component;
|
||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||
|
|
||
|
import jakarta.servlet.http.HttpServletRequest;
|
||
|
import jakarta.servlet.http.HttpServletResponse;
|
||
|
|
||
|
@Component
|
||
|
public class EndpointInterceptor implements HandlerInterceptor {
|
||
|
|
||
|
@Autowired
|
||
|
private EndpointConfiguration endpointConfiguration;
|
||
|
|
||
|
@Override
|
||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||
|
throws Exception {
|
||
|
String requestURI = request.getRequestURI();
|
||
|
System.out.println("trying " + requestURI);
|
||
|
if (!endpointConfiguration.isEndpointEnabled(requestURI)) {
|
||
|
response.sendError(HttpServletResponse.SC_FORBIDDEN, "This endpoint is disabled");
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|