Search in sources :

Example 1 with LdapServer

use of org.apache.directory.server.ldap.LdapServer in project aws-iam-ldap-bridge by denismo.

the class Runner method startServer.

/**
     * starts the LdapServer
     *
     * @throws Exception
     */
public void startServer() throws Exception {
    server = new LdapServer();
    server.setTransports(new TcpTransport(serverPort));
    server.setDirectoryService(service);
    server.start();
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport)

Example 2 with LdapServer

use of org.apache.directory.server.ldap.LdapServer in project jackrabbit-oak by apache.

the class AbstractServer method setUp.

/**
     * Get's the initial context factory for the provider's ou=system context
     * root.
     */
protected void setUp() throws Exception {
    File cwd = new File("target", "apacheds");
    doDelete(cwd);
    // setup directory service
    directoryService = new DefaultDirectoryService();
    directoryService.setShutdownHookEnabled(false);
    directoryService.setInstanceLayout(new InstanceLayout(cwd));
    cacheService = new CacheService();
    cacheService.initialize(directoryService.getInstanceLayout());
    SchemaManager schemaManager = new DefaultSchemaManager();
    directoryService.setSchemaManager(schemaManager);
    directoryService.setDnFactory(new DefaultDnFactory(directoryService.getSchemaManager(), cacheService.getCache("dnCache")));
    AvlPartition schLdifPart = new AvlPartition(directoryService.getSchemaManager(), directoryService.getDnFactory());
    schLdifPart.setId("schema");
    schLdifPart.setSuffixDn(directoryService.getDnFactory().create(ServerDNConstants.CN_SCHEMA_DN));
    SchemaPartition schPart = new SchemaPartition(directoryService.getSchemaManager());
    schPart.setWrappedPartition(schLdifPart);
    directoryService.setSchemaPartition(schPart);
    AvlPartition sysPart = new AvlPartition(directoryService.getSchemaManager(), directoryService.getDnFactory());
    sysPart.setId(SystemSchemaConstants.SCHEMA_NAME);
    sysPart.setSuffixDn(directoryService.getDnFactory().create(ServerDNConstants.SYSTEM_DN));
    directoryService.setSystemPartition(sysPart);
    AvlPartition examplePart = new AvlPartition(directoryService.getSchemaManager(), directoryService.getDnFactory());
    examplePart.setId("example");
    examplePart.setSuffixDn(directoryService.getDnFactory().create(EXAMPLE_DN));
    examplePart.setCacheService(cacheService);
    directoryService.addPartition(examplePart);
    // setup ldap server
    port = AvailablePortFinder.getNextAvailable(1024);
    ldapServer = new LdapServer();
    setupLdapServer();
    setupSaslMechanisms();
    directoryService.startup();
    setupExamplePartition();
    startLdapServer();
    setContexts(ServerDNConstants.ADMIN_SYSTEM_DN, "secret");
}
Also used : DefaultDirectoryService(org.apache.directory.server.core.DefaultDirectoryService) InstanceLayout(org.apache.directory.server.core.api.InstanceLayout) SchemaPartition(org.apache.directory.server.core.api.schema.SchemaPartition) LdapServer(org.apache.directory.server.ldap.LdapServer) DefaultDnFactory(org.apache.directory.server.core.shared.DefaultDnFactory) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) File(java.io.File) CacheService(org.apache.directory.server.core.api.CacheService) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) AvlPartition(org.apache.directory.server.core.partition.impl.avl.AvlPartition)

Example 3 with LdapServer

use of org.apache.directory.server.ldap.LdapServer in project undertow by undertow-io.

the class KerberosKDCUtil method startLdapServer.

private static void startLdapServer() throws Exception {
    createWorkingDir();
    DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory();
    dsf.init(DIRECTORY_NAME);
    directoryService = dsf.getDirectoryService();
    // Derives the Kerberos keys for new entries.
    directoryService.addLast(new KeyDerivationInterceptor());
    directoryService.getChangeLog().setEnabled(false);
    SchemaManager schemaManager = directoryService.getSchemaManager();
    createPartition(dsf, schemaManager, "users", "ou=users,dc=undertow,dc=io");
    CoreSession adminSession = directoryService.getAdminSession();
    Map<String, String> mappings = Collections.singletonMap("hostname", DefaultServer.getDefaultServerAddress().getHostString());
    processLdif(schemaManager, adminSession, "partition.ldif", mappings);
    processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings);
    processLdif(schemaManager, adminSession, "user.ldif", mappings);
    processLdif(schemaManager, adminSession, "server.ldif", mappings);
    ldapServer = new LdapServer();
    ldapServer.setServiceName("DefaultLDAP");
    Transport ldap = new TcpTransport("0.0.0.0", LDAP_PORT, 3, 5);
    ldapServer.addTransports(ldap);
    ldapServer.setDirectoryService(directoryService);
    ldapServer.start();
}
Also used : KeyDerivationInterceptor(org.apache.directory.server.core.kerberos.KeyDerivationInterceptor) LdapServer(org.apache.directory.server.ldap.LdapServer) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) CoreSession(org.apache.directory.server.core.api.CoreSession) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) Transport(org.apache.directory.server.protocol.shared.transport.Transport) DirectoryServiceFactory(org.apache.directory.server.core.factory.DirectoryServiceFactory) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory)

Example 4 with LdapServer

use of org.apache.directory.server.ldap.LdapServer in project spring-security by spring-projects.

the class ApacheDSContainer method afterPropertiesSet.

public void afterPropertiesSet() throws Exception {
    if (workingDir == null) {
        String apacheWorkDir = System.getProperty("apacheDSWorkDir");
        if (apacheWorkDir == null) {
            apacheWorkDir = createTempDirectory("apacheds-spring-security-");
        }
        setWorkingDirectory(new File(apacheWorkDir));
    }
    if (this.ldapOverSslEnabled && this.keyStoreFile == null) {
        throw new IllegalArgumentException("When LdapOverSsl is enabled, the keyStoreFile property must be set.");
    }
    server = new LdapServer();
    server.setDirectoryService(service);
    // AbstractLdapIntegrationTests assume IPv4, so we specify the same here
    TcpTransport transport = new TcpTransport(port);
    if (ldapOverSslEnabled) {
        transport.setEnableSSL(true);
        server.setKeystoreFile(this.keyStoreFile.getAbsolutePath());
        server.setCertificatePassword(this.certificatePassord);
    }
    server.setTransports(transport);
    start();
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) File(java.io.File)

Example 5 with LdapServer

use of org.apache.directory.server.ldap.LdapServer in project graylog2-server by Graylog2.

the class LdapConnectorTest method setUp.

@Before
public void setUp() throws Exception {
    final LdapServer server = getLdapServer();
    final LdapConnectionConfig config = new LdapConnectionConfig();
    config.setLdapHost("localHost");
    config.setLdapPort(server.getPort());
    config.setName(ADMIN_DN);
    config.setCredentials(ADMIN_PASSWORD);
    connector = new LdapConnector(10000);
    connection = connector.connect(config);
}
Also used : CreateLdapServer(org.apache.directory.server.annotations.CreateLdapServer) LdapServer(org.apache.directory.server.ldap.LdapServer) LdapConnectionConfig(org.apache.directory.ldap.client.api.LdapConnectionConfig) Before(org.junit.Before)

Aggregations

LdapServer (org.apache.directory.server.ldap.LdapServer)5 TcpTransport (org.apache.directory.server.protocol.shared.transport.TcpTransport)3 File (java.io.File)2 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)2 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)1 LdapConnectionConfig (org.apache.directory.ldap.client.api.LdapConnectionConfig)1 CreateLdapServer (org.apache.directory.server.annotations.CreateLdapServer)1 DefaultDirectoryService (org.apache.directory.server.core.DefaultDirectoryService)1 CacheService (org.apache.directory.server.core.api.CacheService)1 CoreSession (org.apache.directory.server.core.api.CoreSession)1 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)1 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)1 DefaultDirectoryServiceFactory (org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory)1 DirectoryServiceFactory (org.apache.directory.server.core.factory.DirectoryServiceFactory)1 KeyDerivationInterceptor (org.apache.directory.server.core.kerberos.KeyDerivationInterceptor)1 AvlPartition (org.apache.directory.server.core.partition.impl.avl.AvlPartition)1 DefaultDnFactory (org.apache.directory.server.core.shared.DefaultDnFactory)1 Transport (org.apache.directory.server.protocol.shared.transport.Transport)1 UdpTransport (org.apache.directory.server.protocol.shared.transport.UdpTransport)1 Before (org.junit.Before)1