Search in sources :

Example 11 with InMemoryDirectoryServer

use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project spring-boot by spring-projects.

the class EmbeddedLdapAutoConfigurationTests method testRandomPortWithEnvironment.

@Test
public void testRandomPortWithEnvironment() throws LDAPException {
    load("spring.ldap.embedded.base-dn:dc=spring,dc=org");
    InMemoryDirectoryServer server = this.context.getBean(InMemoryDirectoryServer.class);
    assertThat(server.getListenPort()).isEqualTo(this.context.getEnvironment().getProperty("local.ldap.port", Integer.class));
}
Also used : InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) Test(org.junit.Test)

Example 12 with InMemoryDirectoryServer

use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project spring-boot by spring-projects.

the class EmbeddedLdapAutoConfiguration method directoryServer.

@Bean
public InMemoryDirectoryServer directoryServer() throws LDAPException {
    InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(this.embeddedProperties.getBaseDn());
    if (hasCredentials(this.embeddedProperties.getCredential())) {
        config.addAdditionalBindCredentials(this.embeddedProperties.getCredential().getUsername(), this.embeddedProperties.getCredential().getPassword());
    }
    setSchema(config);
    InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("LDAP", this.embeddedProperties.getPort());
    config.setListenerConfigs(listenerConfig);
    this.server = new InMemoryDirectoryServer(config);
    importLdif();
    this.server.startListening();
    setPortProperty(this.applicationContext, this.server.getListenPort());
    return this.server;
}
Also used : InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) InMemoryDirectoryServerConfig(com.unboundid.ldap.listener.InMemoryDirectoryServerConfig) InMemoryListenerConfig(com.unboundid.ldap.listener.InMemoryListenerConfig) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 13 with InMemoryDirectoryServer

use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project cdap by caskdata.

the class ExternalLDAPAuthenticationServerTestBase method startExternalAuthenticationServer.

protected void startExternalAuthenticationServer() throws Exception {
    InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com");
    config.setListenerConfigs(ldapListenerConfig);
    Entry defaultEntry = new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example");
    Entry userEntry = new Entry("dn: uid=user,dc=example,dc=com", "objectClass: inetorgperson", "cn: admin", "sn: User", "uid: user", "userPassword: realtime");
    ldapServer = new InMemoryDirectoryServer(config);
    ldapServer.addEntries(defaultEntry, userEntry);
    ldapServer.startListening();
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) InMemoryDirectoryServerConfig(com.unboundid.ldap.listener.InMemoryDirectoryServerConfig)

Aggregations

InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)13 Test (org.junit.Test)7 InMemoryDirectoryServerConfig (com.unboundid.ldap.listener.InMemoryDirectoryServerConfig)5 InMemoryListenerConfig (com.unboundid.ldap.listener.InMemoryListenerConfig)2 DN (com.unboundid.ldap.sdk.DN)2 GitblitAuthority (com.gitblit.authority.GitblitAuthority)1 NewCertificateConfig (com.gitblit.authority.NewCertificateConfig)1 GitblitContext (com.gitblit.servlet.GitblitContext)1 X509Log (com.gitblit.utils.X509Utils.X509Log)1 X509Metadata (com.gitblit.utils.X509Utils.X509Metadata)1 Attribute (com.unboundid.ldap.sdk.Attribute)1 BindResult (com.unboundid.ldap.sdk.BindResult)1 Entry (com.unboundid.ldap.sdk.Entry)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 OperationType (com.unboundid.ldap.sdk.OperationType)1 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)1 LDIFReader (com.unboundid.ldif.LDIFReader)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1