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);
}
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);
}
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);
}
}
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());
}
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;
}
Aggregations