private void putProperties(Map<String, String> properties) { put(PROPERTIES, PropertiesHelper.toString(PropertiesHelper.asProperties(properties))); }
/** * 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 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)); }
/** * Returns the token value. * * @return the token value */ public String getToken() { return get(TOKEN); }
private void putTokenSecret(String tokenSecret) { put(TOKEN_SECRET, tokenSecret); }
public Object remove(final String key) { return pluginSettings.remove(hashKeyIfTooLong(key)); } }
/** * 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 String hashKeyIfTooLong(final String key) { if (key.length() > MAX_KEY_LENGTH) { final String keyHash = DigestUtils.md5Hex(key); final String keptOriginalKey = key.substring(0, MAX_KEY_LENGTH - keyHash.length()); LOG.debug("Key '" + key + "' exceeds " + MAX_KEY_LENGTH + " characters. Key length is: '" + key.length() + "'. Hashed key value is: '" + keyHash + "'. Using combined original key and hash value '" + keptOriginalKey + keyHash + " as the key."); final String hashedKey = keptOriginalKey + keyHash; migrateKey(key, hashedKey); return hashedKey; } return key; }
/** * Returns the token secret. * * @return the token secret */ public String getTokenSecret() { return get(TOKEN_SECRET); }
private void putToken(String token) { put(TOKEN, token); }
public Object put(final String key, final Object value) { return pluginSettings.put(hashKeyIfTooLong(key), value); }
/** * 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); }
public Object get(final String key) { return pluginSettings.get(hashKeyIfTooLong(key)); }