@Override protected long currentTimeMsec() { return clock.currentTimeMillis(); } }
@Override protected long currentTimeMsec() { return clock.currentTimeMillis(); } }
@Override protected long currentTimeMsec() { return clock.currentTimeMillis(); } }
/** * @return Consolidated ttl in milliseconds or -1. */ public long getCacheTtl() { long expiration = getCacheExpiration(); if (expiration != -1) { return expiration - getTimeSource().currentTimeMillis(); } return -1; }
/** * @return Consolidated ttl in milliseconds or -1. */ public long getCacheTtl() { long expiration = getCacheExpiration(); if (expiration != -1) { return expiration - getTimeSource().currentTimeMillis(); } return -1; }
/** * @return Consolidated ttl in milliseconds or -1. */ public long getCacheTtl() { long expiration = getCacheExpiration(); if (expiration != -1) { return expiration - getTimeSource().currentTimeMillis(); } return -1; }
/** * Compute and set the expiration time for this token using the provided TTL. * * @param tokenTTL the time to live (in seconds) of the token * @return This security token. */ protected AbstractSecurityToken setExpires(int tokenTTL) { this.tokenTTL = tokenTTL; return setExpiresAt((getTimeSource().currentTimeMillis() / 1000) + getMaxTokenTTL()); }
public AbstractSecurityToken enforceNotExpired() throws BlobExpiredException { Long expiresAt = getExpiresAt(); if (expiresAt != null) { long maxTime = expiresAt + CLOCK_SKEW_ALLOWANCE; long now = getTimeSource().currentTimeMillis() / 1000; if (!(now < maxTime)) { throw new BlobExpiredException(now, maxTime); } } return this; }
public void approveToken() { // Waiting for the consumer to claim the token state = State.APPROVED_UNCLAIMED; issued = clock.currentTimeMillis(); if (callbackUrl != null) { verifier = Crypto.getRandomString(8); } }
/** * Compute and set the expiration time for this token using the provided TTL. * * @param tokenTTL the time to live (in seconds) of the token * @return This security token. */ protected AbstractSecurityToken setExpires(int tokenTTL) { this.tokenTTL = tokenTTL; return setExpiresAt((getTimeSource().currentTimeMillis() / 1000) + getMaxTokenTTL()); }
public AbstractSecurityToken enforceNotExpired() throws BlobExpiredException { Long expiresAt = getExpiresAt(); if (expiresAt != null) { long maxTime = expiresAt + CLOCK_SKEW_ALLOWANCE; long now = getTimeSource().currentTimeMillis() / 1000; if (!(now < maxTime)) { throw new BlobExpiredException(now, maxTime); } } return this; }
public void approveToken() { // Waiting for the consumer to claim the token state = State.APPROVED_UNCLAIMED; issued = clock.currentTimeMillis(); if (callbackUrl != null) { verifier = Crypto.getRandomString(8); } }
public void approveToken() { // Waiting for the consumer to claim the token state = State.APPROVED_UNCLAIMED; issued = clock.currentTimeMillis(); if (callbackUrl != null) { verifier = Crypto.getRandomString(8); } }
private boolean accessTokenExpired() { return (accessorInfo.getTokenExpireMillis() != ACCESS_TOKEN_EXPIRE_UNKNOWN && accessorInfo.getTokenExpireMillis() < fetcherConfig.getClock().currentTimeMillis()); }
public boolean shouldRefetch() { // Time after which resource should be refetched. long refetchExpiration = isStrictNoCache() ? date + getRefetchStrictNoCacheAfterMs() : getCacheExpiration(); return refetchExpiration <= getTimeSource().currentTimeMillis(); }
protected Long getProxyExpireMs(ProxyUri proxyUri, @Nullable HttpResponse httpResponse) { if (httpResponse != null) { return httpResponse.getCacheExpiration(); } else if (proxyUri.getRefresh() != null) { return timeSource.currentTimeMillis() + proxyUri.getRefresh() * 1000; } return getDefaultExpiration(); }
@Test public void testShouldRefetchForStrictNoCacheResponsePastShouldNotRefetch() throws Exception { assertEquals(false, new HttpResponseBuilder().setStrictNoCache() .setHeader("Date", DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 5000)) .setRefetchStrictNoCacheAfterMs(10000) .create() .shouldRefetch()); }
@Test public void testShouldRefetchForStrictNoCacheResponsePastShouldNotRefetch() throws Exception { assertEquals(false, new HttpResponseBuilder().setStrictNoCache() .setHeader("Date", DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 5000)) .setRefetchStrictNoCacheAfterMs(10000) .create() .shouldRefetch()); }
@Test public void testShouldRefetchForStrictNoCacheResponsePastShouldRefetch() throws Exception { assertEquals(true, new HttpResponseBuilder().setStrictNoCache() .setHeader("Date", DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 20000)) .setRefetchStrictNoCacheAfterMs(10000) .create() .shouldRefetch()); }
@Test public void testShouldRefetchForStrictNoCacheResponsePastShouldRefetch() throws Exception { assertEquals(true, new HttpResponseBuilder().setStrictNoCache() .setHeader("Date", DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 20000)) .setRefetchStrictNoCacheAfterMs(10000) .create() .shouldRefetch()); }