/** * Returns the token value. * * @return the token value */ public String getToken() { return get(TOKEN); }
/** * Returns {@code true} if the token is an access token, {@code false} otherwise. * * @return {@code true} if the token is an access token, {@code false} otherwise */ public boolean isAccessToken() { return TokenType.ACCESS == getTokenType(); }
private void putTokenSecret(String tokenSecret) { put(TOKEN_SECRET, tokenSecret); }
/** * Creates a new {@code TokenProperties} instance using the attributes of the {@code Token} as property values. */ public TokenProperties(Token token) { putToken(token.getToken()); putTokenSecret(token.getTokenSecret()); putTokenType(token.isAccessToken() ? TokenType.ACCESS : TokenType.REQUEST); putConsumerKey(token.getConsumer().getKey()); if (!token.getProperties().isEmpty()) { putProperties(token.getProperties()); } }
/** * Returns the token secret. * * @return the token secret */ public String getTokenSecret() { return get(TOKEN_SECRET); }
private void putToken(String token) { put(TOKEN, token); }
/** * Returns the key of the consumer this token was created for. * * @return the key of the consumer this token was created for */ public String getConsumerKey() { return get(CONSUMER_KEY); }
private void putConsumerKey(String consumerKey) { put(CONSUMER_KEY, consumerKey); }
private TokenType getTokenType() { return TokenType.valueOf(get(TYPE)); }
private void putTokenType(TokenType type) { put(TYPE, type != null ? type.name() : null); }
/** * Returns the properties associated with the token. * * @return the properties associated with the token */ public Map<String, String> getProperties() { String propStr = get(PROPERTIES); if (propStr == null) { return ImmutableMap.of(); } return Maps.fromProperties(PropertiesHelper.fromString(propStr)); }
private void putProperties(Map<String, String> properties) { put(PROPERTIES, PropertiesHelper.toString(PropertiesHelper.asProperties(properties))); }