DefaultBearerTokenProvider implements BearerTokenProvider { @Override public void onBeforeCreate(AccessToken accessToken) { String tokenKey = generateTokenKey( _defaultBearerTokenProviderConfiguration.accessTokenKeyByteSize()); accessToken.setTokenKey(tokenKey); accessToken.setExpiresIn( _defaultBearerTokenProviderConfiguration.accessTokenExpiresIn()); }  @Override boolean isValid(AccessToken accessToken); @Override boolean isValid(RefreshToken refreshToken); @Override void onBeforeCreate(AccessToken accessToken); @Override void onBeforeCreate(RefreshToken refreshToken);  }
@Test public void testOnBeforeCreateAccessToken() { BearerTokenProvider.AccessToken accessToken = generateAccessToken(0, 0); _defaultBearerTokenProvider.onBeforeCreate(accessToken); Assert.assertEquals( accessToken.getExpiresIn(), _ACCESS_TOKEN_EXPIRES_IN); Assert.assertEquals( _TOKEN_KEY_STRING_32_BYTES_HEX, accessToken.getTokenKey()); }
@Test public void testOnBeforeCreateRefreshToken() { BearerTokenProvider.RefreshToken refreshToken = generateRefreshToken( 0, 0); _defaultBearerTokenProvider.onBeforeCreate(refreshToken); Assert.assertEquals( refreshToken.getExpiresIn(), _REFRESH_TOKEN_EXPIRES_IN); Assert.assertEquals( _TOKEN_KEY_STRING_32_BYTES_HEX, refreshToken.getTokenKey()); }