/** * The number of days until the token expires, rounded down to an integer. */ public int getDaysTillExpiration() { long millisTillExpiration = (token.getCreationTime() + token.getTimeToLive()) - System.currentTimeMillis(); if (millisTillExpiration < 0) { millisTillExpiration = 0; } return (int) (millisTillExpiration / (1000 * 60 * 60 * 24)); } }
/** * The date/time at which the token will expire. */ public Date getExpirationTime() { return new Date(token.getCreationTime() + token.getTimeToLive()); }
public static Matcher<? super ServiceProviderToken> equalTo(ServiceProviderToken token) { // Hamcrest's is/equalTo matcher uses Object.equals so Consumer and Session properties // need to be explicitly checked Consumer consumer = token.getConsumer(); Matcher<?> consumerMatcher = consumer == null ? nullValue() : samePropertyValuesAs(consumer); ServiceProviderToken.Session session = token.getSession(); Matcher<?> sessionMatcher = session == null ? nullValue() : samePropertyValuesAs(session); return allOf(hasProperty("consumer", consumerMatcher), hasProperty("session", sessionMatcher), hasProperty("authorization", is(token.getAuthorization())), hasProperty("callback", is(token.getCallback())), hasProperty("creationTime", is(token.getCreationTime())), hasProperty("timeToLive", is(token.getTimeToLive())), hasProperty("user", is(token.getUser())), hasProperty("verifier", is(token.getVerifier())), hasProperty("version", is(token.getVersion())), hasProperty("properties", is(token.getProperties())), hasProperty("token", is(token.getToken())), hasProperty("tokenSecret", is(token.getTokenSecret()))); }
LOG.debug(String.format("3-Legged-OAuth token rejected. Token has expired. Token creation time [%d] time to live [%d] clock (contains logging delay) [%d]", token.getCreationTime(), token.getTimeToLive(), clock.timeInMilliseconds()));
OAUTH_TOKEN, accessToken.getToken(), OAUTH_TOKEN_SECRET, accessToken.getTokenSecret(), OAUTH_EXPIRES_IN, Long.toString(accessToken.getTimeToLive() / 1000), OAUTH_SESSION_HANDLE, accessToken.getSession().getHandle(), OAUTH_AUTHORIZATION_EXPIRES_IN, Long.toString(accessToken.getSession().getTimeToLive() / 1000)
OAuth.OAUTH_TOKEN, accessToken.getToken(), OAuth.OAUTH_TOKEN_SECRET, accessToken.getTokenSecret(), Request.OAUTH_EXPIRES_IN, Long.toString(accessToken.getTimeToLive() / 1000), Request.OAUTH_SESSION_HANDLE, accessToken.getSession().getHandle(), Request.OAUTH_AUTHORIZATION_EXPIRES_IN, Long.toString(accessToken.getSession().getTimeToLive() / 1000)