DefaultBearerTokenProvider implements BearerTokenProvider { @Override public boolean isValid(AccessToken accessToken) { return isValid(accessToken.getExpiresIn(), accessToken.getIssuedAt()); }  @Override boolean isValid(AccessToken accessToken); @Override boolean isValid(RefreshToken refreshToken); @Override void onBeforeCreate(AccessToken accessToken); @Override void onBeforeCreate(RefreshToken refreshToken);  }
@Test public void testIsValidAccessToken() { long issuedAtNow = System.currentTimeMillis() / 1000; Assert.assertTrue( _defaultBearerTokenProvider.isValid( generateAccessToken(_ACCESS_TOKEN_EXPIRES_IN, issuedAtNow))); Assert.assertFalse( _defaultBearerTokenProvider.isValid( generateAccessToken(-1, issuedAtNow))); Assert.assertFalse( _defaultBearerTokenProvider.isValid( generateAccessToken( _ACCESS_TOKEN_EXPIRES_IN, issuedAtNow - (_ACCESS_TOKEN_EXPIRES_IN + 1)))); Assert.assertFalse( _defaultBearerTokenProvider.isValid( generateAccessToken( _ACCESS_TOKEN_EXPIRES_IN, issuedAtNow + _ACCESS_TOKEN_EXPIRES_IN))); }
@Test public void testIsValidRefreshToken() { long issuedAtNow = System.currentTimeMillis() / 1000; Assert.assertTrue( _defaultBearerTokenProvider.isValid( generateRefreshToken(_REFRESH_TOKEN_EXPIRES_IN, issuedAtNow))); Assert.assertFalse( _defaultBearerTokenProvider.isValid( generateRefreshToken(-1, issuedAtNow))); Assert.assertFalse( _defaultBearerTokenProvider.isValid( generateRefreshToken( _REFRESH_TOKEN_EXPIRES_IN, issuedAtNow - (_REFRESH_TOKEN_EXPIRES_IN + 1)))); Assert.assertFalse( _defaultBearerTokenProvider.isValid( generateRefreshToken( _REFRESH_TOKEN_EXPIRES_IN, issuedAtNow + _REFRESH_TOKEN_EXPIRES_IN))); }