Java Code Examples for org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices

The following examples show how to use org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-microservice-exam   Source File: WxLoginConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 微信登录成功后的处理
 *
 * @return AuthenticationSuccessHandler
 */
@Bean
public AuthenticationSuccessHandler wxLoginSuccessHandler(PasswordEncoder encoder, ClientDetailsService clientDetailsService, ObjectMapper objectMapper,
                                                          AuthorizationServerTokenServices defaultAuthorizationServerTokenServices) {
    return WxLoginSuccessHandler.builder()
            .objectMapper(objectMapper)
            .clientDetailsService(clientDetailsService)
            .passwordEncoder(encoder)
            .defaultAuthorizationServerTokenServices(defaultAuthorizationServerTokenServices).build();
}
 
Example 2
Source Project: spring-microservice-exam   Source File: MobileLoginConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 手机登录成功后的处理
 *
 * @return AuthenticationSuccessHandler
 */
@Bean
public AuthenticationSuccessHandler mobileLoginSuccessHandler(PasswordEncoder encoder, ClientDetailsService clientDetailsService, ObjectMapper objectMapper,
                                                              AuthorizationServerTokenServices defaultAuthorizationServerTokenServices) {
    return MobileLoginSuccessHandler.builder()
            .objectMapper(objectMapper)
            .clientDetailsService(clientDetailsService)
            .passwordEncoder(encoder)
            .defaultAuthorizationServerTokenServices(defaultAuthorizationServerTokenServices).build();
}
 
Example 3
Source Project: mall4j   Source File: TokenConfig.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Primary
@Bean
@Lazy
public AuthorizationServerTokenServices yamiTokenServices() {
    YamiTokenServices tokenServices = new YamiTokenServices();
    tokenServices.setTokenStore(tokenStore());
    //支持刷新token
    tokenServices.setSupportRefreshToken(true);
    tokenServices.setReuseRefreshToken(true);
    tokenServices.setTokenEnhancer(tokenEnhancer);
    addUserDetailsService(tokenServices);
    return tokenServices;
}
 
Example 4
Source Project: cola   Source File: OpenIdOAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
@ConditionalOnBean({AuthenticationManager.class, AuthorizationServerTokenServices.class, ClientDetailsService.class})
public OpenIdTokenGranter openIdTokenGranter(AuthenticationManager authenticationManager,
											 AuthorizationServerTokenServices tokenServices,
											 ClientDetailsService clientDetailsService) {
	return new OpenIdTokenGranter(authenticationManager, tokenServices, clientDetailsService, new DefaultOAuth2RequestFactory(clientDetailsService));
}
 
Example 5
Source Project: cola   Source File: AcOAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
@ConditionalOnBean({AuthenticationManager.class, AuthorizationServerTokenServices.class, ClientDetailsService.class})
public AcTokenGranter acTokenGranter(AuthenticationManager authenticationManager,
									 AuthorizationServerTokenServices tokenServices,
									 ClientDetailsService clientDetailsService) {
	return new AcTokenGranter(authenticationManager, tokenServices, clientDetailsService, new DefaultOAuth2RequestFactory(clientDetailsService));
}
 
Example 6
Source Project: cola   Source File: SmsOAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
@ConditionalOnBean({AuthenticationManager.class, AuthorizationServerTokenServices.class, ClientDetailsService.class})
public SmsTokenGranter smsTokenGranter(AuthenticationManager authenticationManager,
									   AuthorizationServerTokenServices tokenServices,
									   ClientDetailsService clientDetailsService) {
	return new SmsTokenGranter(authenticationManager, tokenServices, clientDetailsService, new DefaultOAuth2RequestFactory(clientDetailsService));
}
 
Example 7
Source Project: oauth2lab   Source File: OAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenGranter tokenGranter() {

    DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService());

    AuthorizationCodeServices codeServices = authorizationCodeServices();

    AuthorizationServerTokenServices tokenServices = tokenServices();
    List<TokenGranter> tokenGranters = Arrays.asList(
            new AuthorizationCodeTokenGranter(tokenServices, codeServices, clientDetailsService(), requestFactory),
            new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService(), requestFactory),
            new ImplicitTokenGranter(tokenServices, clientDetailsService(), requestFactory));

    return new CompositeTokenGranter(tokenGranters);
}
 
Example 8
Source Project: spring-cloud-shop   Source File: OAuth2SecurityConfiguration.java    License: MIT License 5 votes vote down vote up
private List<TokenGranter> getTokenGranters(AuthorizationCodeServices authorizationCodeServices,
                                            AuthorizationServerTokenServices tokenServices,
                                            ClientDetailsService clientDetailsService,
                                            OAuth2RequestFactory requestFactory) {
    return Stream.of(
            new ClientCredentialsTokenGranter(tokenServices, clientDetailsService, requestFactory),
            new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService, requestFactory),
            new PhonePasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService, requestFactory),
            new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory),
            new SmsTokenGranter(userServiceImpl, tokenServices, clientDetailsService, requestFactory))
            .collect(Collectors.toList());
}
 
Example 9
@Bean
@ConditionalOnMissingBean(AuthorizationServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}
 
Example 10
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenGranter tokenGranter() {

    DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService());

    AuthorizationCodeServices codeServices = authorizationCodeServices();

    AuthorizationServerTokenServices tokenServices = tokenServices();
    List<TokenGranter> tokenGranters = Arrays.asList(
            new CustomAuthCodeTokenGranter(tokenServices, codeServices, clientDetailsService(), requestFactory),
            new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService(), requestFactory),
            new ImplicitTokenGranter(tokenServices, clientDetailsService(), requestFactory));

    return new CompositeTokenGranter(tokenGranters);
}
 
Example 11
public CustomResourceOwnerPasswordTokenGranter(
    AuthenticationManager authenticationManager,
    AuthorizationServerTokenServices tokenServices,
    ClientDetailsService clientDetailsService,
    OAuth2RequestFactory requestFactory) {
  this(authenticationManager, tokenServices, clientDetailsService,
      requestFactory, GRANT_TYPE);
}
 
Example 12
protected CustomResourceOwnerPasswordTokenGranter(
    AuthenticationManager authenticationManager,
    AuthorizationServerTokenServices tokenServices,
    ClientDetailsService clientDetailsService,
    OAuth2RequestFactory requestFactory, String grantType) {
  super(tokenServices, clientDetailsService, requestFactory, grantType);
  this.authenticationManager = authenticationManager;
}
 
Example 13
Source Project: Auth-service   Source File: OAuth2Config.java    License: MIT License 5 votes vote down vote up
@Bean
public AuthorizationServerTokenServices authorizationServerTokenServices() {
    CustomAuthorizationTokenServices customTokenServices = new CustomAuthorizationTokenServices();
    customTokenServices.setTokenStore(tokenStore(redisConnectionFactory));
    customTokenServices.setSupportRefreshToken(true);
    customTokenServices.setReuseRefreshToken(false);
    customTokenServices.setClientDetailsService(clientDetailsService());
    customTokenServices.setTokenEnhancer(accessTokenConverter());
    return customTokenServices;
}
 
Example 14
Source Project: microservice-integration   Source File: OAuth2Config.java    License: MIT License 5 votes vote down vote up
@Bean
public AuthorizationServerTokenServices authorizationServerTokenServices() {
    CustomAuthorizationTokenServices customTokenServices = new CustomAuthorizationTokenServices();
    customTokenServices.setTokenStore(tokenStore(dataSource));
    customTokenServices.setSupportRefreshToken(true);
    customTokenServices.setReuseRefreshToken(true);
    customTokenServices.setClientDetailsService(jdbcClientDetailsService(dataSource));
    customTokenServices.setTokenEnhancer(accessTokenConverter());
    return customTokenServices;
}
 
Example 15
@Primary
@Bean
public AuthorizationServerTokenServices tokenServices()
{
    DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore( new JdbcTokenStore( dataSource ) );
    defaultTokenServices.setSupportRefreshToken( true );
    return defaultTokenServices;
}
 
Example 16
@Bean
@Profile("test")
public AuthorizationServerTokenServices testAuthorizationServerTokenServices(final KeyExchangeJwtAccessTokenConverter keyExchangeJwtAccessTokenConverter,
                                                                             final KeyPair keyPair) {
    final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    keyExchangeJwtAccessTokenConverter.setKeyPair(keyPair);
    defaultTokenServices.setTokenStore(new JwtTokenStore(keyExchangeJwtAccessTokenConverter));
    return defaultTokenServices;
}
 
Example 17
public LessStrictRedirectUriAuthorizationCodeTokenGranter(
        AuthorizationServerTokenServices tokenServices,
        AuthorizationCodeServices authorizationCodeServices,
        ClientDetailsService clientDetailsService,
        OAuth2RequestFactory requestFactory
) {
    super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
    this.authorizationCodeServices = authorizationCodeServices;
}
 
Example 18
Source Project: springcloud-oauth2   Source File: MobileCodeTokenGranter.java    License: MIT License 4 votes vote down vote up
public MobileCodeTokenGranter(AuthenticationManager authenticationManager,
                              AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
    this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
}
 
Example 19
Source Project: springcloud-oauth2   Source File: MobileCodeTokenGranter.java    License: MIT License 4 votes vote down vote up
private MobileCodeTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
                               ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
    super(tokenServices, clientDetailsService, requestFactory, grantType);
    this.authenticationManager = authenticationManager;
}
 
Example 20
Source Project: cola   Source File: OpenIdTokenGranter.java    License: MIT License 4 votes vote down vote up
public OpenIdTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
	super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
	this.authenticationManager = authenticationManager;
}
 
Example 21
Source Project: cola   Source File: AcTokenGranter.java    License: MIT License 4 votes vote down vote up
public AcTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
	super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
	this.authenticationManager = authenticationManager;
}
 
Example 22
Source Project: cola   Source File: SmsTokenGranter.java    License: MIT License 4 votes vote down vote up
public SmsTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
	super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
	this.authenticationManager = authenticationManager;
}
 
Example 23
Source Project: spring-cloud-gray   Source File: OAuth2Config.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public RefreshTokenGranter refreshTokenGranter(AuthorizationServerTokenServices tokenServices,
                                               ClientDetailsService clientDetailsService,
                                               OAuth2RequestFactory requestFactory) {
    return new RefreshTokenGranter(tokenServices, clientDetailsService, requestFactory);
}
 
Example 24
Source Project: spring-cloud-gray   Source File: OAuth2Config.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public DefaultTokenGranter defaultTokenGranter(AuthorizationServerTokenServices tokenServices,
                                               ClientDetailsService clientDetailsService,
                                               OAuth2RequestFactory requestFactory) {
    return new DefaultTokenGranter(tokenServices, clientDetailsService, requestFactory);
}
 
Example 25
Source Project: spring-cloud-gray   Source File: DefaultTokenGranter.java    License: Apache License 2.0 4 votes vote down vote up
public DefaultTokenGranter(
        AuthorizationServerTokenServices tokenServices,
        ClientDetailsService clientDetailsService,
        OAuth2RequestFactory requestFactory) {
    super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
}
 
Example 26
Source Project: spring-cloud-shop   Source File: SmsTokenGranter.java    License: MIT License 4 votes vote down vote up
public SmsTokenGranter(UserServiceImpl userService, AuthorizationServerTokenServices tokenServices,
                       ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
    this(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
    this.userService = userService;
}
 
Example 27
Source Project: spring-cloud-shop   Source File: SmsTokenGranter.java    License: MIT License 4 votes vote down vote up
protected SmsTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService,
                          OAuth2RequestFactory requestFactory, String grantType) {
    super(tokenServices, clientDetailsService, requestFactory, grantType);
    this.requestFactory = requestFactory;
}
 
Example 28
Source Project: spring-cloud-shop   Source File: PhonePasswordTokenGranter.java    License: MIT License 4 votes vote down vote up
public PhonePasswordTokenGranter(AuthenticationManager authenticationManager,
                                 AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
    this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
}
 
Example 29
Source Project: spring-cloud-shop   Source File: PhonePasswordTokenGranter.java    License: MIT License 4 votes vote down vote up
protected PhonePasswordTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
                                    ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
    super(tokenServices, clientDetailsService, requestFactory, grantType);
    this.authenticationManager = authenticationManager;
}
 
Example 30
@Bean
@ConditionalOnMissingBean(AuthorizationServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}