@Override public String cookie(String name) { return delegate.cookie(name); } }
/** * Checks user cookies and seee if he is allowed to login * * @return ok, if he is allowed to see what he's trying to see */ public boolean checkSession(Request req, Response res) { try { Settings useAuth = get(Settings.USE_AUTH); if (useAuth != null && useAuth.getValue().equalsIgnoreCase("1")) { logger.info("Auth requested, checking if everything is alright;"); //checking cookie first if (req.cookies().containsKey(AUTH_KEY)) { return checkPassword(req.cookie(AUTH_KEY)); } else if (req.session().attribute(AUTH_KEY) != null) { return checkPassword(req.session().attribute(AUTH_KEY)); } else { res.removeCookie(AUTH_KEY); req.session().removeAttribute(AUTH_KEY); return false; } } return true; } catch (Exception e) { return false; } }
public String update(Request request, Response response) { String fromCookie = request.cookie(COOKIE_NAME); final Long userId = currentUserId(request); if (!Objects.equals(pipelineSelectionsService.load(fromCookie, userId).etag(), getIfMatch(request))) { throw HaltApiResponses.haltBecauseEtagDoesNotMatch(DATA_IS_OUT_OF_DATE); } Filters filters; try { filters = Filters.fromJson(request.body()); } catch (FilterValidationException | JsonParseException e) { throw HaltApiResponses.haltBecauseOfReason(e.getMessage()); } Long recordId = pipelineSelectionsService.save(fromCookie, userId, filters); if (!apiAuthenticationHelper.securityEnabled()) { response.cookie("/go", COOKIE_NAME, String.valueOf(recordId), ONE_YEAR, systemEnvironment.isSessionCookieSecure(), true); } response.status(OK); return format("{ \"contentHash\": \"%s\" }", pipelineSelectionsService.load(fromCookie, userId).etag()); }
public String show(Request request, Response response) { String fromCookie = request.cookie(COOKIE_NAME); PipelineSelections pipelineSelections = pipelineSelectionsService.load(fromCookie, currentUserId(request)); if (fresh(request, pipelineSelections.etag())) { return notModified(response); } setEtagHeader(response, pipelineSelections.etag()); PipelineSelectionResponse pipelineSelectionResponse = new PipelineSelectionResponse(pipelineSelections.viewFilters()); return PipelineSelectionsRepresenter.toJSON(pipelineSelectionResponse); }
public Object index(Request request, Response response) throws IOException { if (!goDashboardService.hasEverLoadedCurrentState()) { response.status(ACCEPTED); return BEING_PROCESSED; } final String personalizationCookie = request.cookie(COOKIE_NAME); final Long userId = currentUserId(request); final Username userName = currentUsername(); final PipelineSelections personalization = pipelineSelectionsService.load(personalizationCookie, userId); final DashboardFilter filter = personalization.namedFilter(getViewName(request)); List<GoDashboardPipelineGroup> pipelineGroups = goDashboardService.allPipelineGroupsForDashboard(filter, userName); List<GoDashboardEnvironment> environments = goDashboardService.allEnvironmentsForDashboard(filter, userName); String etag = calcEtag(userName, pipelineGroups, environments); if (fresh(request, etag)) { return notModified(response); } setEtagHeader(response, etag); return writerForTopLevelObject(request, response, outputWriter -> DashboardRepresenter.toJSON( outputWriter, new DashboardFor(pipelineGroups, environments, userName, personalization.etag()) ) ); }
public Object index(Request request, Response response) throws IOException { if (!goDashboardService.hasEverLoadedCurrentState()) { response.status(ACCEPTED); return BEING_PROCESSED; } final String personalizationCookie = request.cookie(COOKIE_NAME); final Long userId = currentUserId(request); final Username userName = currentUsername(); final PipelineSelections personalization = pipelineSelectionsService.load(personalizationCookie, userId); final DashboardFilter filter = personalization.namedFilter(getViewName(request)); List<GoDashboardPipelineGroup> pipelineGroups = goDashboardService.allPipelineGroupsForDashboard(filter, userName); List<GoDashboardEnvironment> environments = goDashboardService.allEnvironmentsForDashboard(filter, userName); String etag = calcEtag(userName, pipelineGroups, environments); if (fresh(request, etag)) { return notModified(response); } setEtagHeader(response, etag); return writerForTopLevelObject(request, response, outputWriter -> DashboardRepresenter.toJSON( outputWriter, new DashboardFor(pipelineGroups, environments, userName, personalization.etag()) ) ); }
@Override public String cookie(String name) { return delegate.cookie(name); } }
@Override public String cookie(String name) { return delegate.cookie(name); } }