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

The following examples show how to use org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices. 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 File: OAuth2SecurityConfiguration.java    From spring-cloud-shop with 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 #2
Source File: LessStrictRedirectUriAuthorizationCodeTokenGranter.java    From osiam with MIT License 5 votes vote down vote up
public LessStrictRedirectUriAuthorizationCodeTokenGranter(
        AuthorizationServerTokenServices tokenServices,
        AuthorizationCodeServices authorizationCodeServices,
        ClientDetailsService clientDetailsService,
        OAuth2RequestFactory requestFactory
) {
    super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
    this.authorizationCodeServices = authorizationCodeServices;
}
 
Example #3
Source File: OAuthPublicKeyTestConfiguration.java    From edison-microservice with Apache License 2.0 5 votes vote down vote up
@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 #4
Source File: SecurityConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Primary
@Bean
public AuthorizationServerTokenServices tokenServices()
{
    DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore( new JdbcTokenStore( dataSource ) );
    defaultTokenServices.setSupportRefreshToken( true );
    return defaultTokenServices;
}
 
Example #5
Source File: OAuth2Config.java    From microservice-integration with 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 #6
Source File: OAuth2Config.java    From Auth-service with 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 #7
Source File: CustomResourceOwnerPasswordTokenGranter.java    From spring-auth-example with MIT License 5 votes vote down vote up
protected CustomResourceOwnerPasswordTokenGranter(
    AuthenticationManager authenticationManager,
    AuthorizationServerTokenServices tokenServices,
    ClientDetailsService clientDetailsService,
    OAuth2RequestFactory requestFactory, String grantType) {
  super(tokenServices, clientDetailsService, requestFactory, grantType);
  this.authenticationManager = authenticationManager;
}
 
Example #8
Source File: CustomResourceOwnerPasswordTokenGranter.java    From spring-auth-example with MIT License 5 votes vote down vote up
public CustomResourceOwnerPasswordTokenGranter(
    AuthenticationManager authenticationManager,
    AuthorizationServerTokenServices tokenServices,
    ClientDetailsService clientDetailsService,
    OAuth2RequestFactory requestFactory) {
  this(authenticationManager, tokenServices, clientDetailsService,
      requestFactory, GRANT_TYPE);
}
 
Example #9
Source File: OAuth2Configuration.java    From OAuth-2.0-Cookbook with 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 #10
Source File: AuthorizationServerTokenServicesConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(AuthorizationServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}
 
Example #11
Source File: OAuth2Configuration.java    From oauth2lab with 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 #12
Source File: AcOAuth2Configuration.java    From cola with 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 #13
Source File: WxLoginConfig.java    From spring-microservice-exam with 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 #14
Source File: MobileLoginConfig.java    From spring-microservice-exam with 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 #15
Source File: TokenConfig.java    From mall4j with 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 #16
Source File: OpenIdOAuth2Configuration.java    From cola with 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 #17
Source File: SmsOAuth2Configuration.java    From cola with 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 #18
Source File: CustomAuthCodeTokenGranter.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
protected CustomAuthCodeTokenGranter(AuthorizationServerTokenServices tokenServices, AuthorizationCodeServices authorizationCodeServices,
                                        ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
    super(tokenServices, clientDetailsService, requestFactory, grantType);
    this.authorizationCodeServices = authorizationCodeServices;
}
 
Example #19
Source File: SmsTokenGranter.java    From cola with 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 #20
Source File: MobileTokenGranter.java    From SpringCloud with Apache License 2.0 4 votes vote down vote up
public MobileTokenGranter(AuthenticationManager authenticationManager,
                          AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService,
                          OAuth2RequestFactory requestFactory) {
    super(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
    this.authenticationManager = authenticationManager;
}
 
Example #21
Source File: OAuth2Config.java    From spring-cloud-gray with 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 #22
Source File: MobileCodeTokenGranter.java    From springcloud-oauth2 with 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 #23
Source File: MobileCodeTokenGranter.java    From springcloud-oauth2 with 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 #24
Source File: OAuth2Config.java    From spring-cloud-gray with 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 File: OpenIdTokenGranter.java    From cola with 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 #26
Source File: AcTokenGranter.java    From cola with 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 #27
Source File: CustomAuthCodeTokenGranter.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
public CustomAuthCodeTokenGranter(AuthorizationServerTokenServices tokenServices,
                                     AuthorizationCodeServices authorizationCodeServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
    this(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory, GRANT_TYPE);
}
 
Example #28
Source File: AuthorizationServerTokenServicesConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(AuthorizationServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}
 
Example #29
Source File: DefaultTokenGranter.java    From spring-cloud-gray with 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 #30
Source File: PhonePasswordTokenGranter.java    From spring-cloud-shop with 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;
}