public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { final Repository db = getRepository(request); asIs.access((HttpServletRequest) request, db); chain.doFilter(request, response); } catch (ServiceNotAuthorizedException e) { ((HttpServletResponse) response).sendError(SC_UNAUTHORIZED); } catch (ServiceNotEnabledException e) { ((HttpServletResponse) response).sendError(SC_FORBIDDEN); } } }
/** * Determine if access to any bare file of the repository is allowed. * <p> * This method silently succeeds if the request is allowed, or fails by * throwing a checked exception if access should be denied. * <p> * The default implementation of this method checks {@code http.getanyfile}, * throwing {@link ServiceNotEnabledException} if it was explicitly set to * {@code false}, and otherwise succeeding silently. * * @param req * current HTTP request, in case information from the request may * help determine the access request. * @param db * the repository the request would obtain a bare file from. * @throws ServiceNotEnabledException * bare file access is not allowed on the target repository, by * any user, for any reason. * @throws ServiceNotAuthorizedException * bare file access is not allowed for this HTTP request and * repository, such as due to a permission error. */ public void access(HttpServletRequest req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { if (!isEnabled(db)) throw new ServiceNotEnabledException(); } }
/** * Determine if access to any bare file of the repository is allowed. * <p> * This method silently succeeds if the request is allowed, or fails by * throwing a checked exception if access should be denied. * <p> * The default implementation of this method checks {@code http.getanyfile}, * throwing {@link ServiceNotEnabledException} if it was explicitly set to * {@code false}, and otherwise succeeding silently. * * @param req * current HTTP request, in case information from the request may * help determine the access request. * @param db * the repository the request would obtain a bare file from. * @throws ServiceNotEnabledException * bare file access is not allowed on the target repository, by * any user, for any reason. * @throws ServiceNotAuthorizedException * bare file access is not allowed for this HTTP request and * repository, such as due to a permission error. */ public void access(HttpServletRequest req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { if (!isEnabled(db)) throw new ServiceNotEnabledException(); } }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; try { final Repository db = getRepository(request); asIs.access(req, db); chain.doFilter(request, response); } catch (ServiceNotAuthorizedException e) { res.sendError(SC_UNAUTHORIZED, e.getMessage()); } catch (ServiceNotEnabledException e) { res.sendError(SC_FORBIDDEN, e.getMessage()); } } }