Java Code Examples for org.springframework.security.oauth2.provider.ClientDetailsService

The following examples show how to use org.springframework.security.oauth2.provider.ClientDetailsService. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Test
public void testDefaultConfiguration() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(AuthorizationAndResourceServerConfiguration.class, MinimalSecureWebApplication.class);
	this.context.refresh();
	this.context.getBean(AUTHORIZATION_SERVER_CONFIG);
	this.context.getBean(RESOURCE_SERVER_CONFIG);
	this.context.getBean(OAuth2MethodSecurityConfiguration.class);
	ClientDetails config = this.context.getBean(BaseClientDetails.class);
	AuthorizationEndpoint endpoint = this.context.getBean(AuthorizationEndpoint.class);
	UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils.getField(endpoint,
			"userApprovalHandler");
	ClientDetailsService clientDetailsService = this.context.getBean(ClientDetailsService.class);
	ClientDetails clientDetails = clientDetailsService.loadClientByClientId(config.getClientId());
	assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService)).isTrue();
	assertThat(AopUtils.getTargetClass(clientDetailsService).getName())
			.isEqualTo(InMemoryClientDetailsService.class.getName());
	assertThat(handler).isInstanceOf(ApprovalStoreUserApprovalHandler.class);
	assertThat(clientDetails).isEqualTo(config);
	verifyAuthentication(config);
	assertThat(this.context.getBeanNamesForType(OAuth2RestOperations.class)).isEmpty();
}
 
Example 2
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 3
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 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: syhthems-platform   Source File: JdbcClientDetailsServiceConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@Primary
public ClientDetailsService jdbcClientDetailsService() {
    JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
    clientDetailsService.setPasswordEncoder(passwordEncoder);
    return clientDetailsService;
}
 
Example 8
Source Project: Taroco   Source File: AuthorizationServerConfigration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 客户端管理
 */
@Bean
@Lazy
@Scope(proxyMode = ScopedProxyMode.INTERFACES)
public ClientDetailsService clientDetailsService() {
    return new CustomClientDetailsService(CacheConstants.REDIS_CLIENTS_PREFIX, dataSource, redisRepository, objectMapper);
}
 
Example 9
Source Project: spring-cloud-gray   Source File: OAuth2Config.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Oauth2Service oauth2Service(
        ClientDetailsService clientDetailsService,
        OAuth2RequestFactory requestFactory,
        DefaultTokenGranter defaultTokenGranter) {
    return new Oauth2Service(clientDetailsService, requestFactory, defaultTokenGranter);
}
 
Example 10
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 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
public LessStrictRedirectUriAuthorizationCodeTokenGranter(
        AuthorizationServerTokenServices tokenServices,
        AuthorizationCodeServices authorizationCodeServices,
        ClientDetailsService clientDetailsService,
        OAuth2RequestFactory requestFactory
) {
    super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
    this.authorizationCodeServices = authorizationCodeServices;
}
 
Example 14
public ClientAndUserDetailsService(ClientDetailsService clients,
		UserDetailsService users) {
	super();
	clients_ = clients;
	users_ = users;
	clientDetailsWrapper_ = new ClientDetailsUserDetailsService(clients_);
}
 
Example 15
@Bean
public ClientDetailsService clientDetails() {
    return new JdbcClientDetailsService(dataSource);
}
 
Example 16
@Bean
public ClientDetailsService jdbcClientDetailsService() {
    // 基于 JDBC 实现,需要事先在数据库配置客户端信息
    return new JdbcClientDetailsService(dataSource());
}
 
Example 17
Source Project: cloud-template   Source File: AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public ClientDetailsService clientDetailsService() {
    return new JdbcClientDetailsService(dataSource());
}
 
Example 18
@Bean
public ClientDetailsService jdbcClientDetails() {
    // 基于 JDBC 实现,需要事先在数据库配置客户端信息
    return new JdbcClientDetailsService(dataSource());
}
 
Example 19
@Bean
public ClientDetailsService clientDetails() {
    return new JdbcClientDetailsService(dataSource);
}
 
Example 20
public CustomOauth2RequestFactory(ClientDetailsService clientDetailsService) {
	super(clientDetailsService);
}
 
Example 21
Source Project: spring-cloud-gray   Source File: OAuth2Config.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public OAuth2RequestFactory requestFactory(ClientDetailsService clientDetailsService) {
    return new DefaultOAuth2RequestFactory(clientDetailsService);
}
 
Example 22
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 23
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 24
Source Project: oauth2lab   Source File: OAuth2Configuration.java    License: MIT License 4 votes vote down vote up
@Bean
public ClientDetailsService clientDetailsService() {
    return new JdbcClientDetailsService(dataSource);
}
 
Example 25
Source Project: java-tutorial   Source File: AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public ClientDetailsService clientDetails() {
    JdbcClientDetailsService jdbcClientDetailsService = new JdbcClientDetailsService(dataSource);
    jdbcClientDetailsService.setPasswordEncoder(new BCryptPasswordEncoder());
    return jdbcClientDetailsService;
}
 
Example 26
Source Project: spring-cloud-shop   Source File: OAuth2SecurityConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
public ClientDetailsService clientDetails() {
    return new JdbcClientDetailsService(dataSource);
}
 
Example 27
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 28
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 29
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 30
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;
}