Package org.springframework.ldap.core.support

Examples of org.springframework.ldap.core.support.LdapContextSource


        reloadEntitySequences();
        reloadConnectors();
    }

    public void testLDAPConnection() {
        LdapContextSource source = new LdapContextSource();
        source.setUrl(configurationModel.getLdapConfiguration().getLdapHost()
                + ":" + configurationModel.getLdapConfiguration().getLdapPort());
        source.setBase(configurationModel.getLdapConfiguration().getLdapBase());
        source.setUserDn(configurationModel.getLdapConfiguration()
                .getLdapUserDn());
        source.setPassword(configurationModel.getLdapConfiguration()
                .getLdapPassword());
        source.setDirObjectFactory(DefaultDirObjectFactory.class);
        source.setPooled(false);
        try {
            source.afterPropertiesSet();
        } catch (Exception e) {
            e.printStackTrace();
        }

        LdapTemplate template = new LdapTemplate(source);
View Full Code Here


   * @return corresponding LDAP authentication provider
   */
  LdapAuthenticationProvider loadLdapAuthenticationProvider() {
    if (reloadLdapServerProperties()) {
      LOG.info("LDAP Properties changed - rebuilding Context");
      LdapContextSource springSecurityContextSource = new LdapContextSource();
      List<String> ldapUrls = ldapServerProperties.get().getLdapUrls();
      springSecurityContextSource.setUrls(ldapUrls.toArray(new String[ldapUrls.size()]));
      springSecurityContextSource.setBase(ldapServerProperties.get().getBaseDN());

      if (!ldapServerProperties.get().isAnonymousBind()) {
        springSecurityContextSource.setUserDn(ldapServerProperties.get().getManagerDn());
        springSecurityContextSource.setPassword(ldapServerProperties.get().getManagerPassword());
      }

      try {
        springSecurityContextSource.afterPropertiesSet();
      } catch (Exception e) {
        LOG.error("LDAP Context Source not loaded ", e);
        throw new UsernameNotFoundException("LDAP Context Source not loaded", e);
      }

View Full Code Here

    public void setUp() throws Exception
    {
        baseDN = "o=sevenSeas";
        // TODO : move config to build environment
        LdapContextSource contextSource = new LdapContextSource();
        contextSource.setUrl("ldap://localhost:389");
        contextSource.setBase(baseDN);
        contextSource.setUserDn("cn=admin,o=sevenSeas");
        contextSource.setPassword("secret");
        contextSource.afterPropertiesSet();
        ldapTemplate = new LdapTemplate();
        ldapTemplate.setContextSource(contextSource);

        try
        {
View Full Code Here

     * @param ldapConfig
     * @return
     */
    public static LdapContextSource createLdapContext(
            LDAPBaseSecurityServiceConfig ldapConfig) {
        LdapContextSource ldapContext = new DefaultSpringSecurityContextSource(
                ldapConfig.getServerURL());
        ldapContext.setCacheEnvironmentProperties(false);
        ldapContext
                .setAuthenticationSource(new SpringSecurityAuthenticationSource());
   
        if (ldapConfig.isUseTLS()) {
            // TLS does not play nicely with pooled connections
            ldapContext.setPooled(false);
   
            DefaultTlsDirContextAuthenticationStrategy tls = new DefaultTlsDirContextAuthenticationStrategy();
            tls.setHostnameVerifier(new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }
            });
   
            ldapContext.setAuthenticationStrategy(tls);
        }
        return ldapContext;
    }
View Full Code Here

   
    @Override
    public GeoServerAuthenticationProvider createAuthenticationProvider(SecurityNamedServiceConfig config) {
        LDAPSecurityServiceConfig ldapConfig = (LDAPSecurityServiceConfig) config;

        LdapContextSource ldapContext = LDAPUtils.createLdapContext(ldapConfig);

        GeoserverLdapBindAuthenticator authenticator = new GeoserverLdapBindAuthenticator(
                ldapContext);

        // authenticate and extract user using a filter and an optional username
View Full Code Here

                startApacheDirectoryServer(10389, basePath, "test",
                        LdapTestUtils.DEFAULT_PRINCIPAL,
                        LdapTestUtils.DEFAULT_PASSWORD, allowAnonymous);
   
                // Bind to the directory
                LdapContextSource contextSource = new LdapContextSource();
                contextSource.setUrl(ldapServerUrl);
                contextSource.setUserDn(LdapTestUtils.DEFAULT_PRINCIPAL);
                contextSource.setPassword(LdapTestUtils.DEFAULT_PASSWORD);
                contextSource.setPooled(false);
                contextSource.afterPropertiesSet();
   
                // Create the Sprint LDAP template
                LdapTemplate template = new LdapTemplate(contextSource);
   
                // Clear out any old data - and load the test data
View Full Code Here

    public void setUp() throws Exception
    {
        super.setUp();
        // TODO : move config to build environment
        baseDN = getBaseDN();
        LdapContextSource contextSource = new LdapContextSource();
        contextSource.setUrl("ldap://localhost:"+Integer.toString(getLdapPort()));
        contextSource.setBase(baseDN);
        contextSource.setUserDn("uid=admin,ou=system");
        contextSource.setPassword("secret");
        contextSource.setPooled(false);
        contextSource.afterPropertiesSet();
        PoolingContextSource pcs = new MutablePoolingContextSource();
        pcs.setContextSource(contextSource);
       
        ldapTemplate = new LdapTemplate(pcs);
View Full Code Here

TOP

Related Classes of org.springframework.ldap.core.support.LdapContextSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.