/** * But pull access is open to anyone */ @Override public UploadPack createUploadPack(HttpServletRequest context, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { return new DefaultUploadPackFactory().create(context,db); }
public ServiceConfig parse(final Config cfg) { return new ServiceConfig(cfg); } };
public ServiceConfig parse(final Config cfg) { return new ServiceConfig(cfg); } };
public ServiceConfig parse(final Config cfg) { return new ServiceConfig(cfg); } };
private static ReceivePack createFor(final HttpServletRequest req, final Repository db, final String user) { final ReceivePack rp = new ReceivePack(db); rp.setRefLogIdent(toPersonIdent(req, user)); return rp; }
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(); } }
public ReceivePack create(final HttpServletRequest req, final Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { final ServiceConfig cfg = db.getConfig().get(CONFIG); String user = req.getRemoteUser(); if (cfg.set) { if (cfg.enabled) { if (user == null || "".equals(user)) user = "anonymous"; return createFor(req, db, user); } throw new ServiceNotEnabledException(); } if (user != null && !"".equals(user)) return createFor(req, db, user); throw new ServiceNotAuthorizedException(); }
static String getProject(HttpServletRequest req) throws ServiceNotEnabledException { String pc = (String) req.getAttribute(ATT_CONTROL); if (pc == null) { log.error("No " + ATT_CONTROL + " in request", new Exception("here")); throw new ServiceNotEnabledException(); } return pc; }
@Inject public GitReceivePackFactory(GitRepositoryHandler handler, HookEventFacade hookEventFacade) { this.handler = handler; this.hook = new GitReceiveHook(hookEventFacade, handler); this.wrapped = new DefaultReceivePackFactory(); }
public ServiceConfig parse(final Config cfg) { return new ServiceConfig(cfg); } };
public ServiceConfig parse(final Config cfg) { return new ServiceConfig(cfg); } };
public ServiceConfig parse(final Config cfg) { return new ServiceConfig(cfg); } };
private static ReceivePack createFor(final HttpServletRequest req, final Repository db, final String user) { final ReceivePack rp = new ReceivePack(db); rp.setRefLogIdent(toPersonIdent(req, user)); return rp; }
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()); } } }
/** * 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 ReceivePack create(final HttpServletRequest req, final Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { final ServiceConfig cfg = db.getConfig().get(CONFIG); String user = req.getRemoteUser(); if (cfg.set) { if (cfg.enabled) { if (user == null || "".equals(user)) user = "anonymous"; return createFor(req, db, user); } throw new ServiceNotEnabledException(); } if (user != null && !"".equals(user)) return createFor(req, db, user); throw new ServiceNotAuthorizedException(); }