List of usage examples for org.springframework.security.ldap DefaultSpringSecurityContextSource DefaultSpringSecurityContextSource
public DefaultSpringSecurityContextSource(String providerUrl)
From source file:com.netflix.spinnaker.fiat.config.LdapConfig.java
@Bean SpringSecurityLdapTemplate springSecurityLdapTemplate() throws Exception { DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(configProps.url); contextSource.setUserDn(configProps.managerDn); contextSource.setPassword(configProps.managerPassword); contextSource.afterPropertiesSet();//from www.j a v a 2s.com return new SpringSecurityLdapTemplate(contextSource); }
From source file:io.gravitee.management.idp.ldap.authentication.LdapAuthenticationProvider.java
@Override public SecurityConfigurer configure() throws Exception { LOGGER.info("Configuring an LDAP Identity Provider"); LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthenticationProviderConfigurer = new LdapAuthenticationProviderConfigurer<>(); // Create LDAP context DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource( environment.getProperty("context-source-url")); contextSource.setBase(environment.getProperty("context-source-base")); contextSource.setUserDn(environment.getProperty("context-source-username")); contextSource.setPassword(environment.getProperty("context-source-password")); contextSource.afterPropertiesSet();//w w w. j a v a 2 s .c om String userDNPattern = environment.getProperty("user-dn-pattern"); if (userDNPattern == null || userDNPattern.isEmpty()) { ldapAuthenticationProviderConfigurer.userSearchBase(environment.getProperty("user-search-base")) .userSearchFilter(environment.getProperty("user-search-filter")); } else { ldapAuthenticationProviderConfigurer.userDnPatterns(userDNPattern); } ldapAuthenticationProviderConfigurer.groupSearchBase(environment.getProperty("group-search-base", "")) .groupSearchFilter(environment.getProperty("group-search-filter", "(uniqueMember={0})")) .groupRoleAttribute(environment.getProperty("group-role-attribute", "cn")).rolePrefix(""); DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(contextSource, environment.getProperty("group-search-base", "")); populator.setRolePrefix(""); ldapAuthenticationProviderConfigurer.ldapAuthoritiesPopulator(populator).contextSource(contextSource); // set up roles mapper if (environment.getProperty("role-mapping", Boolean.class, false)) { UserDetailsContextPropertiesMapper userDetailsContextPropertiesMapper = new UserDetailsContextPropertiesMapper(); userDetailsContextPropertiesMapper.setEnvironment(environment); ldapAuthenticationProviderConfigurer.userDetailsContextMapper(userDetailsContextPropertiesMapper); } return ldapAuthenticationProviderConfigurer; }
From source file:com.evolveum.midpoint.web.boot.LdapSecurityConfig.java
@Bean public LdapContextSource contextSource() { DefaultSpringSecurityContextSource ctx = new DefaultSpringSecurityContextSource(ldapHost); ctx.setUserDn(ldapUserDn);/* w ww . j a va2s.co m*/ ctx.setPassword(ldapUserPassword); return ctx; }
From source file:de.interseroh.report.test.security.LdapServerTest.java
@Test public void testJndiSpring() throws Exception { DefaultSpringSecurityContextSource ctxSrc = new DefaultSpringSecurityContextSource( "ldap://ldap.xxx:389/OU=xxx"); ctxSrc.setUserDn(USER_LDAP);//from w w w. ja v a2 s .com ctxSrc.setPassword(PASSWORD_LDAP); ctxSrc.afterPropertiesSet(); logger.info("Base LDAP Path: " + ctxSrc.getBaseLdapPath()); logger.info("Principal: " + ctxSrc.getAuthenticationSource().getPrincipal().toString()); logger.info("Credentials: " + ctxSrc.getAuthenticationSource().getCredentials()); Authentication bob = new UsernamePasswordAuthenticationToken("bob", "bob"); BindAuthenticator authenticator = new BindAuthenticator(ctxSrc); authenticator.setUserSearch( new FilterBasedLdapUserSearch("", "(&(objectCategory=Person)(sAMAccountName={0}))", ctxSrc)); authenticator.afterPropertiesSet(); authenticator.authenticate(bob); DirContextOperations user = authenticator.authenticate(bob); logger.info("User: {}", user); }
From source file:sk.lazyman.gizmo.security.GizmoAuthProvider.java
public void init() throws Exception { if (!useLdapAuth()) { return;/*from ww w . j a v a 2s .c o m*/ } LdapContextSource contextSource = new DefaultSpringSecurityContextSource(ldapHost); contextSource.setUserDn(ldapUsername); contextSource.setPassword(ldapPassword); contextSource.afterPropertiesSet(); DefaultLdapAuthoritiesPopulator ldapAuthoritiesPopulator = new DefaultLdapAuthoritiesPopulator( contextSource, ldapGroupSearchBase); ldapAuthoritiesPopulator.setGroupRoleAttribute(ldapGroupRoleAttribute); ldapAuthoritiesPopulator.setGroupSearchFilter(ldapGroupSearchFilter); ldapBindAuthenticator = new SimpleBindAunthenticator(contextSource, gizmoGroup); ldapBindAuthenticator.setUserDnPatterns(new String[] { userDnPattern }); }
From source file:org.osiam.auth.configuration.LdapConfiguration.java
@Bean public DefaultSpringSecurityContextSource createLdapContextSource() { if (isLdapConfigured) { return new DefaultSpringSecurityContextSource(url); }/*from w w w .j ava2s . com*/ return null; }
From source file:org.osiam.configuration.LdapAuthentication.java
@Bean public BaseLdapPathContextSource contextSource() { return new DefaultSpringSecurityContextSource(serverUrl); }
From source file:net.oneandone.stool.overview.config.SecurityConfiguration.java
@Bean public DefaultSpringSecurityContextSource contextSource() { DefaultSpringSecurityContextSource contextSource; contextSource = new DefaultSpringSecurityContextSource(session.configuration.ldapUrl); contextSource.setUserDn(session.configuration.ldapPrincipal); contextSource.setPassword(session.configuration.ldapCredentials); return contextSource; }
From source file:com.thoughtworks.go.server.service.ServerConfigService.java
DefaultSpringSecurityContextSource ldapContextSource(LdapConfig ldapConfig) { DefaultSpringSecurityContextSource source = new DefaultSpringSecurityContextSource(ldapConfig.uri()); //so user can define the variable java.naming.referral=follow in the server.sh source.setBaseEnvironmentProperties(System.getProperties()); new LdapContextSourceConfigurator(ldapConfig).configure(source); try {// w ww . j a va 2 s .c o m source.afterPropertiesSet(); } catch (Exception e) { bomb("Cannot create ldap context", e); } return source; }
From source file:de.thm.arsnova.config.SecurityConfig.java
@Bean public LdapContextSource ldapContextSource() throws Exception { DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(ldapUrl); /* TODO: implement support for LDAP bind using manager credentials */ // contextSource.setUserDn(ldapManagerUserDn); // contextSource.setPassword(ldapManagerPassword); return contextSource; }