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(); }
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()); } } }
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(); }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse rsp = (HttpServletResponse) response; UploadPack rp; try { rp = uploadPackFactory.create(req, getRepository(req)); } catch (ServiceNotAuthorizedException e) { rsp.sendError(SC_UNAUTHORIZED, e.getMessage()); return; } catch (ServiceNotEnabledException e) { sendError(req, rsp, SC_FORBIDDEN, e.getMessage()); return; } try { req.setAttribute(ATTRIBUTE_HANDLER, rp); chain.doFilter(req, rsp); } finally { req.removeAttribute(ATTRIBUTE_HANDLER); } }
public ReceivePack create(HttpServletRequest req, Repository repo) throws ServiceNotEnabledException, ServiceNotAuthorizedException { String user = userManager.getRemoteUsername(req); String pluginKey = repo.getWorkTree().getName(); UserProfile userProfile = userManager.getUserProfile(user); final UserExtension userExtension = speakeasyService.getRemotePlugin(pluginKey, user); if (userExtension != null && !userExtension.isCanEdit()) { throw new ServiceNotAuthorizedException(); } ReceiveCommits rc = new ReceiveCommits(userProfile, userExtension, repo, speakeasyService, gitRepositoryManager); return rc.getReceivePack(); } }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse rsp = (HttpServletResponse) response; ReceivePack rp; try { rp = receivePackFactory.create(req, getRepository(req)); } catch (ServiceNotAuthorizedException e) { rsp.sendError(SC_UNAUTHORIZED, e.getMessage()); return; } catch (ServiceNotEnabledException e) { sendError(req, rsp, SC_FORBIDDEN, e.getMessage()); return; } try { req.setAttribute(ATTRIBUTE_HANDLER, rp); chain.doFilter(req, rsp); } finally { req.removeAttribute(ATTRIBUTE_HANDLER); } }
throw new ServiceMayNotContinueException(e); } catch (ForbiddenException e) { throw new ServiceNotAuthorizedException(); } catch (GitUserException e) { throw new ServiceMayNotContinueException(e.getMessage(), e);
return; } catch (ServiceNotAuthorizedException e) { res.sendError(SC_UNAUTHORIZED, e.getMessage()); return; } catch (ServiceMayNotContinueException e) {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; if (svc.equals(req.getParameter("service"))) { final Repository db = getRepository(req); try { begin(req, db); } catch (ServiceNotAuthorizedException e) { res.sendError(SC_UNAUTHORIZED, e.getMessage()); return; } catch (ServiceNotEnabledException e) { sendError(req, res, SC_FORBIDDEN, e.getMessage()); return; } try { if (filters.length == 0) service(req, response); else new Chain().doFilter(request, response); } finally { req.removeAttribute(ATTRIBUTE_HANDLER); } } else { chain.doFilter(request, response); } }
private void service(ServletRequest request, ServletResponse response) throws IOException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; final SmartOutputStream buf = new SmartOutputStream(req, res, true); try { res.setContentType(infoRefsResultType(svc)); final PacketLineOut out = new PacketLineOut(buf); out.writeString("# service=" + svc + "\n"); out.end(); advertise(req, new PacketLineOutRefAdvertiser(out)); buf.close(); } catch (ServiceNotAuthorizedException e) { res.sendError(SC_UNAUTHORIZED, e.getMessage()); } catch (ServiceNotEnabledException e) { sendError(req, res, SC_FORBIDDEN, e.getMessage()); } catch (ServiceMayNotContinueException e) { if (e.isOutput()) buf.close(); else sendError(req, res, e.getStatusCode(), e.getMessage()); } }