class PathAuthorizationFilter implements ContainerRequestFilter {

    private static final Logger logger = LoggerFactory.getLogger(PathAuthorizationFilter.class);

    private static final RuntimeEnvironment env = RuntimeEnvironment.getInstance();

    public static final String PATH_PARAM = "path";

    @Context
    private HttpServletRequest request;

    private static boolean isPathAuthorized(String path, HttpServletRequest request) {<FILL_FUNCTION_BODY>}

    @Override
    public void filter(final ContainerRequestContext context) {
        if (request == null) { // happens in tests
            return;
        }

        String path = request.getParameter(PATH_PARAM);
        if (path == null || path.isEmpty()) {
            logger.log(Level.WARNING, "request does not contain \"{0}\" parameter: {1}",
                    new Object[]{PATH_PARAM, request});
            // This should align with whatever NoPathExceptionMapper does.
            // We cannot throw the exception here as it would not match the filter() signature.
            context.abortWith(Response.status(Response.Status.NOT_ACCEPTABLE).build());
            return;
        }

        if (!isPathAuthorized(path, request)) {
            // TODO: this should probably update statistics for denied requests like in AuthorizationFilter
            context.abortWith(Response.status(Response.Status.FORBIDDEN).build());
        }
    }
}

        if (request != null) {
            AuthorizationFramework auth = env.getAuthorizationFramework();
            if (auth != null) {
                Project p = Project.getProject(path.startsWith("/") ? path : "/" + path);
                return p == null || auth.isAllowed(request, p);
            }
        }

        return false;
    
<no_super_class>