public OAuth2Authentication readAuthenticationForRefreshToken(String value) {
    OAuth2Authentication authentication = null;

    try {
      authentication =
          dynamoDBTemplate.get(
              schema.getRefreshTableName(),
              Collections.singletonMap(
                  schema.getRefreshColumnTokenId(), new AttributeValue(extractTokenKey(value))),
              new ObjectExtractor<OAuth2Authentication>() {

                public OAuth2Authentication extract(Map<String, AttributeValue> values) {
                  return deserializeAuthentication(
                      values.get(schema.getRefreshColumnAuthentication()).getB());
                }
              },
              schema.getRefreshColumnAuthentication());
    } catch (EmptyResultDataAccessException e) {
      if (LOG.isInfoEnabled()) {
        LOG.info("Failed to find refresh token for token " + value);
      }
    } catch (IllegalArgumentException e) {
      LOG.warn("Failed to deserialize authentication for " + value, e);
      removeRefreshToken(value);
    }

    return authentication;
  }
  public void storeRefreshToken(
      OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
    Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
    updates.put(
        schema.getRefreshColumnToken(),
        new AttributeValueUpdate(
            new AttributeValue().withB(serializeRefreshToken(refreshToken)), AttributeAction.PUT));
    updates.put(
        schema.getRefreshColumnAuthentication(),
        new AttributeValueUpdate(
            new AttributeValue().withB(serializeAuthentication(authentication)),
            AttributeAction.PUT));

    dynamoDBTemplate.update(
        schema.getRefreshTableName(), //
        Collections.singletonMap(
            schema.getRefreshColumnTokenId(),
            new AttributeValue(extractTokenKey(refreshToken.getValue()))), //
        updates);
  }
 public void removeRefreshToken(String token) {
   dynamoDBTemplate.delete(
       schema.getRefreshTableName(),
       Collections.singletonMap(
           schema.getRefreshColumnTokenId(), new AttributeValue(extractTokenKey(token))));
 }