/** * Sub-class constructor. * * @param tokenValue the token value * @param issuedAt the time at which the token was issued, may be null * @param expiresAt the expiration time on or after which the token MUST NOT be accepted, may be null */ protected AbstractOAuth2Token(String tokenValue, @Nullable Instant issuedAt, @Nullable Instant expiresAt) { Assert.hasText(tokenValue, "tokenValue cannot be empty"); if (issuedAt != null && expiresAt != null) { Assert.isTrue(expiresAt.isAfter(issuedAt), "expiresAt must be after issuedAt"); } this.tokenValue = tokenValue; this.issuedAt = issuedAt; this.expiresAt = expiresAt; }
private void cleanUp() { Instant now = Instant.now(); if (lastCleanup.plus(cleanupInterval).isAfter(now)) { return; } lastCleanup = now; for (Entry<String, NotificationFilter> entry : getNotificationFilters().entrySet()) { if (entry.getValue() instanceof ExpiringNotificationFilter && ((ExpiringNotificationFilter) entry.getValue()).isExpired()) { LOGGER.debug("Expired filter '{}' removed", entry); filters.remove(entry.getKey()); } } }
private boolean checkExpired(Instant currentTime) { return isStarted() && !this.maxIdleTime.isNegative() && currentTime.minus(this.maxIdleTime).isAfter(this.lastAccessTime); }
@SchemaModification(addField = "afterNow", onType = Timestamp.class) Boolean isAfterNow(Timestamp timestamp) { return Instant.ofEpochSecond(timestamp.getSeconds()).isAfter(Instant.now()); }
/** * Returns false, if the wait duration has not elapsed. * Returns true, if the wait duration has elapsed and transitions the state machine to HALF_OPEN state. * * @return false, if the wait duration has not elapsed. true, if the wait duration has elapsed. */ @Override boolean isCallPermitted() { // Thread-safe if (Instant.now().isAfter(retryAfterWaitDuration)) { stateMachine.transitionToHalfOpenState(); return true; } circuitBreakerMetrics.onCallNotPermitted(); return false; }
/** * Check for current state timeout and act upon it. */ void checkForTimeout() { final Duration actionTimeout = Duration.ofMinutes(config.actionTimeout()); final Instant now = Instant.now(); events.removeIf(event -> event.getType().isShouldTimeout() && now.isAfter(event.getUpdated().plus(actionTimeout))); } }
@Override public TrackingToken createTokenAt(Instant dateTime) { return events.values() .stream() .filter(event -> event.getTimestamp().equals(dateTime) || event.getTimestamp().isAfter(dateTime)) .min(Comparator.comparingLong(e -> ((GlobalSequenceTrackingToken) e.trackingToken()) .getGlobalIndex())) .map(TrackedEventMessage::trackingToken) .map(tt -> (GlobalSequenceTrackingToken) tt) .map(tt -> new GlobalSequenceTrackingToken(tt.getGlobalIndex() - 1)) .orElse(null); }
@Override public void validate(Jwt token, Errors.Collector collector) { token.expirationTime().ifPresent(it -> { if (earliest().isAfter(it)) { collector.fatal(token, "Token no longer valid, expiration: " + it); } }); } }
private boolean checkExpired(Instant currentTime) { return isStarted() && !this.maxIdleTime.isNegative() && currentTime.minus(this.maxIdleTime).isAfter(this.lastAccessTime); }
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; }
private Entry writeMessage(KCVSMessage msg) { StaticBuffer content = msg.getContent(); DataOutput out = manager.serializer.getDataOutput(8 + 8 + manager.senderId.length() + 2 + content.length()); Instant rawTimestamp = msg.getTimestamp(); Preconditions.checkArgument(rawTimestamp.isAfter(Instant.EPOCH)); out.putLong(times.getTime(rawTimestamp)); out.writeObjectNotNull(manager.senderId); out.putLong(numMsgCounter.incrementAndGet()); final int valuePos = out.getPosition(); out.putBytes(content); return new StaticArrayEntry(out.getStaticBuffer(),valuePos); }
@Override public final void read(Message message) { assertNotNull(message); assertNotNull(message.getSenderId()); assertNotNull(message.getContent()); Instant now = Instant.now(); assertTrue(now.isAfter(message.getTimestamp()) || now.equals(message.getTimestamp())); processMessage(message); latch.countDown(); }
private Entry writeMessage(KCVSMessage msg) { StaticBuffer content = msg.getContent(); DataOutput out = manager.serializer.getDataOutput(8 + 8 + manager.senderId.length() + 2 + content.length()); Instant rawTimestamp = msg.getTimestamp(); Preconditions.checkArgument(rawTimestamp.isAfter(Instant.EPOCH)); out.putLong(times.getTime(rawTimestamp)); out.writeObjectNotNull(manager.senderId); out.putLong(numMsgCounter.incrementAndGet()); final int valuePos = out.getPosition(); out.putBytes(content); return new StaticArrayEntry(out.getStaticBuffer(),valuePos); }
@Override public final void read(Message message) { assertNotNull(message); assertNotNull(message.getSenderId()); assertNotNull(message.getContent()); Instant now = Instant.now(); assertTrue(now.isAfter(message.getTimestamp()) || now.equals(message.getTimestamp())); processMessage(message); latch.countDown(); }
/** * Verifies that the actual {@code Instant} is before or equals to the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2007-12-03T10:15:30.00Z")).isBeforeOrEqualTo(parse("2007-12-03T10:15:30.00Z")) * .isBeforeOrEqualTo(parse("2007-12-03T10:15:31.00Z"));</code></pre> * * @param other the given {@link Instant}. * @return this assertion object. * @throws AssertionError if the actual {@code Instant} is {@code null}. * @throws IllegalArgumentException if other {@code Instant} is {@code null}. * @throws AssertionError if the actual {@code Instant} is not before or equals to the given one. * @since 3.7.0 */ public SELF isBeforeOrEqualTo(Instant other) { assertNotNull(info, actual); assertInstantParameterIsNotNull(other); if (actual.isAfter(other)) { throw Failures.instance().failure(info, shouldBeBeforeOrEqualsTo(actual, other)); } return myself; }
/** * Verifies that the actual {@code Instant} is <b>strictly</b> after the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2007-12-03T10:15:30.00Z").isAfter(parse("2007-12-03T10:15:27.00Z"));</code></pre> * * @param other the given {@link Instant}. * @return this assertion object. * @throws AssertionError if the actual {@code Instant} is {@code null}. * @throws IllegalArgumentException if other {@code Instant} is {@code null}. * @throws AssertionError if the actual {@code Instant} is not strictly after the given one. * @since 3.7.0 */ public SELF isAfter(Instant other) { assertNotNull(info, actual); assertInstantParameterIsNotNull(other); if (!actual.isAfter(other)) { throw Failures.instance().failure(info, shouldBeAfter(actual, other)); } return myself; }
@Override public void read(Message message) { Instant msgTime = message.getTimestamp(); assertTrue(msgTime.isAfter(startTime) || msgTime.equals(startTime)); assertNotNull(message.getSenderId()); StaticBuffer content = message.getContent(); assertTrue(content != null && content.length() > 0); TransactionLogHeader.Entry txentry = TransactionLogHeader.parse(content, serializer, times); Instant txTime = txentry.getHeader().getTimestamp(); assertTrue(txTime.isBefore(msgTime) || txTime.equals(msgTime)); assertTrue(txTime.isAfter(startTime) || txTime.equals(msgTime)); long txid = txentry.getHeader().getId(); assertTrue(txid > 0); for (TransactionLogHeader.Modification modification : txentry.getContentAsModifications(serializer)) { assertTrue(modification.state == Change.ADDED || modification.state == Change.REMOVED); userChangeCounter.get(modification.state).incrementAndGet(); } userLogMsgCounter.incrementAndGet(); } });
if (lastModified.isAfter(Instant.EPOCH) && getResponseHeaders().getLastModified() == -1) { getResponseHeaders().setLastModified(lastModified.toEpochMilli());
private void assertConditionalResponse(MockServerWebExchange exchange, HttpStatus status, String body, String etag, Instant lastModified) throws Exception { assertEquals(status, exchange.getResponse().getStatusCode()); if (body != null) { assertResponseBody(exchange, body); } else { assertResponseBodyIsEmpty(exchange); } if (etag != null) { assertEquals(1, exchange.getResponse().getHeaders().get(HttpHeaders.ETAG).size()); assertEquals(etag, exchange.getResponse().getHeaders().getETag()); } if (lastModified.isAfter(Instant.EPOCH)) { assertEquals(1, exchange.getResponse().getHeaders().get(HttpHeaders.LAST_MODIFIED).size()); assertEquals(lastModified.toEpochMilli(), exchange.getResponse().getHeaders().getLastModified()); } }