Example usage for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder authenticationProvider

List of usage examples for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder authenticationProvider

Introduction

In this page you can find the example usage for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder authenticationProvider.

Prototype

public AuthenticationManagerBuilder authenticationProvider(AuthenticationProvider authenticationProvider) 

Source Link

Document

Add authentication based upon the custom AuthenticationProvider that is passed in.

Usage

From source file:com.netflix.genie.web.security.SecurityConfig.java

/**
 * Configure the global authentication manager.
 *
 * @param auth The builder to configure//  ww  w .j av  a 2s  .  c o  m
 * @throws Exception on error
 */
@Autowired
protected void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
    if (this.providers != null) {
        for (final AuthenticationProvider provider : this.providers) {
            log.debug("Adding authentication provider {} to authentication provider.", provider);
            auth.authenticationProvider(provider);
        }
    } else {
        // in the case nothing was configured
        log.debug("No providers were found. Configuring in memory authentication to avoid NPE.");
        auth.inMemoryAuthentication();
    }
}

From source file:fi.helsinki.opintoni.config.SAMLSecurityConfiguration.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(samlAuthenticationProvider());
}

From source file:cn.net.withub.demo.bootsec.hello.config.WebSecurityConfig.java

/**
 * /*from   w w w  .j a  v a2 s  .co m*/
 *
 * @param auth
 * @throws Exception
 */
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    //?roles()??ROLE_
    //?
    auth.inMemoryAuthentication().withUser("admin").password("admin").roles("ADMIN", "A");//?ROLE_ADMIN, ROLE_A

    //?
    auth.authenticationProvider(authenticationProvider());
}

From source file:com.hp.autonomy.frontend.find.hod.beanconfiguration.HodSecurity.java

@SuppressWarnings("ProhibitedExceptionDeclared")
@Override//from   ww w. j a  va 2 s .c  o m
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
    final Collection<String> roles = new LinkedList<>();
    roles.add(FindRole.USER.toString());

    // TODO: Remove when we can get group information from HOD (HOD-2420)
    if (enableBi) {
        roles.add(FindRole.BI.toString());
    }

    auth.authenticationProvider(new HodAuthenticationProvider(tokenRepository,
            new ConstantAuthoritiesResolver(roles.toArray(new String[roles.size()])), authenticationService,
            unboundTokenService, userStoreUsersService, HavenSearchUserMetadata.METADATA_TYPES,
            usernameResolver(), null));
}

From source file:com.erudika.para.security.SecurityConfig.java

/**
 * Configures the authentication providers
 *
 * @param auth a builder//from w w w .j a  v a 2s. co  m
 * @throws Exception ex
 */
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    OpenIDAuthenticationProvider openidProvider = new OpenIDAuthenticationProvider();
    openidProvider.setAuthenticationUserDetailsService(new SimpleUserService());
    auth.authenticationProvider(openidProvider);

    RememberMeAuthenticationProvider rmeProvider = new RememberMeAuthenticationProvider(Config.APP_SECRET_KEY);
    auth.authenticationProvider(rmeProvider);
}

From source file:jp.pigumer.sso.WebSecurityConfig.java

/**
 * samlAuthenticationProvider???/*from  w  ww  . j  av a  2  s  . c om*/
 * 
 * @param   auth AuthenticationManagerBuilder
 */
@Override
protected void configure(AuthenticationManagerBuilder auth) {
    auth.authenticationProvider(samlAuthenticationProvider());
}

From source file:com.naveen.demo.config.Saml2SSOConfig.java

/**
* Sets a custom authentication provider.
* 
* @param   auth SecurityBuilder used to create an AuthenticationManager.
* @throws  Exception //from w  w w .j a  v  a 2s  .co  m
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(samlAuthenticationProvider());
}

From source file:net.oneandone.stool.overview.config.SecurityConfiguration.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    CasAuthenticationProvider provider;/*from  w w  w .  j a va  2 s. c  o m*/

    provider = new CasAuthenticationProvider();
    provider.setServiceProperties(serviceProperties());
    provider.setTicketValidator(new Cas20ServiceTicketValidator(session.configuration.ldapSso));
    provider.setKey("cas");
    provider.setAuthenticationUserDetailsService(new UserDetailsByNameServiceWrapper(userDetailsService()));

    auth.authenticationProvider(provider);
}

From source file:de.thm.arsnova.config.SecurityConfig.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    List<String> providers = new ArrayList<>();
    if (dbAuthEnabled) {
        providers.add("user-db");
        auth.authenticationProvider(daoAuthenticationProvider());
    }/*from  w  ww . ja va2 s.c  o m*/
    if (ldapEnabled) {
        providers.add("ldap");
        auth.authenticationProvider(ldapAuthenticationProvider());
    }
    if (casEnabled) {
        providers.add("cas");
        auth.authenticationProvider(casAuthenticationProvider());
    }
    if (googleEnabled) {
        providers.add("google");
        auth.authenticationProvider(googleAuthProvider());
    }
    if (facebookEnabled) {
        providers.add("facebook");
        auth.authenticationProvider(facebookAuthProvider());
    }
    if (twitterEnabled) {
        providers.add("twitter");
        auth.authenticationProvider(twitterAuthProvider());
    }
    logger.info("Enabled authentication providers: {}", providers);
}

From source file:org.drugis.addis.config.SecurityConfig.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.jdbcAuthentication().dataSource(dataSource)
            .usersByUsernameQuery("SELECT username, password, TRUE FROM Account WHERE username = ?")
            .authoritiesByUsernameQuery(
                    "SELECT Account.username, COALESCE(AccountRoles.role, 'ROLE_USER') FROM Account"
                            + " LEFT OUTER JOIN AccountRoles ON Account.id = AccountRoles.accountId WHERE Account.username = ?")
            .passwordEncoder(passwordEncoder());
    auth.authenticationProvider(tokenAuthenticationProvider());

}