use of org.springframework.security.oauth2.provider.token.TokenEnhancer in project FP-PSP-SERVER by FundacionParaguaya.
the class AuthServerOAuth2Config method defaultTokenServices.
@Bean
@Primary
public DefaultTokenServices defaultTokenServices() {
final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setTokenEnhancer(tokenEnhancer());
defaultTokenServices.setSupportRefreshToken(true);
defaultTokenServices.setClientDetailsService(clientDetailsService());
return defaultTokenServices;
}
use of org.springframework.security.oauth2.provider.token.TokenEnhancer in project flytecnologia-api by jullierme.
the class FlyAutorizationServerConfig method configure.
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain();
tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer(), jwtAccessTokenConverter));
endpoints.tokenStore(tokenStore()).tokenEnhancer(tokenEnhancerChain).authenticationManager(authenticationManager).accessTokenConverter(jwtAccessTokenConverter).reuseRefreshTokens(false);
/* endpoints
.tokenStore(tokenStore())
.accessTokenConverter(jwtAccessTokenConverter)
.reuseRefreshTokens(false)
.authenticationManager(authenticationManager);*/
}
use of org.springframework.security.oauth2.provider.token.TokenEnhancer in project spring-security-oauth by spring-projects.
the class AuthorizationServerEndpointsConfigurer method createDefaultTokenServices.
private DefaultTokenServices createDefaultTokenServices() {
DefaultTokenServices tokenServices = new DefaultTokenServices();
tokenServices.setTokenStore(tokenStore());
tokenServices.setSupportRefreshToken(true);
tokenServices.setReuseRefreshToken(reuseRefreshToken);
tokenServices.setClientDetailsService(clientDetailsService());
tokenServices.setTokenEnhancer(tokenEnhancer());
addUserDetailsService(tokenServices, this.userDetailsService);
return tokenServices;
}
use of org.springframework.security.oauth2.provider.token.TokenEnhancer in project spring-security-oauth by spring-projects.
the class AbstractPersistentDefaultTokenServicesTests method testRefreshedTokenIsEnhanced.
@Test
public void testRefreshedTokenIsEnhanced() throws Exception {
getTokenServices().setTokenEnhancer(new TokenEnhancer() {
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
result.setValue("I'mEnhanced");
return result;
}
});
OAuth2AccessToken accessToken = getTokenServices().createAccessToken(createAuthentication());
assertTrue(accessToken.getValue().startsWith("I'mEnhanced"));
TokenRequest tokenRequest = new TokenRequest(Collections.singletonMap("client_id", "id"), "id", null, null);
OAuth2AccessToken refreshedAccessToken = getTokenServices().refreshAccessToken(accessToken.getRefreshToken().getValue(), tokenRequest);
assertTrue(refreshedAccessToken.getValue().startsWith("I'mEnhanced"));
}
use of org.springframework.security.oauth2.provider.token.TokenEnhancer in project mots by motech-implementations.
the class TokenConfiguration method tokenServices.
/**
* Set-up CustomTokenServices with tokenStore().
* @return token services
*/
@Bean
@Primary
public CustomTokenServices tokenServices() {
TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain();
tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer(), accessTokenConverter()));
CustomTokenServices customTokenServices = new CustomTokenServices();
customTokenServices.setTokenStore(tokenStore());
customTokenServices.setTokenEnhancer(tokenEnhancerChain);
customTokenServices.setClientDetailsService(clientDetailsService);
customTokenServices.setSupportRefreshToken(true);
customTokenServices.setAccessTokenValiditySeconds(tokenValiditySeconds);
customTokenServices.setRefreshTokenValiditySeconds(tokenValiditySeconds * 2);
customTokenServices.setReuseRefreshToken(false);
return customTokenServices;
}
Aggregations