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

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

Introduction

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

Prototype

public LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthentication()
        throws Exception 

Source Link

Document

Add LDAP authentication to the AuthenticationManagerBuilder and return a LdapAuthenticationProviderConfigurer to allow customization of the LDAP authentication.

Usage

From source file:com.marklogic.samplestack.security.ApplicationSecurity.java

@Override
/**/* w w w .  ja  v a 2 s.c o  m*/
 * Standard practice in Spring Security is to provide a hook for configuring
 * the authentication manager.  This configuration sets up an embedded LDAP
 * server.
 * @param authManagerBuilder  a builder provided by the framework.
 */
protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception {

    authManagerBuilder.ldapAuthentication()

            .userDnPatterns("uid={0},ou=people", "uid={0},ou=apps").groupSearchBase("ou=groups").contextSource()
            .ldif("classpath:samplestack-ds.ldif").root("dc=samplestack,dc=org");

}

From source file:com.ericsson.eiffel.remrem.generate.config.SecurityConfig.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    LOGGER.debug("LDAP server url: " + ldapUrl);
    auth.ldapAuthentication().userSearchFilter(userSearchFilter).contextSource().managerDn(managerDn)
            .root(rootDn).managerPassword(decode(managerPassword)).url(ldapUrl);
}

From source file:de.whs.poodle.security.LdapAuthenticationProvider.java

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.ldapAuthentication().contextSource(this.ldapContextSource)
            .ldapAuthoritiesPopulator(new PoodleLdapAuthoritiesPopulator())
            .userSearchFilter(ldapProperties.getUserSearchFilter());
}

From source file:com.expedia.seiso.SeisoWebSecurityConfig.java

@SuppressWarnings("unused")
private void configureTestLdap(AuthenticationManagerBuilder auth) throws Exception {
    // @formatter:off
    auth.ldapAuthentication().userDnPatterns("uid={0},ou=people").groupSearchBase("ou=groups").contextSource()
            .ldif("classpath:test-server.ldif");
    // @formatter:on
}

From source file:org.schedoscope.metascope.config.ProductionSpringConfiguration.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    MetascopeConfig config = metascopeConfig();
    if (config.getAuthenticationMethod().equalsIgnoreCase("ldap")) {
        auth.ldapAuthentication().userDnPatterns(config.getUserDnPattern())
                .groupSearchBase(config.getGroupSearchBase()).contextSource(ldapContextSource());
    } else {//from  w  ww.j av  a 2s.c o  m
        auth.jdbcAuthentication().passwordEncoder(new ShaPasswordEncoder(256)).dataSource(dataSource())
                .usersByUsernameQuery(
                        "select username,password_hash,'true' from metascope_user where username = ?")
                .authoritiesByUsernameQuery("select username,userrole from metascope_user where username = ?");

        metascopeUserService.createAdminAccount();
    }

}

From source file:au.edu.anu.orcid.security.SecurityConfig.java

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    Properties properties = PropertyLoader.loadProperties("ldap.properties");
    LdapUserDetailsMapper contextMapper = new LdapUserDetailsMapper();
    //contextMapper.setRoleAttributes(new String[]{"affiliation"});
    contextMapper.setPasswordAttributeName("password");

    String ldapUri = properties.getProperty("ldap.uri");
    String baseDn = properties.getProperty("ldap.baseDn");

    String contextLdapUri = ldapUri + "/" + baseDn;

    LOGGER.debug("Ldap Url: {}", contextLdapUri);

    auth.ldapAuthentication().userDnPatterns("uid={0}, ou=People").contextSource().url(contextLdapUri).and()
            .userDetailsContextMapper(contextMapper);
}

From source file:de.interseroh.report.webconfig.SecurityConfig.java

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    logger.debug("configureGlobal: mapping login to LDAP");

    // LDAP or InMemory
    String ldapAuth = prepareLdapAuth();
    if (!ldapAuth.equalsIgnoreCase("true")) {
        // In memory authentication
        String inMemoryUser = prepareInMemoryUser();
        String inMemoryPassword = prepareInMemoryPassword();

        auth.inMemoryAuthentication().withUser(inMemoryUser).password(inMemoryPassword).roles("USER");
    } else {//from w  ww . ja v  a 2s  .  c o  m
        // LDAP authentication
        String ldapUrl = prepareLdapUrl();
        String managerDn = prepareManagerDn();
        String managerPassword = prepareManagerPassword();

        auth.ldapAuthentication().userSearchFilter(USER_SEARCH_FILTER).contextSource().managerDn(managerDn)
                .managerPassword(managerPassword).url(ldapUrl);
    }
}

From source file:org.schedoscope.metascope.conf.ProductionSpringConfiguration.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    MetascopeConfig config = metascopeConfig();
    if (config.getAuthenticationMethod().equalsIgnoreCase("ldap")) {
        auth.ldapAuthentication().userDnPatterns(config.getUserDnPattern())
                .groupSearchBase(config.getGroupSearchBase()).contextSource(ldapContextSource());
    } else {//from ww w  .  j a  v a 2s.c  o  m
        auth.jdbcAuthentication().passwordEncoder(new ShaPasswordEncoder(256)).dataSource(dataSource())
                .usersByUsernameQuery(
                        "select username,password_hash,'true' from user_entity where username = ?")
                .authoritiesByUsernameQuery("select username,userrole from user_entity where username = ?");

        userEntityService.createAdminAccount();
    }

}