use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class RefreshTokenSupportTests method verifyAccessTokens.
protected void verifyAccessTokens(OAuth2AccessToken oldAccessToken, OAuth2AccessToken newAccessToken) {
// make sure the new access token can be used.
verifyTokenResponse(newAccessToken.getValue(), HttpStatus.OK);
// the old access token is still valid because there is no state on the server.
verifyTokenResponse(oldAccessToken.getValue(), HttpStatus.OK);
JwtTokenStore store = (JwtTokenStore) ReflectionTestUtils.getField(services, "tokenStore");
OAuth2AccessToken token = store.readAccessToken(oldAccessToken.getValue());
OAuth2AccessToken refresh = ReflectionTestUtils.invokeMethod(store, "convertAccessToken", oldAccessToken.getRefreshToken().getValue());
assertEquals(refresh.getExpiration().getTime(), token.getExpiration().getTime() + 100000);
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class JwkTokenStoreTest method readAccessTokenWhenCalledThenDelegateCalled.
@Test
public void readAccessTokenWhenCalledThenDelegateCalled() throws Exception {
JwkTokenStore spy = spy(this.jwkTokenStore);
JwtTokenStore delegate = mock(JwtTokenStore.class);
when(delegate.readAccessToken(anyString())).thenReturn(null);
Field field = ReflectionUtils.findField(spy.getClass(), "delegate");
field.setAccessible(true);
ReflectionUtils.setField(field, spy, delegate);
spy.readAccessToken(anyString());
verify(delegate).readAccessToken(anyString());
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class JwkTokenStoreTest method readAuthenticationUsingAccessTokenStringWhenCalledThenDelegateCalled.
@Test
public void readAuthenticationUsingAccessTokenStringWhenCalledThenDelegateCalled() throws Exception {
JwkTokenStore spy = spy(this.jwkTokenStore);
JwtTokenStore delegate = mock(JwtTokenStore.class);
when(delegate.readAuthentication(anyString())).thenReturn(null);
Field field = ReflectionUtils.findField(spy.getClass(), "delegate");
field.setAccessible(true);
ReflectionUtils.setField(field, spy, delegate);
spy.readAuthentication(anyString());
verify(delegate).readAuthentication(anyString());
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class TokenServicesWithTokenEnhancerTests method init.
@Before
public void init() throws Exception {
tokenServices = new DefaultTokenServices();
tokenServices.setClientDetailsService(new InMemoryClientDetailsServiceBuilder().withClient("client").authorizedGrantTypes(new String[] { "authorization_code", "refresh_token" }).scopes("read").secret("secret").and().build());
enhancer.setTokenEnhancers(Arrays.<TokenEnhancer>asList(jwtTokenEnhancer));
jwtTokenEnhancer.afterPropertiesSet();
tokenServices.setTokenStore(new JwtTokenStore(jwtTokenEnhancer));
tokenServices.setTokenEnhancer(enhancer);
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class JwkTokenStoreTest method removeAccessTokenWhenCalledThenDelegateCalled.
@Test
public void removeAccessTokenWhenCalledThenDelegateCalled() throws Exception {
JwkTokenStore spy = spy(this.jwkTokenStore);
JwtTokenStore delegate = mock(JwtTokenStore.class);
doNothing().when(delegate).removeAccessToken(any(OAuth2AccessToken.class));
Field field = ReflectionUtils.findField(spy.getClass(), "delegate");
field.setAccessible(true);
ReflectionUtils.setField(field, spy, delegate);
spy.removeAccessToken(any(OAuth2AccessToken.class));
verify(delegate).removeAccessToken(any(OAuth2AccessToken.class));
}
Aggregations