private static Map<String, String> getParameters(HttpServletRequest req) { final Map<String, String> params = new HashMap<>(); for (final String pair : req.getQueryString().split("[&;]")) { final int eq = pair.indexOf('='); if (0 < eq) { String name = pair.substring(0, eq); String value = pair.substring(eq + 1); name = Url.decode(name); value = Url.decode(value); params.put(name, value); } } return params; }
private void authenticateAndRedirect(HttpServletRequest req, HttpServletResponse rsp) throws IOException { AuthRequest areq = new AuthRequest(user.getExternalId()); AuthResult arsp; try { String claimedIdentifier = user.getClaimedIdentity(); if (!Strings.isNullOrEmpty(claimedIdentifier)) { if (!authenticateWithIdentityClaimedDuringHandshake(areq, rsp, claimedIdentifier)) { return; } } else if (linkMode) { if (!authenticateWithLinkedIdentity(areq, rsp)) { return; } } areq.setUserName(user.getUserName()); areq.setEmailAddress(user.getEmailAddress()); areq.setDisplayName(user.getDisplayName()); arsp = accountManager.authenticate(areq); } catch (AccountException e) { log.error("Unable to authenticate user \"" + user + "\"", e); rsp.sendError(HttpServletResponse.SC_FORBIDDEN); return; } webSession.get().login(arsp, true); String suffix = redirectToken.substring(OAuthWebFilter.GERRIT_LOGIN.length() + 1); StringBuilder rdr = new StringBuilder(urlProvider.get(req)); rdr.append(Url.decode(suffix)); rsp.sendRedirect(rdr.toString()); }
@Override public boolean updateChange(ChangeContext ctx) throws ResourceNotFoundException, OrmException { PatchSet ps = psUtil.get(ctx.getDb(), ctx.getNotes(), psId); if (ps == null) { throw new ResourceNotFoundException("patch set not found: " + psId); } comment = new Comment( new Comment.Key(ChangeUtil.messageUUID(ctx.getDb()), in.path, ps.getPatchSetId()), ctx.getAccountId(), ctx.getWhen(), in.side(), in.message.trim(), serverId); comment.parentUuid = Url.decode(in.inReplyTo); comment.setLineNbrAndRange(in.line, in.range); comment.tag = in.tag; setCommentRevId(comment, patchListCache, ctx.getChange(), ps); commentsUtil.putComments( ctx.getDb(), ctx.getUpdate(psId), Status.DRAFT, Collections.singleton(comment)); ctx.bumpLastUpdatedOn(false); return true; }