UserTokenGranter extends AbstractTokenGranter { protected DefaultOAuth2AccessToken prepareForSerialization(DefaultOAuth2AccessToken token) { String id = token.getValue(); token.setValue(null); token.getAdditionalInformation().put(ClaimConstants.JTI, token.getRefreshToken().getValue()); tokenStore.delete(id, 0, IdentityZoneHolder.get().getId()); return token; } UserTokenGranter(AuthorizationServerTokenServices tokenServices,
                            MultitenantClientServices clientDetailsService,
                            OAuth2RequestFactory requestFactory,
                            RevocableTokenProvisioning tokenStore); @Override OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest);  }
@Test public void ensure_that_access_token_is_deleted_and_modified() { String tokenId = "access_token"; DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(tokenId); DefaultOAuth2RefreshToken refreshToken = new DefaultOAuth2RefreshToken("refresh_token"); Map<String,Object> info = new HashMap(token.getAdditionalInformation()); info.put(JTI, token.getValue()); token.setAdditionalInformation(info); token.setRefreshToken(refreshToken); token.setExpiration(new Date()); DefaultOAuth2AccessToken result = granter.prepareForSerialization(token); assertSame(token, result); assertEquals(refreshToken.getValue(), result.getAdditionalInformation().get(JTI)); assertNull(result.getValue()); verify(tokenStore).delete(eq(tokenId), anyInt(), eq(IdentityZoneHolder.get().getId())); }