org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader Java Examples
The following examples show how to use
org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubtreeSpecificationParserTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Initialization */ @BeforeAll public static void init() throws Exception { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); schemaManager = new DefaultSchemaManager( loader ); schemaManager.loadAllEnabled(); parser = new SubtreeSpecificationParser( schemaManager ); topOC = schemaManager.lookupObjectClassRegistry( "top" ); aliasOC = schemaManager.lookupObjectClassRegistry( "alias" ); countryOC = schemaManager.lookupObjectClassRegistry( "country" ); personOC = schemaManager.lookupObjectClassRegistry( "person" ); }
Example #2
Source File: ApiLdapSchemaDataOsgiTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Override protected void useBundleClasses() throws LdapException, IOException { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); loader.getAllEnabled(); loader.getAllSchemas(); SchemaManager schemaManager = new DefaultSchemaManager(); schemaManager.getEnabled(); schemaManager.getDisabled(); }
Example #3
Source File: ACIItemParserTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Initialization */ @BeforeAll public static void init() throws Exception { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager( loader ); schemaManager.loadAllEnabled(); parser = new ACIItemParser( schemaManager ); }
Example #4
Source File: ACIItemCheckerTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Initialization */ @BeforeAll public static void init() throws Exception { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager( loader ); schemaManager.loadAllEnabled(); checker = new ACIItemChecker( schemaManager ); }
Example #5
Source File: SubtreeSpecificationSyntaxCheckerTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Initialization */ @BeforeAll public static void init() throws Exception { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager( loader ); schemaManager.loadAllEnabled(); checker = SubtreeSpecificationSyntaxChecker.INSTANCE; checker.setSchemaManager( schemaManager ); }
Example #6
Source File: ACIItemSyntaxCheckerTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@BeforeAll 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 ); }
Example #7
Source File: DefaultSchemaManager.java From directory-ldap-api with Apache License 2.0 | 5 votes |
private static SchemaLoader jarLdifSchemaLoader() { try { return new JarLdifSchemaLoader(); } catch ( LdapException | IOException e ) { LOG.error( I18n.err( I18n.ERR_16080_SCHEMA_LOADER_CANT_BE_CREATED, e.getMessage() ) ); throw new RuntimeException( e.getMessage() ); } }
Example #8
Source File: JarLdifSchemaLoaderTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testJarLdifSchemaLoader() throws Exception { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager sm = new DefaultSchemaManager( loader ); sm.loadWithDeps( "system" ); assertTrue( sm.getRegistries().getAttributeTypeRegistry().contains( "cn" ) ); assertFalse( sm.getRegistries().getAttributeTypeRegistry().contains( "m-aux" ) ); sm.loadWithDeps( "apachemeta" ); assertTrue( sm.getRegistries().getAttributeTypeRegistry().contains( "m-aux" ) ); }
Example #9
Source File: InMemoryDirectoryServiceFactory.java From bouncr with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig)); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition 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); directoryService.startup(); }
Example #10
Source File: InMemoryDirectoryServiceFactory.java From activemq-artemis with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService == null) || directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30).timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig)); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition 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); directoryService.startup(); }
Example #11
Source File: EmbeddedLdapServer.java From cloudstack with Apache License 2.0 | 3 votes |
/** * Add additional schemas to the directory server. This uses * JarLdifSchemaLoader, which will search for the "ou=schema" directory * within "/schema" on the classpath. If packaging the schema as part of * a jar using Gradle or Maven, you'd probably want to put your * "ou=schema" directory in src/main/resources/schema. * <p/> * It's also required that a META-INF/apacheds-schema.index be present in * your classpath that lists each LDIF file in your schema directory. * * @param schemaName The name of the schema * @return true if the schemas have been loaded and the registries is * consistent */ public boolean addSchemaFromClasspath(String schemaName) throws LdapException, IOException { // To debug if your apacheds-schema.index isn't found: // Enumeration<URL> indexes = getClass().getClassLoader().getResources("META-INF/apacheds-schema.index"); JarLdifSchemaLoader schemaLoader = new JarLdifSchemaLoader(); Schema schema = schemaLoader.getSchema(schemaName); return schema != null && getDirectoryService().getSchemaManager().load(schema); }