org.springframework.security.authentication.ProviderManager Java Examples

The following examples show how to use org.springframework.security.authentication.ProviderManager. 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: SecurityConfig.java    From feast with 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 File: NextServerApplication.java    From nextreports-server with 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 File: WithBasicAuthSecurityConfiguration.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(daoAuthenticationProvider());
    // providers.add(anonymousAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example #4
Source File: AppSpringModuleConfig.java    From herd with 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 #5
Source File: Oauth20AutoConfiguration.java    From MaxKey with 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 #6
Source File: WithBasicAuthSecurityConfiguration.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(daoAuthenticationProvider());
    // providers.add(anonymousAuthenticationProvider());
    return new ProviderManager(providers);
}
 
Example #7
Source File: SecurityConfiguration.java    From grpc-spring-boot-starter with 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 #8
Source File: SecurityConfiguration.java    From grpc-spring-boot-starter with 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 #9
Source File: SecurityConfig.java    From bearchoke with 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 #10
Source File: MockServerConfig.java    From bearchoke with 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 #11
Source File: SecurityConfiguration.java    From grpc-spring-boot-starter with 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 #12
Source File: SecurityConfiguration.java    From grpc-spring-boot-starter with 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 #13
Source File: SecurityConfig.java    From cloudbreak with 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 #14
Source File: SecurityConfig.java    From cloudbreak with 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 File: AuthorizationServerConfig.java    From oauth-server with 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 #16
Source File: MavenArtifactNotifierWebappSecurityConfig.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void addPac4jToAuthenticationManager() {
	applicationContext.getBean("authenticationManager", ProviderManager.class).getProviders()
			.add(clientAuthenticationProvider(clients()));
}
 
Example #17
Source File: SecurityConfig.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManager() {
    return new ProviderManager(Arrays.asList(authenticationProvider));
}
 
Example #18
Source File: WebSecurityConfiguration.java    From Parrit with 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);
}
 
Example #19
Source File: WebSecurityConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
@Override
protected AuthenticationManager authenticationManager() throws Exception {
    return new ProviderManager(Collections.singletonList(casAuthenticationProvider));
}
 
Example #20
Source File: SecurityConfig.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManager() {
    return new ProviderManager(Arrays.asList(authenticationProvider));
}
 
Example #21
Source File: UserSynchronizerJob.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Required
public void setAuthenticationManager(ProviderManager authenticationManager) {
	this.authenticationManager = authenticationManager;
}
 
Example #22
Source File: TokenConfig.java    From mall4j with 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 #23
Source File: SAMLConfig.java    From spring-boot-security-saml-samples with MIT License 4 votes vote down vote up
@Bean
public AuthenticationManager authenticationManager() {
    return new ProviderManager(Collections.singletonList(samlAuthenticationProvider()));
}
 
Example #24
Source File: WithCertificateSecurityConfiguration.java    From grpc-spring-boot-starter with MIT License 4 votes vote down vote up
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(new X509CertificateAuthenticationProvider(userDetailsService()));
    return new ProviderManager(providers);
}
 
Example #25
Source File: InsightsSecurityConfigurationAdapterSAML.java    From Insights with Apache License 2.0 4 votes vote down vote up
/**
 * 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 #26
Source File: InsightsSecurityConfigurationAdapter.java    From Insights with Apache License 2.0 4 votes vote down vote up
/**
 * Used to set authenticationManager Native Grafana
 */
@Override
protected AuthenticationManager authenticationManager() throws Exception {
	return new ProviderManager(Arrays.asList(new NativeAuthenticationProvider()));
}
 
Example #27
Source File: WebSecurityConfig.java    From spring-security-firebase with MIT License 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManager() throws Exception {
    return new ProviderManager(Arrays.asList(authenticationProvider));
}
 
Example #28
Source File: WithCertificateSecurityConfiguration.java    From grpc-spring-boot-starter with MIT License 4 votes vote down vote up
@Bean
AuthenticationManager authenticationManager() {
    final List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(new X509CertificateAuthenticationProvider(userDetailsService()));
    return new ProviderManager(providers);
}
 
Example #29
Source File: AppSecurityModelC.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
@Override
protected AuthenticationManager authenticationManager() throws Exception {
 return new ProviderManager(Arrays.asList(appAdminProvider, appHRProvider ), appAuthenticationMgr);
}
 
Example #30
Source File: AppSecurityModelB.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
@Override
protected AuthenticationManager authenticationManager() throws Exception {
	 return new ProviderManager(Arrays.asList(appAdminProvider, appHRProvider ), appAuthenticationMgr);
}