use of org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore in project spring-security-oauth by spring-projects.
the class TokenServicesWithTokenEnhancerTests method storeEnhancedRefreshTokenDuringRefresh.
// gh-511
@Test
public void storeEnhancedRefreshTokenDuringRefresh() {
InMemoryTokenStore tokenStore = new InMemoryTokenStore();
tokenServices.setSupportRefreshToken(true);
tokenServices.setReuseRefreshToken(false);
tokenServices.setTokenStore(tokenStore);
OAuth2AccessToken accessToken = tokenServices.createAccessToken(authentication);
OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
TokenRequest tokenRequest = new TokenRequest(Collections.<String, String>emptyMap(), request.getClientId(), request.getScope(), "authorization_code");
accessToken = tokenServices.refreshAccessToken(refreshToken.getValue(), tokenRequest);
OAuth2RefreshToken enhancedRefreshToken = accessToken.getRefreshToken();
OAuth2RefreshToken storedEnhancedRefreshToken = tokenStore.readRefreshToken(enhancedRefreshToken.getValue());
assertEquals(enhancedRefreshToken.getValue(), storedEnhancedRefreshToken.getValue());
}
use of org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore in project spring-security-oauth by spring-projects.
the class AbstractIntegrationTests method clear.
private void clear(TokenStore tokenStore) throws Exception {
if (tokenStore instanceof Advised) {
Advised advised = (Advised) tokenStore;
TokenStore target = (TokenStore) advised.getTargetSource().getTarget();
clear(target);
return;
}
if (tokenStore instanceof InMemoryTokenStore) {
((InMemoryTokenStore) tokenStore).clear();
}
if (tokenStore instanceof JdbcTokenStore) {
JdbcTemplate template = new JdbcTemplate(dataSource);
template.execute("delete from oauth_access_token");
template.execute("delete from oauth_refresh_token");
template.execute("delete from oauth_client_token");
template.execute("delete from oauth_code");
}
}
use of org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore in project spring-cloud-framework by zhuwj921.
the class AuthorizationServerConfiguration method configure.
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
logger.debug("授权配置");
endpoints.authenticationManager(authenticationManager).userDetailsService(// 若无,refresh_token会有UserDetailsService is required错误
userDetailsService()).tokenStore(new InMemoryTokenStore());
}
Aggregations