title: Using JdbcTokenStore for JWT
body: <p>for my REST API I am using JWT's for OAuth2 authorization. Currently I am extending <code>JwtTokenStore</code> to store the refresh tokens in memory so that I am able to revoke them.</p>
  
  <pre><code>// TODO: This is a temporary in memory solution that needs to be replaced with a concrete persistent implementation.
  public class MyJwtTokenStore extends JwtTokenStore {
  
      private List&lt;OAuth2RefreshToken&gt; refreshTokens;
  
      public MyJwtTokenStore(JwtAccessTokenConverter jwtTokenEnhancer) {
          super(jwtTokenEnhancer);
          refreshTokens = new ArrayList&lt;&gt;();
      }
  
      @Override
      public OAuth2RefreshToken readRefreshToken(String tokenValue) {
          OAuth2RefreshToken refreshToken = super.readRefreshToken(tokenValue);
          if (!refreshTokens.contains(refreshToken)) {
              throw new InvalidGrantException("Invalid refresh token: " + tokenValue);
          }
          return refreshToken;
      }
  
      @Override
      public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
          refreshTokens.add(refreshToken);
      }
  
      @Override
      public void removeRefreshToken(OAuth2RefreshToken token) {
          refreshTokens.remove(token);
      }
  }
  </code></pre>
  
  <p>I would like start storing these refresh tokens in a database rather than in memory. Spring provides us with <code>JdbcTokenStore</code>, but if I extend that class then I am unable to set a <code>JwtAccessTokenConverter</code> in the constructor. I know that I could just implement my own method of saving/retrieving the JWTs but I would like to take advantage of the out of the box support for the schema at <a href="https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql" rel="nofollow noreferrer">https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql</a> which the <code>JdbcTokenStore</code> provides.</p>
  
  <pre><code>create table oauth_refresh_token (
    token_id VARCHAR(256),
    token LONGVARBINARY,
    authentication LONGVARBINARY
  ); 
  </code></pre>
  
  <p>Does Spring support storing JWT in a data source? I need something like a "JwtJdbcTokenStore". What is a good way to go about doing this but still use the predefined queries and operations from <code>JdbcTokenStore</code>?</p>