Search in sources :

Example 31 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class ACIItemSyntaxCheckerTest method init.

@BeforeClass
public static void init() throws Exception {
    JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    checker = ACIItemSyntaxChecker.builder().setSchemaManager(schemaManager).build();
    checker.setSchemaManager(schemaManager);
}
Also used : JarLdifSchemaLoader(org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 32 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SubtreeSpecificationSyntaxCheckerTest method init.

/**
 * Initialization
 */
@BeforeClass
public static void init() throws Exception {
    JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    checker = SubtreeSpecificationSyntaxChecker.INSTANCE;
    checker.setSchemaManager(schemaManager);
}
Also used : JarLdifSchemaLoader(org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 33 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class LdifAnonymizerTest method setup.

@Before
public void setup() {
    schemaManager = null;
    try {
        schemaManager = new DefaultSchemaManager();
        ldifReader = new LdifReader(schemaManager);
    } catch (Exception e) {
        // Todo : we need a schemaManager
        System.out.println("Missing a SchemaManager !");
        System.exit(-1);
    }
}
Also used : LdifReader(org.apache.directory.api.ldap.model.ldif.LdifReader) IOException(java.io.IOException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Before(org.junit.Before)

Example 34 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class QuirkySchemaTest method testLoadQuirkySchema.

/**
 * Try to load a quirky schema. This schema has a lot of issues that violate the
 * standards. Therefore load the schema in relaxed mode. We should be able to work
 * with this schema anyway. E.g. the loader and schema manager should not die on
 * null pointer or similar trivial error.
 */
@Test
public void testLoadQuirkySchema() throws Exception {
    LdapConnection connection = createFakeConnection("src/test/resources/schema-quirky.ldif");
    DefaultSchemaLoader loader = new DefaultSchemaLoader(connection, true);
    Collection<Schema> allEnabled = loader.getAllEnabled();
    assertEquals(1, allEnabled.size());
    Schema schema = allEnabled.iterator().next();
    assertNotNull(schema);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    boolean loaded = schemaManager.loadAllEnabledRelaxed();
    if (!loaded) {
        fail("Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()));
    }
    assertTrue("Surprisingly no errors after load", schemaManager.getErrors().size() > 0);
    assertTrue(schemaManager.getRegistries().getAttributeTypeRegistry().contains("cn"));
    ObjectClass person = schemaManager.getRegistries().getObjectClassRegistry().lookup("person");
    assertNotNull(person);
    assertEquals(2, person.getMustAttributeTypes().size());
    assertEquals(5, person.getMayAttributeTypes().size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 35 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project structr by structr.

the class LDAPServerService method initialize.

@Override
public boolean initialize(final StructrServices services) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    logger.info("Initializing directory service");
    try {
        ds = new DefaultDirectoryService();
        final SchemaManager schemaManager = new DefaultSchemaManager();
        final SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
        final StructrPartition structrSchemaPartition = new StructrPartition(schemaManager, "schema", new Dn("ou=system"));
        schemaPartition.setWrappedPartition(structrSchemaPartition);
        ds.setInstanceLayout(new InstanceLayout(new File("/tmp/ldap-test")));
        ds.setSchemaPartition(schemaPartition);
        ds.setSchemaManager(schemaManager);
        ds.setSystemPartition(new StructrPartition(schemaManager, "system", new Dn("ou=system")));
        ds.startup();
        logger.info("Importing schema..");
        initSchema(schemaManager, ds.getAdminSession(), structrSchemaPartition);
        server = new LdapServer();
        int serverPort = 10389;
        server.setTransports(new TcpTransport(serverPort));
        server.setDirectoryService(ds);
        server.start();
    } catch (Throwable t) {
        t.printStackTrace();
        logger.warn("Unable to start LDAP server: {}", t.getMessage());
        return false;
    }
    return true;
}
Also used : DefaultDirectoryService(org.apache.directory.server.core.DefaultDirectoryService) SchemaPartition(org.apache.directory.server.core.api.schema.SchemaPartition) InstanceLayout(org.apache.directory.server.core.api.InstanceLayout) LdapServer(org.apache.directory.server.ldap.LdapServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) Dn(org.apache.directory.api.ldap.model.name.Dn) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) JarFile(java.util.jar.JarFile) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)

Aggregations

DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)64 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)55 Test (org.junit.Test)41 BeforeClass (org.junit.BeforeClass)11 JarLdifSchemaLoader (org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader)9 File (java.io.File)7 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)7 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)6 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)6 IOException (java.io.IOException)5 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)4 LdapUnwillingToPerformException (org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)4 SchemaLoader (org.apache.directory.api.ldap.model.schema.registries.SchemaLoader)4 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)3 SchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor)3 DefaultSchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor)3 CacheService (org.apache.directory.server.core.api.CacheService)3 CacheManager (net.sf.ehcache.CacheManager)2 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)2 Configuration (net.sf.ehcache.config.Configuration)2