Instant earliest() { return instant.minus(allowedTimeSkewAmount, allowedTimeSkewUnit); } }
private boolean checkExpired(Instant currentTime) { return isStarted() && !this.maxIdleTime.isNegative() && currentTime.minus(this.maxIdleTime).isAfter(this.lastAccessTime); }
private Instant gapTimeoutFrame() { return GenericEventMessage.clock.instant().minus(gapTimeout, ChronoUnit.MILLIS); }
private Instant gapTimeoutFrame() { return GenericEventMessage.clock.instant().minus(gapTimeout, ChronoUnit.MILLIS); }
protected Mono<Void> updateStatusForAllInstances() { log.debug("Updating status for all instances"); Instant expiryInstant = Instant.now().minus(statusLifetime); return Flux.fromIterable(lastQueried.entrySet()) .filter(e -> e.getValue().isBefore(expiryInstant)) .map(Map.Entry::getKey) .flatMap(this::updateStatus) .then(); }
private boolean checkExpired(Instant currentTime) { return isStarted() && !this.maxIdleTime.isNegative() && currentTime.minus(this.maxIdleTime).isAfter(this.lastAccessTime); }
public DateRange(String daterange) { if (StringUtils.isBlank(daterange) || daterange.equalsIgnoreCase("default")) { endTime = getInstant(); startTime = endTime.minus(1, ChronoUnit.DAYS); } else { String[] dates = daterange.split(","); startTime = parseInstant(dates[0]); endTime = parseInstant(dates[1]); } }
private boolean hasTokenExpired(OAuth2AuthorizedClient authorizedClient) { Instant now = this.clock.instant(); Instant expiresAt = authorizedClient.getAccessToken().getExpiresAt(); if (now.isAfter(expiresAt.minus(this.accessTokenExpiresSkew))) { return true; } return false; }
private boolean hasTokenExpired(OAuth2AuthorizedClient authorizedClient) { Instant now = this.clock.instant(); Instant expiresAt = authorizedClient.getAccessToken().getExpiresAt(); if (now.isAfter(expiresAt.minus(this.accessTokenExpiresSkew))) { return true; } return false; }
boolean isExpired(Instant now) { if (this.maxInactiveInterval.isNegative()) { return false; } return now.minus(this.maxInactiveInterval).compareTo(this.lastAccessedTime) >= 0; }
@Override public void run(SourceContext<Email> ctx) throws Exception { // Sleep for 10 seconds on start to allow time to copy jobid Thread.sleep(10000L); int types = LabelSurrogate.Type.values().length; while (isRunning) { int r = random.nextInt(100); final EmailId emailId = new EmailId(Integer.toString(random.nextInt())); final Instant timestamp = Instant.now().minus(Duration.ofDays(1L)); final String foo = String.format("foo #%d", r); final LabelSurrogate label = new LabelSurrogate(LabelSurrogate.Type.values()[r % types], "bar"); synchronized (ctx.getCheckpointLock()) { ctx.collect(new Email(emailId, timestamp, foo, label)); } Thread.sleep(30L); } }
private void update(Jwt.Builder builder) { Instant now = Instant.now(); Instant exp = now.plus(validitySeconds, ChronoUnit.SECONDS); Instant notBefore = now.minus(notBeforeSeconds, ChronoUnit.SECONDS); builder.issueTime(now) .expirationTime(exp) .notBefore(notBefore) .keyId(jwtKid) .audience(jwtAudience); }
private void update(Jwt.Builder builder) { Instant now = Instant.now(); Instant exp = now.plus(validitySeconds, ChronoUnit.SECONDS); Instant notBefore = now.minus(notBeforeSeconds, ChronoUnit.SECONDS); builder.issueTime(now) .expirationTime(exp) .notBefore(notBefore) .keyId(jwtKid) .audience(jwtAudience); } }
@Test public void validateWhenExpiredAnd60secClockSkewThenNoErrors() { this.issuedAt = Instant.now().minus(Duration.ofSeconds(60)); this.expiresAt = this.issuedAt.plus(Duration.ofSeconds(30)); this.clockSkew = Duration.ofSeconds(60); assertThat(this.validateIdToken()).isEmpty(); }
@Test public void validateWhenExpiredAnd0secClockSkewThenHasErrors() { this.issuedAt = Instant.now().minus(Duration.ofSeconds(60)); this.expiresAt = this.issuedAt.plus(Duration.ofSeconds(30)); this.clockSkew = Duration.ofSeconds(0); assertThat(this.validateIdToken()) .hasSize(1) .extracting(OAuth2Error::getDescription) .allMatch(msg -> msg.contains(IdTokenClaimNames.EXP)); }
@Test public void validateWhenExpiresAtBeforeNowThenHasErrors() { this.issuedAt = Instant.now().minus(Duration.ofSeconds(10)); this.expiresAt = this.issuedAt.plus(Duration.ofSeconds(5)); this.clockSkew = Duration.ofSeconds(0); assertThat(this.validateIdToken()) .hasSize(1) .extracting(OAuth2Error::getDescription) .allMatch(msg -> msg.contains(IdTokenClaimNames.EXP)); }
@Test public void findByIdWhenExpiredRemovesFromSessionMap() { this.session.setMaxInactiveInterval(Duration.ofMinutes(1)); this.session.setLastAccessedTime(Instant.now().minus(5, ChronoUnit.MINUTES)); Map<String, Session> sessions = new ConcurrentHashMap<>(); sessions.put("session-id", this.session); this.repository = new ReactiveMapSessionRepository(sessions); assertThat(this.repository.findById(this.session.getId()).block()).isNull(); assertThat(sessions).isEmpty(); }
@Test public void testHaltingPredicateHonorsTimeRange() { // verify that halting predicate does nothing and changes no state if the // document's timestamp is outside of the time range. AtomicBoolean thisReaderNearEnd = new AtomicBoolean(false); AtomicBoolean otherReaderNearEnd = new AtomicBoolean(false); Duration duration = Duration.ofMinutes(5); ParallelHaltingPredicate parallelHaltingPredicate = new ParallelHaltingPredicate(thisReaderNearEnd, otherReaderNearEnd, duration); boolean testResult = parallelHaltingPredicate.accepts(createSourceRecordWithTimestamp(Instant.now().minus(duration.multipliedBy(2)))); Assert.assertTrue(testResult); Assert.assertFalse(thisReaderNearEnd.get()); Assert.assertFalse(otherReaderNearEnd.get()); }
@Test public void getSessionExpired() { this.session.setMaxInactiveInterval(Duration.ofSeconds(1)); this.session.setLastAccessedTime(Instant.now().minus(5, ChronoUnit.MINUTES)); this.repository.save(this.session); assertThat(this.repository.findById(this.session.getId())).isNull(); }
@Test public void getSessionExpired() { String expiredId = "expired-id"; given(this.redisOperations.boundHashOps(getKey(expiredId))) .willReturn(this.boundHashOperations); Map map = map(RedisOperationsSessionRepository.MAX_INACTIVE_ATTR, 1, RedisOperationsSessionRepository.LAST_ACCESSED_ATTR, Instant.now().minus(5, ChronoUnit.MINUTES).toEpochMilli()); given(this.boundHashOperations.entries()).willReturn(map); assertThat(this.redisRepository.findById(expiredId)).isNull(); }