use of org.springframework.security.oauth2.common.util.JsonParser in project spring-security-oauth by spring-projects.
the class DefaultTokenServicesWithJwtTests method testDoubleRefresh.
@Test
public void testDoubleRefresh() throws Exception {
JsonParser parser = JsonParserFactory.create();
OAuth2Authentication authentication = createAuthentication();
OAuth2AccessToken initialToken = getTokenServices().createAccessToken(authentication);
TokenRequest tokenRequest = new TokenRequest(Collections.singletonMap("client_id", "id"), "id", null, null);
OAuth2AccessToken refreshedAccessToken = getTokenServices().refreshAccessToken(initialToken.getRefreshToken().getValue(), tokenRequest);
refreshedAccessToken = getTokenServices().refreshAccessToken(refreshedAccessToken.getRefreshToken().getValue(), tokenRequest);
Map<String, ?> accessTokenInfo = parser.parseMap(JwtHelper.decode(refreshedAccessToken.getValue()).getClaims());
Map<String, ?> refreshTokenInfo = parser.parseMap(JwtHelper.decode(refreshedAccessToken.getRefreshToken().getValue()).getClaims());
assertEquals("Access token ID does not match refresh token ATI", accessTokenInfo.get(AccessTokenConverter.JTI), refreshTokenInfo.get(AccessTokenConverter.ATI));
}
Aggregations