Search in sources :

Example 1 with AvlPartition

use of org.apache.directory.server.core.partition.impl.avl.AvlPartition 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 2 with AvlPartition

use of org.apache.directory.server.core.partition.impl.avl.AvlPartition in project activemq-artemis by apache.

the class LdapServer method checkPartition.

private void checkPartition(LdifEntry ldifEntry) throws Exception {
    Dn dn = ldifEntry.getDn();
    Dn parent = dn.getParent();
    try {
        directoryService.getAdminSession().exists(parent);
    } catch (Exception e) {
        System.out.println("Creating new partition for DN=" + dn + "\n");
        AvlPartition partition = new AvlPartition(directoryService.getSchemaManager());
        partition.setId(dn.getName());
        partition.setSuffixDn(dn);
        directoryService.addPartition(partition);
    }
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) IOException(java.io.IOException) AvlPartition(org.apache.directory.server.core.partition.impl.avl.AvlPartition)

Example 3 with AvlPartition

use of org.apache.directory.server.core.partition.impl.avl.AvlPartition in project sonarqube by SonarSource.

the class ApacheDS method startDirectoryService.

private ApacheDS startDirectoryService(String workDirStr) throws Exception {
    DefaultDirectoryServiceFactory factory = new DefaultDirectoryServiceFactory();
    factory.init(realm);
    directoryService = factory.getDirectoryService();
    directoryService.getChangeLog().setEnabled(false);
    directoryService.setShutdownHookEnabled(false);
    directoryService.setAllowAnonymousAccess(true);
    File workDir = new File(workDirStr);
    if (workDir.exists()) {
        FileUtils.deleteDirectory(workDir);
    }
    InstanceLayout instanceLayout = new InstanceLayout(workDir);
    directoryService.setInstanceLayout(instanceLayout);
    AvlPartition partition = new AvlPartition(directoryService.getSchemaManager());
    partition.setId("Test");
    partition.setSuffixDn(new Dn(directoryService.getSchemaManager(), baseDn));
    partition.addIndexedAttributes(new AvlIndex<>("ou"), new AvlIndex<>("uid"), new AvlIndex<>("dc"), new AvlIndex<>("objectClass"));
    partition.initialize();
    directoryService.addPartition(partition);
    directoryService.addLast(new KeyDerivationInterceptor());
    directoryService.shutdown();
    directoryService.startup();
    return this;
}
Also used : InstanceLayout(org.apache.directory.server.core.api.InstanceLayout) KeyDerivationInterceptor(org.apache.directory.server.core.kerberos.KeyDerivationInterceptor) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory) Dn(org.apache.directory.api.ldap.model.name.Dn) File(java.io.File) AvlPartition(org.apache.directory.server.core.partition.impl.avl.AvlPartition)

Example 4 with AvlPartition

use of org.apache.directory.server.core.partition.impl.avl.AvlPartition in project sonarqube by SonarSource.

the class ApacheDS method startDirectoryService.

private ApacheDS startDirectoryService(String workDirStr) throws Exception {
    DefaultDirectoryServiceFactory factory = new DefaultDirectoryServiceFactory();
    factory.init(realm);
    directoryService = factory.getDirectoryService();
    directoryService.getChangeLog().setEnabled(false);
    directoryService.setShutdownHookEnabled(false);
    directoryService.setAllowAnonymousAccess(true);
    File workDir = new File(workDirStr);
    if (workDir.exists()) {
        FileUtils.deleteDirectory(workDir);
    }
    InstanceLayout instanceLayout = new InstanceLayout(workDir);
    directoryService.setInstanceLayout(instanceLayout);
    AvlPartition partition = new AvlPartition(directoryService.getSchemaManager());
    partition.setId("Test");
    partition.setSuffixDn(new Dn(directoryService.getSchemaManager(), baseDn));
    partition.addIndexedAttributes(new AvlIndex<>("ou"), new AvlIndex<>("uid"), new AvlIndex<>("dc"), new AvlIndex<>("objectClass"));
    partition.initialize();
    directoryService.addPartition(partition);
    directoryService.addLast(new KeyDerivationInterceptor());
    directoryService.shutdown();
    directoryService.startup();
    return this;
}
Also used : InstanceLayout(org.apache.directory.server.core.api.InstanceLayout) KeyDerivationInterceptor(org.apache.directory.server.core.kerberos.KeyDerivationInterceptor) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory) Dn(org.apache.directory.api.ldap.model.name.Dn) File(java.io.File) AvlPartition(org.apache.directory.server.core.partition.impl.avl.AvlPartition)

Aggregations

AvlPartition (org.apache.directory.server.core.partition.impl.avl.AvlPartition)4 File (java.io.File)3 Dn (org.apache.directory.api.ldap.model.name.Dn)3 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)3 DefaultDirectoryServiceFactory (org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory)2 KeyDerivationInterceptor (org.apache.directory.server.core.kerberos.KeyDerivationInterceptor)2 IOException (java.io.IOException)1 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)1 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)1 DefaultDirectoryService (org.apache.directory.server.core.DefaultDirectoryService)1 CacheService (org.apache.directory.server.core.api.CacheService)1 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)1 DefaultDnFactory (org.apache.directory.server.core.shared.DefaultDnFactory)1 LdapServer (org.apache.directory.server.ldap.LdapServer)1