/** * The token string. */ public String getToken() { return token.getToken(); }
private Session newSession(ServiceProviderToken token) { Session.Builder builder = Session.newSession(randomizer.randomAlphanumericString(32)); if (token.getSession() != null) { builder.creationTime(token.getSession().getCreationTime()); } return builder.build(); } }
public ServiceProviderToken get(String token) throws StoreException { try { return store.get(token); } catch (InvalidTokenException e) { store.removeAndNotify(token); throw e; } }
public ServiceProviderToken generateRequestToken(Consumer consumer, @Nullable URI callback, OAuthMessage message, Version version) { checkNotNull(consumer, "consumer"); String token = randomizer.randomAlphanumericString(32); String secret = randomizer.randomAlphanumericString(32); return ServiceProviderToken.newRequestToken(token) .tokenSecret(secret) .consumer(consumer) .callback(callback) .version(version) .properties(propertiesFactory.newRequestTokenProperties(Requests.fromOAuthMessage(message))) .build(); }
private void redirectBackToConsumer(HttpServletRequest request, HttpServletResponse response, ServiceProviderToken token) throws IOException { if (V_1_0_A.equals(token.getVersion())) { redirectBackToConsumerVersion1a(request, response, token); } else { redirectBackToConsumerVersion1(request, response, token); } }
/** * The human-readable name of the consumer application. */ public String getConsumerName() { if (token.hasProperty("alternate.consumer.name")) { return token.getProperty("alternate.consumer.name"); } return token.getConsumer().getName(); }
/** * 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)); } }
/** * Additional descriptive text about the consumer application. */ public String getDescription() { return token.getConsumer().getDescription(); }
public void removeByConsumer(String consumerKey) { store.removeByConsumer(consumerKey); } }
public ServiceProviderToken put(ServiceProviderToken token) throws StoreException { return store.put(token); }
/** * The date/time that the token was created. */ public Date getCreationTime() { return new Date(token.getCreationTime()); }
public Iterable<ServiceProviderToken> getAccessTokensForUser(String username) { return store.getAccessTokensForUser(username); }
public void removeAndNotify(String token) throws StoreException { store.removeAndNotify(token); }
public Object doInTransaction() { return store.get(tokenStr); } });
public final void render() throws IOException { renderer.render(token, request, writer); } }
public boolean apply(ConsumerInformationRenderer renderer) { return renderer.canRender(token, request); } }
public void removeExpiredSessionsAndNotify() throws StoreException { store.removeExpiredSessionsAndNotify(); }
public void removeExpiredTokensAndNotify() throws StoreException { store.removeExpiredTokensAndNotify(); }
/** * Create a new {@link com.atlassian.oauth.serviceprovider.ServiceProviderToken.Session} for the given {@code token} * * @param token the {@link com.atlassian.oauth.serviceprovider.ServiceProviderToken} to create the session for * @return the new {@link com.atlassian.oauth.serviceprovider.ServiceProviderToken.Session} */ private ServiceProviderToken.Session newSession(ServiceProviderToken token) { ServiceProviderToken.Session.Builder builder = ServiceProviderToken.Session.newSession(RandomStringUtils.randomAlphanumeric(32)); if (token.getSession() != null) { builder.creationTime(token.getSession().getCreationTime()); } return builder.build(); }
private Iterable<TokenRepresentation> getTokenRepresentations(String username) { return transform(store.getAccessTokensForUser(username), toTokenRepresentation); }