Java Code Examples for org.springframework.security.authentication.ProviderManager

The following examples show how to use org.springframework.security.authentication.ProviderManager. 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: feast   Source File: SecurityConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes an AuthenticationManager if authentication has been enabled.
 *
 * @return AuthenticationManager
 */
@Bean
@ConditionalOnProperty(prefix = "feast.security.authentication", name = "enabled")
AuthenticationManager authenticationManager() {
  final List<AuthenticationProvider> providers = new ArrayList<>();

  if (securityProperties.getAuthentication().isEnabled()) {
    switch (securityProperties.getAuthentication().getProvider()) {
      case "jwt":
        providers.add(
            new DefaultJwtAuthenticationProvider(
                securityProperties.getAuthentication().getOptions()));
        break;
      default:
        throw new IllegalArgumentException(
            "Please configure an Authentication Provider if you have enabled authentication.");
    }
  }
  return new ProviderManager(providers);
}
 
Example 2
Source Project: nextreports-server   Source File: NextServerApplication.java    License: Apache License 2.0 6 votes vote down vote up
private void runUserSynchronizerJob() {
	if (LOG.isDebugEnabled()) {
		LOG.debug("Run user synchronizer job ...");
	}
	long t = System.currentTimeMillis();

	// JobDetail userSynchronizerJob = (JobDetail)
	// getSpringBean("userSynchronizerJob");
	ProviderManager authenticationManager = (ProviderManager) getSpringBean("authenticationManager");
	UserSynchronizerJob userSynchronizerJob = new UserSynchronizerJob();
	userSynchronizerJob.setAuthenticationManager(authenticationManager);
	userSynchronizerJob.setStorageService((StorageService) getSpringBean("storageService"));
	userSynchronizerJob.syncUsers();

	if (LOG.isDebugEnabled()) {
		t = System.currentTimeMillis() - t;
		LOG.debug("Users synchronized in " + t + " ms");
	}
}
 
Example 3
Source Project: oauth-server   Source File: AuthorizationServerConfig.java    License: Apache License 2.0 5 votes vote down vote up
private void addUserDetailsService(CustomTokenService tokenServices, UserDetailsService userDetailsService) {
    if (userDetailsService != null) {
        PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
        provider.setPreAuthenticatedUserDetailsService(new UserDetailsByNameServiceWrapper<>(
                userDetailsService));
        tokenServices.setAuthenticationManager(new ProviderManager(Arrays.asList(provider)));
    }
}
 
Example 4
Source Project: grpc-spring-boot-starter   Source File: SecurityConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
/*
 * Add the authentication providers to the manager.
 */
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(jwtAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example 5
Source Project: grpc-spring-boot-starter   Source File: SecurityConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
// Add the authentication providers to the manager.
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(daoAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example 6
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(daoAuthenticationProvider());
    // providers.add(anonymousAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example 7
Source Project: grpc-spring-boot-starter   Source File: SecurityConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
/*
 * Add the authentication providers to the manager.
 */
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(jwtAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example 8
Source Project: grpc-spring-boot-starter   Source File: SecurityConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
// Add the authentication providers to the manager.
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(daoAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example 9
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(daoAuthenticationProvider());
    // providers.add(anonymousAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example 10
Source Project: MaxKey   Source File: Oauth20AutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * ProviderManager. 
 * @return oauth20ClientAuthenticationManager
 */
@Bean(name = "oauth20ClientAuthenticationManager")
public ProviderManager oauth20ClientAuthenticationManager(
        ClientDetailsUserDetailsService oauth20ClientDetailsUserService
        ) {
    DaoAuthenticationProvider daoAuthenticationProvider= new DaoAuthenticationProvider();
    PasswordEncoder passwordEncoder = NoOpPasswordEncoder.getInstance();
    daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);
    daoAuthenticationProvider.setUserDetailsService(oauth20ClientDetailsUserService);
    ProviderManager clientAuthenticationManager = new ProviderManager(daoAuthenticationProvider);
    return clientAuthenticationManager;
}
 
Example 11
Source Project: herd   Source File: AppSpringModuleConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManager()
{
    PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
    authenticationProvider.setPreAuthenticatedUserDetailsService(herdUserDetailsService);
    List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(authenticationProvider);
    return new ProviderManager(providers);
}
 
Example 12
Source Project: bearchoke   Source File: SecurityConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(name = "preAuthAuthenticationManager")
public AuthenticationManager preAuthAuthenticationManager() {
    PreAuthenticatedAuthenticationProvider preAuthProvider = new PreAuthenticatedAuthenticationProvider();
    preAuthProvider.setPreAuthenticatedUserDetailsService(preAuthUserDetailsService);

    List<AuthenticationProvider> providers = new ArrayList<AuthenticationProvider>();
    providers.add(preAuthProvider);

    return new ProviderManager(providers);
}
 
Example 13
Source Project: bearchoke   Source File: MockServerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(name = "preAuthAuthenticationManager")
public AuthenticationManager preAuthAuthenticationManager() {
    PreAuthenticatedAuthenticationProvider preAuthProvider = new PreAuthenticatedAuthenticationProvider();
    preAuthProvider.setPreAuthenticatedUserDetailsService(preAuthUserDetailsService());

    return new ProviderManager(Arrays.asList(preAuthProvider));
}
 
Example 14
Source Project: cloudbreak   Source File: SecurityConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Override
protected AuthenticationManager authenticationManager() throws Exception {
    List<AuthenticationProvider> providers = new ArrayList<>(1);
    providers.add(preAuthAuthProvider());
    return new ProviderManager(providers);
}
 
Example 15
Source Project: cloudbreak   Source File: SecurityConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Override
protected AuthenticationManager authenticationManager() throws Exception {
    List<AuthenticationProvider> providers = new ArrayList<>(1);
    providers.add(preAuthAuthProvider());
    return new ProviderManager(providers);
}
 
Example 16
Source Project: mall4j   Source File: TokenConfig.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
private void addUserDetailsService(YamiTokenServices tokenServices) {
    PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
    provider.setPreAuthenticatedUserDetailsService(new UserDetailsByNameServiceWrapper<>(userDetailsService));
    tokenServices.setAuthenticationManager(new ProviderManager(Collections.singletonList(provider)));
}
 
Example 17
Source Project: cymbal   Source File: CasConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public AuthenticationManager authenticationManager(CasAuthenticationProvider provider) {
    List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(provider);
    return new ProviderManager(providers);
}
 
Example 18
Source Project: cymbal   Source File: SecurityConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public AuthenticationManager authenticationManager(final CasAuthenticationProvider provider) {
    List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(provider);
    return new ProviderManager(providers);
}
 
Example 19
Source Project: Spring-5.0-Cookbook   Source File: AppSecurityModelB.java    License: MIT License 4 votes vote down vote up
@Override
protected AuthenticationManager authenticationManager() throws Exception {
	 return new ProviderManager(Arrays.asList(appAdminProvider, appHRProvider ), appAuthenticationMgr);
}
 
Example 20
Source Project: Spring-5.0-Cookbook   Source File: AppSecurityModelC.java    License: MIT License 4 votes vote down vote up
@Override
protected AuthenticationManager authenticationManager() throws Exception {
 return new ProviderManager(Arrays.asList(appAdminProvider, appHRProvider ), appAuthenticationMgr);
}
 
Example 21
Source Project: Spring-5.0-Cookbook   Source File: AppSecurityModelB.java    License: MIT License 4 votes vote down vote up
@Override
protected AuthenticationManager authenticationManager() throws Exception {
	 return new ProviderManager(Arrays.asList(appAdminProvider, appHRProvider ), appAuthenticationMgr);
}
 
Example 22
Source Project: Spring-5.0-Cookbook   Source File: AppSecurityModelC.java    License: MIT License 4 votes vote down vote up
@Override
protected AuthenticationManager authenticationManager() throws Exception {
 return new ProviderManager(Arrays.asList(appAdminProvider, appHRProvider ), appAuthenticationMgr);
}
 
Example 23
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(new X509CertificateAuthenticationProvider(userDetailsService()));
    return new ProviderManager(providers);
}
 
Example 24
Source Project: spring-security-firebase   Source File: WebSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManager() throws Exception {
    return new ProviderManager(Arrays.asList(authenticationProvider));
}
 
Example 25
/**
 * Used to set authenticationManager Native Grafana
 */
@Override
protected AuthenticationManager authenticationManager() throws Exception {
	return new ProviderManager(Arrays.asList(new NativeAuthenticationProvider()));
}
 
Example 26
/**
 * used to initialize Authentication Provider for authentication Manager for all
 * subsequent request
 */
@Override
protected AuthenticationManager authenticationManager() throws Exception {
	return new ProviderManager(Arrays.asList(new InsightsSAMLTokenAuthenticationImpl()));
}
 
Example 27
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(new X509CertificateAuthenticationProvider(userDetailsService()));
    return new ProviderManager(providers);
}
 
Example 28
Source Project: spring-boot-security-saml-samples   Source File: SAMLConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthenticationManager authenticationManager() {
    return new ProviderManager(Collections.singletonList(samlAuthenticationProvider()));
}
 
Example 29
Source Project: sakai   Source File: SecurityConfig.java    License: Educational Community License v2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManager() {
    return new ProviderManager(Arrays.asList(authenticationProvider));
}
 
Example 30
Source Project: Parrit   Source File: WebSecurityConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthenticationManager authenticationManager(AuthenticationProvider authenticationProvider) {
    List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(authenticationProvider);
    return new ProviderManager(providers);
}