Search in sources :

Example 1 with DirectoryServiceFactory

use of org.apache.directory.server.core.factory.DirectoryServiceFactory in project wildfly-camel by wildfly-extras.

the class DirectoryServiceBuilder method setupDirectoryService.

public static SetupResult setupDirectoryService(Class<?> testClass) throws Exception {
    // Define a default class DS then
    DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.class.newInstance();
    SetupResult result = new SetupResult();
    result.directoryService = dsf.getDirectoryService();
    result.directoryService.getChangeLog().setEnabled(true);
    dsf.init("default" + UUID.randomUUID().toString());
    // Apply the class LDIFs
    ApplyLdifFiles applyLdifFiles = testClass.getAnnotation(ApplyLdifFiles.class);
    if (applyLdifFiles != null) {
        LOG.debug("Applying {} to {}", applyLdifFiles.value(), testClass.getName());
        DSAnnotationProcessor.injectLdifFiles(applyLdifFiles.clazz(), result.directoryService, applyLdifFiles.value());
    }
    // check if it has a LdapServerBuilder then use the DS created above
    CreateLdapServer ldapServerAnnotation = testClass.getAnnotation(CreateLdapServer.class);
    if (ldapServerAnnotation != null) {
        result.ldapServer = ServerAnnotationProcessor.instantiateLdapServer(ldapServerAnnotation, result.directoryService);
        result.ldapServer.setDirectoryService(result.directoryService);
        result.ldapServer.start();
    }
    // print out information which partition factory we use
    DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
    PartitionFactory partitionFactory = dsFactory.getPartitionFactory();
    LOG.debug("Using partition factory {}", partitionFactory.getClass().getSimpleName());
    return result;
}
Also used : ApplyLdifFiles(org.apache.directory.server.core.annotations.ApplyLdifFiles) PartitionFactory(org.apache.directory.server.core.factory.PartitionFactory) CreateLdapServer(org.apache.directory.server.annotations.CreateLdapServer) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory) DirectoryServiceFactory(org.apache.directory.server.core.factory.DirectoryServiceFactory)

Example 2 with DirectoryServiceFactory

use of org.apache.directory.server.core.factory.DirectoryServiceFactory 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)

Aggregations

DefaultDirectoryServiceFactory (org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory)2 DirectoryServiceFactory (org.apache.directory.server.core.factory.DirectoryServiceFactory)2 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)1 CreateLdapServer (org.apache.directory.server.annotations.CreateLdapServer)1 ApplyLdifFiles (org.apache.directory.server.core.annotations.ApplyLdifFiles)1 CoreSession (org.apache.directory.server.core.api.CoreSession)1 PartitionFactory (org.apache.directory.server.core.factory.PartitionFactory)1 KeyDerivationInterceptor (org.apache.directory.server.core.kerberos.KeyDerivationInterceptor)1 LdapServer (org.apache.directory.server.ldap.LdapServer)1 TcpTransport (org.apache.directory.server.protocol.shared.transport.TcpTransport)1 Transport (org.apache.directory.server.protocol.shared.transport.Transport)1 UdpTransport (org.apache.directory.server.protocol.shared.transport.UdpTransport)1