use of org.apache.directory.server.core.partition.ldif.LdifPartition in project vertx-auth by vert-x3.
the class EmbeddedADS method initSchemaPartition.
/**
* initialize the schema manager and add the schema partition to diectory service
*
* @throws Exception if the schema LDIF files are not found on the classpath
*/
private void initSchemaPartition() throws Exception {
SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
// Init the LdifPartition
LdifPartition ldifPartition = new LdifPartition();
String workingDirectory = service.getWorkingDirectory().getPath();
ldifPartition.setWorkingDirectory(workingDirectory + "/schema");
// Extract the schema on disk (a brand new one) and load the registries
File schemaRepository = new File(workingDirectory, "schema");
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy(true);
schemaPartition.setWrappedPartition(ldifPartition);
SchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
service.setSchemaManager(schemaManager);
// We have to load the schema now, otherwise we won't be able
// to initialize the Partitions, as we won't be able to parse
// and normalize their suffix DN
schemaManager.loadAllEnabled();
schemaPartition.setSchemaManager(schemaManager);
List<Throwable> errors = schemaManager.getErrors();
if (errors.size() != 0) {
throw new Exception("Schema load failed : " + errors);
}
}
use of org.apache.directory.server.core.partition.ldif.LdifPartition in project aws-iam-ldap-bridge by denismo.
the class Runner method initSchemaPartition.
/**
* initialize the schema manager and add the schema partition to diectory service
*
* @throws Exception if the schema LDIF files are not found on the classpath
*/
private void initSchemaPartition() throws Exception {
InstanceLayout instanceLayout = service.getInstanceLayout();
File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
// Extract the schema on disk (a brand new one) and load the registries
if (schemaPartitionDirectory.exists()) {
System.out.println("schema partition already exists, skipping schema extraction");
} else {
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
extractor.extractOrCopy();
}
SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
// We have to load the schema now, otherwise we won't be able
// to initialize the Partitions, as we won't be able to parse
// and normalize their suffix Dn
schemaManager.loadAllEnabled();
List<Throwable> errors = schemaManager.getErrors();
if (errors.size() != 0) {
throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
}
service.setSchemaManager(schemaManager);
// Init the LdifPartition with schema
LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.getDnFactory());
schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());
// The schema partition
SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
schemaPartition.setWrappedPartition(schemaLdifPartition);
service.setSchemaPartition(schemaPartition);
}
use of org.apache.directory.server.core.partition.ldif.LdifPartition in project syncope by apache.
the class ApacheDSStartStopListener method initSchemaPartition.
/**
* Initialize the schema manager and add the schema partition to directory service.
*
* @throws Exception if the schema LDIF files are not found on the classpath
*/
private void initSchemaPartition() throws Exception {
InstanceLayout instanceLayout = service.getInstanceLayout();
File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
// Extract the schema on disk (a brand new one) and load the registries
if (schemaPartitionDirectory.exists()) {
LOG.debug("schema partition already exists, skipping schema extraction");
} else {
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
extractor.extractOrCopy();
}
SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
// We have to load the schema now, otherwise we won't be able
// to initialize the Partitions, as we won't be able to parse
// and normalize their suffix Dn
schemaManager.loadAllEnabled();
List<Throwable> errors = schemaManager.getErrors();
if (!errors.isEmpty()) {
throw new IllegalStateException(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
}
service.setSchemaManager(schemaManager);
// Init the LdifPartition with schema
LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.getDnFactory());
schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());
// The schema partition
SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
schemaPartition.setWrappedPartition(schemaLdifPartition);
service.setSchemaPartition(schemaPartition);
}
use of org.apache.directory.server.core.partition.ldif.LdifPartition in project camunda-bpm-platform by camunda.
the class LdapTestEnvironment method initSchemaPartition.
/**
* initialize the schema manager and add the schema partition to directory
* service
*
* @throws Exception if the schema LDIF files are not found on the classpath
*/
protected void initSchemaPartition() throws Exception {
InstanceLayout instanceLayout = service.getInstanceLayout();
File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
// Extract the schema on disk (a brand new one) and load the registries
if (schemaPartitionDirectory.exists()) {
LOG.log(Level.INFO, "schema partition already exists, skipping schema extraction");
} else {
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
extractor.extractOrCopy();
}
SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
// We have to load the schema now, otherwise we won't be able
// to initialize the Partitions, as we won't be able to parse
// and normalize their suffix Dn
schemaManager.loadAllEnabled();
List<Throwable> errors = schemaManager.getErrors();
if (!errors.isEmpty()) {
throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
}
service.setSchemaManager(schemaManager);
// Init the LdifPartition with schema
LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.getDnFactory());
schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());
// The schema partition
SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
schemaPartition.setWrappedPartition(schemaLdifPartition);
service.setSchemaPartition(schemaPartition);
}
use of org.apache.directory.server.core.partition.ldif.LdifPartition in project goodies by sonatype.
the class LdapServer method initPartitions.
private static void initPartitions(DefaultDirectoryService directoryService) throws Exception {
LdifPartition ldifPartition = new LdifPartition(directoryService.getSchemaManager(), directoryService.getDnFactory());
ldifPartition.setPartitionPath(new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "schema").toURI());
SchemaPartition schemaPartition = new SchemaPartition(directoryService.getSchemaManager());
schemaPartition.setWrappedPartition(ldifPartition);
directoryService.setSchemaPartition(schemaPartition);
PartitionFactory partitionFactory = new AvlPartitionFactory();
Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system"));
systemPartition.setSchemaManager(directoryService.getSchemaManager());
partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
directoryService.setSystemPartition(systemPartition);
Partition sonatypePartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "sonatype", "o=sonatype", 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "sonatype"));
sonatypePartition.setSchemaManager(directoryService.getSchemaManager());
partitionFactory.addIndex(sonatypePartition, SchemaConstants.OBJECT_CLASS_AT, 100);
directoryService.addPartition(sonatypePartition);
Partition groupsPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "groups", "ou=groups,dc=company,dc=com", 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "groups"));
groupsPartition.setSchemaManager(directoryService.getSchemaManager());
partitionFactory.addIndex(groupsPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
directoryService.addPartition(groupsPartition);
Partition usersPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "users", "ou=users,dc=company,dc=com", 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "users"));
usersPartition.setSchemaManager(directoryService.getSchemaManager());
partitionFactory.addIndex(usersPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
directoryService.addPartition(usersPartition);
Partition acmeBrickPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "acme_brick", "dc=acme brick,dc=com", 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "acme_brick"));
acmeBrickPartition.setSchemaManager(directoryService.getSchemaManager());
partitionFactory.addIndex(acmeBrickPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
directoryService.addPartition(acmeBrickPartition);
}
Aggregations