/** * This hack must be done because date precision is millisecond in db/es and date format is select only */ private static Date fixDate(Date date) { return DateUtils.addSeconds(date, 1); }
private Optional<Token> validateToken(String tokenEncoded, HttpServletRequest request, HttpServletResponse response) { Optional<Claims> claims = jwtSerializer.decode(tokenEncoded); if (!claims.isPresent()) { return Optional.empty(); } Date now = new Date(system2.now()); Claims token = claims.get(); if (now.after(addSeconds(token.getIssuedAt(), SESSION_DISCONNECT_IN_SECONDS))) { return Optional.empty(); } jwtCsrfVerifier.verifyState(request, (String) token.get(CSRF_JWT_PARAM), token.getSubject()); if (now.after(addSeconds(getLastRefreshDate(token), SESSION_REFRESH_IN_SECONDS))) { refreshToken(token, request, response); } Optional<UserDto> user = selectUserFromUuid(token.getSubject()); if (!user.isPresent()) { return Optional.empty(); } return Optional.of(new Token(user.get(), claims.get())); }
@Override public Void call() { LOG.info("{} start...", dataSourceInfo.getUrl()); stop = false; String name = Thread.currentThread().getName(); try { Thread.currentThread().setName(dataSourceInfo.getUrl()); long begin = System.currentTimeMillis(); while ((!isStop() && !timeout(begin))) { Date since = DateUtils.addSeconds(new Date(), -DEFAULT_TIME_INTEL); List<MsgQueue> errorMessages = messageClientStore.findErrorMsg(this.dataSource, since); if (errorMessages == null || errorMessages.isEmpty()) { break; } logRemainMsg(errorMessages); processErrorMessages(errorMessages, since); } } catch (Exception e) { throw new RuntimeException("process message error, url: " + dataSourceInfo.getUrl(), e); } finally { stop = true; Thread.currentThread().setName(name); LOG.info("{} finish", dataSourceInfo.getUrl()); } return null; }
/** * This hack must be done because date precision is millisecond in db/es and date format is select only */ private static Date fixDate(Date date) { return DateUtils.addSeconds(date, 1); }
/** * This hack must be done because date precision is millisecond in db/es and date format is select only */ private Date fixDate(Date date) { return DateUtils.addSeconds(date, 1); }
private Date addOneUnit(Date lowerDate) { return DateUtils.addSeconds(lowerDate,1); }
public static Date getFutureDate(Date date, int seconds) { return DateUtils.addSeconds(date, seconds); }
private static Date getImmediateScheduleStartDate() { return DateUtils.addSeconds(new Date(), 10); }
public void setExpirationTime(String key, long expiresInSeconds) { Date expirationTime = DateUtils.addSeconds(new Date(), (int) expiresInSeconds); expirationTimes.put(key.toString(), expirationTime); }
/** * Build a random {@link Date} with an year either side of today. For example * <p/> * <code> * Date aRandomBirthday = RandomBuilder.aRandomDate(); * </code> * * @return a random {@link Date} with an year either side of today. */ public static Date aRandomDate() { return addSeconds(new Date(), nextInt(SECONDS_IN_A_YEAR)); }
public Nonce(String nonceKey, String apiStr, boolean oneTime) { this.nonceKey = nonceKey; this.apiPath = apiStr; this.oneTime = oneTime; this.expires = DateUtils.addSeconds(new Date(), getOptionsParamApi().getNonceTimeToLiveInSecs()); }
public void setExpirationTime(String targetCache, String key, long expiresInSeconds) { Date expirationTime = DateUtils.addSeconds(new Date(), (int) expiresInSeconds); this.setExpirationTime(targetCache, key, expirationTime); }
public Date diff(Integer i) { return DateUtils.addSeconds(AbstractDateParamFilter.this.clock.current(), i.intValue()); }
@Override protected void run() { Date now = new Date(); Date nowPlusOneMinute = DateUtils.addSeconds(now, getCheckIntervalSeconds()); systemNotificationRepository.getFutureNotifications(nowPlusOneMinute, userRepository.getSystemUser()) .forEach(workQueueRepository::pushSystemNotification); }
public DateAssert isEqualTo(Date expected, int toleranceInSeconds) { Assertions.assertThat(actual).overridingErrorMessage("actual is null").isNotNull(); long right = DateUtils.addSeconds(actual, toleranceInSeconds).getTime(); long left = DateUtils.addSeconds(actual, -toleranceInSeconds).getTime(); Assertions.assertThat(actual.getTime()).overridingErrorMessage("actual date not in expected range : ("+left+","+right+")") .isGreaterThan(left).isLessThan(right); return this; }
@CheckForNull public Long calculateNewTechnicalDebt(Issue issue, @Nullable Date periodDate) { Long debt = ((DefaultIssue) issue).debtInMinutes(); Date periodDatePlusOneSecond = periodDate != null ? DateUtils.addSeconds(periodDate, 1) : null; if (isAfter(issue.creationDate(), periodDatePlusOneSecond)) { return debt; } else { return calculateNewTechnicalDebtValueFromChangelog(debt, issue, periodDate); } }
private int countIssues(Collection<Issue> issues, Period period) { // SONAR-3647 Use real snapshot date and not target date in order to stay consistent with other measure variations Date datePlusOneSecond = period.getDate() != null ? DateUtils.addSeconds(period.getDate(), 1) : null; return countIssuesAfterDate(issues, datePlusOneSecond); }
private Date getNextRunWithDelay(Date date, int countEmptyRuns) { //ignore milliseconds because MySQL does not support them, and it's not important for test return DateUtils.setMilliseconds(DateUtils.addSeconds(date, Math.min((int)(Math.pow(2., countEmptyRuns) * HistoryCleanupJobHandlerConfiguration.START_DELAY), HistoryCleanupJobHandlerConfiguration.MAX_DELAY)), 0); }
public void execute(DelegateExecution execution) throws Exception { Date currentTime = (Date)execution.getVariable("currentTime"); currentTime = DateUtils.addSeconds(currentTime, 1); ClockUtil.setCurrentTime(currentTime); execution.setVariable("currentTime", currentTime); }
@Test public void testSuccessfulLoginAfterFailureAndDelay() { User user = identityService.newUser("johndoe"); user.setPassword("xxx"); identityService.saveUser(user); Date now = null; now = ClockUtil.getCurrentTime(); assertFalse(identityService.checkPassword("johndoe", "invalid pwd")); ClockUtil.setCurrentTime(DateUtils.addSeconds(now, 30)); assertTrue(identityService.checkPassword("johndoe", "xxx")); identityService.deleteUser("johndoe"); }