org.apache.directory.server.xdbm.Index Java Examples
The following examples show how to use
org.apache.directory.server.xdbm.Index.
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: ApacheDSStartStopListener.java From syncope with Apache License 2.0 | 6 votes |
/** * Add a new partition to the server. * * @param partitionId The partition Id * @param partitionDn The partition DN * @param dnFactory the DN factory * @return The newly added partition * @throws Exception If the partition can't be added */ private void addPartition(final String partitionId, final String partitionDn, final DnFactory dnFactory) throws Exception { // Create a new partition with the given partition id JdbmPartition partition = new JdbmPartition(service.getSchemaManager(), dnFactory); partition.setId(partitionId); partition.setPartitionPath(new File(service.getInstanceLayout().getPartitionsDirectory(), partitionId).toURI()); partition.setSuffixDn(new Dn(partitionDn)); service.addPartition(partition); Set<Index<?, String>> indexedAttributes = Stream.of( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.OU_AT, SchemaConstants.UID_AT, SchemaConstants.CN_AT). map(attr -> new JdbmIndex<String>(attr, false)).collect(Collectors.toSet()); partition.setIndexedAttributes(indexedAttributes); }
Example #2
Source File: LDAPServer.java From Benchmark with GNU General Public License v2.0 | 5 votes |
/** * Add a new set of index on the given attributes * * @param partition * The partition on which we want to add index * @param attrs * The list of attributes to index */ private void addIndex(Partition partition, String... attrs) { // Index some attributes on the apache partition HashSet<Index<?, ServerEntry, Long>> indexedAttributes = new HashSet<Index<?, ServerEntry, Long>>(); for (String attribute : attrs) { indexedAttributes.add(new JdbmIndex<String, ServerEntry>(attribute)); } ((JdbmPartition) partition).setIndexedAttributes(indexedAttributes); }
Example #3
Source File: EmbeddedADS.java From vertx-auth with Apache License 2.0 | 5 votes |
/** * Add a new set of index on the given attributes * * @param partition The partition on which we want to add index * @param attrs The list of attributes to index */ private void addIndex(Partition partition, String... attrs) { // Index some attributes on the apache partition HashSet<Index<?, ServerEntry, Long>> indexedAttributes = new HashSet<>(); for (String attribute : attrs) { indexedAttributes.add(new JdbmIndex<String, ServerEntry>(attribute)); } ((JdbmPartition) partition).setIndexedAttributes(indexedAttributes); }
Example #4
Source File: EmbeddedLdapServer.java From cloudstack with Apache License 2.0 | 5 votes |
/** * @return A map where the key is the attribute name the value is the * oid. */ public Map<String, String> getSystemIndexMap() throws IndexNotFoundException { Map<String, String> result = new LinkedHashMap<>(); Iterator<String> it = getBasePartition().getSystemIndices(); while (it.hasNext()) { String oid = it.next(); Index<?, String> index = getBasePartition().getSystemIndex(getDirectoryService().getSchemaManager().getAttributeType(oid)); result.put(index.getAttribute().getName(), index.getAttributeId()); } return result; }
Example #5
Source File: EmbeddedLdapServer.java From cloudstack with Apache License 2.0 | 5 votes |
/** * @return A map where the key is the attribute name the value is the * oid. */ public Map<String, String> getUserIndexMap() throws IndexNotFoundException { Map<String, String> result = new LinkedHashMap<>(); Iterator<String> it = getBasePartition().getUserIndices(); while (it.hasNext()) { String oid = it.next(); Index<?, String> index = getBasePartition().getUserIndex(getDirectoryService().getSchemaManager().getAttributeType(oid)); result.put(index.getAttribute().getName(), index.getAttributeId()); } return result; }
Example #6
Source File: ApacheDSUtils.java From aws-iam-ldap-bridge with Apache License 2.0 | 5 votes |
/** * Add a new set of index on the given attributes * * @param partition The partition on which we want to add index * @param attrs The list of attributes to index */ public void addIndex(Partition partition, String... attrs) { // Index some attributes on the apache partition Set<Index<?,String>> indexedAttributes = new HashSet<Index<?,String>>(); for ( String attribute : attrs ) { indexedAttributes.add( new JdbmIndex( attribute, false ) ); } ( ( JdbmPartition ) partition ).setIndexedAttributes( indexedAttributes ); }
Example #7
Source File: LdapTestEnvironment.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Add a new set of index on the given attributes * * @param partition The partition on which we want to add index * @param attrs The list of attributes to index */ protected void addIndex(Partition partition, String... attrs) { // Index some attributes on the apache partition Set<Index<?, String>> indexedAttributes = new HashSet<>(); for (String attribute : attrs) { indexedAttributes.add(new JdbmIndex<String>(attribute, false)); } ((JdbmPartition) partition).setIndexedAttributes(indexedAttributes); }
Example #8
Source File: MiniKdc.java From hadoop with Apache License 2.0 | 4 votes |
private void initDirectoryService() throws Exception { ds = new DefaultDirectoryService(); ds.setInstanceLayout(new InstanceLayout(workDir)); CacheService cacheService = new CacheService(); ds.setCacheService(cacheService); // first load the schema InstanceLayout instanceLayout = ds.getInstanceLayout(); File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema"); SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory()); extractor.extractOrCopy(); SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ds.setSchemaManager(schemaManager); // Init the LdifPartition with schema LdifPartition schemaLdifPartition = new LdifPartition(schemaManager); schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI()); // The schema partition SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(schemaLdifPartition); ds.setSchemaPartition(schemaPartition); JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager()); systemPartition.setId("system"); systemPartition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI()); systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN)); systemPartition.setSchemaManager(ds.getSchemaManager()); ds.setSystemPartition(systemPartition); ds.getChangeLog().setEnabled(false); ds.setDenormalizeOpAttrsEnabled(true); ds.addLast(new KeyDerivationInterceptor()); // create one partition String orgName= conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH); String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH); JdbmPartition partition = new JdbmPartition(ds.getSchemaManager()); partition.setId(orgName); partition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI()); partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain)); ds.addPartition(partition); // indexes Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>(); indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false)); indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false)); indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false)); partition.setIndexedAttributes(indexedAttributes); // And start the ds ds.setInstanceId(conf.getProperty(INSTANCE)); ds.startup(); // context entry, after ds.startup() Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain); Entry entry = ds.newEntry(dn); entry.add("objectClass", "top", "domain"); entry.add("dc", orgName); ds.getAdminSession().add(entry); }
Example #9
Source File: MiniKdc.java From big-c with Apache License 2.0 | 4 votes |
private void initDirectoryService() throws Exception { ds = new DefaultDirectoryService(); ds.setInstanceLayout(new InstanceLayout(workDir)); CacheService cacheService = new CacheService(); ds.setCacheService(cacheService); // first load the schema InstanceLayout instanceLayout = ds.getInstanceLayout(); File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema"); SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory()); extractor.extractOrCopy(); SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ds.setSchemaManager(schemaManager); // Init the LdifPartition with schema LdifPartition schemaLdifPartition = new LdifPartition(schemaManager); schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI()); // The schema partition SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(schemaLdifPartition); ds.setSchemaPartition(schemaPartition); JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager()); systemPartition.setId("system"); systemPartition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI()); systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN)); systemPartition.setSchemaManager(ds.getSchemaManager()); ds.setSystemPartition(systemPartition); ds.getChangeLog().setEnabled(false); ds.setDenormalizeOpAttrsEnabled(true); ds.addLast(new KeyDerivationInterceptor()); // create one partition String orgName= conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH); String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH); JdbmPartition partition = new JdbmPartition(ds.getSchemaManager()); partition.setId(orgName); partition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI()); partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain)); ds.addPartition(partition); // indexes Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>(); indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false)); indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false)); indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false)); partition.setIndexedAttributes(indexedAttributes); // And start the ds ds.setInstanceId(conf.getProperty(INSTANCE)); ds.startup(); // context entry, after ds.startup() Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain); Entry entry = ds.newEntry(dn); entry.add("objectClass", "top", "domain"); entry.add("dc", orgName); ds.getAdminSession().add(entry); }
Example #10
Source File: ApacheDirectoryPartitionManager.java From carbon-identity with Apache License 2.0 | 4 votes |
private JdbmPartition createNewPartition(String partitionId, String partitionSuffix) throws DirectoryServerException { try { JdbmPartition partition = new JdbmPartition(); String partitionDirectoryName = this.workingDirectory + File.separator + partitionId; File partitionDirectory = new File(partitionDirectoryName); partition.setId(partitionId); partition.setSuffix(partitionSuffix); partition.setPartitionDir(partitionDirectory); Set<Index<?, ServerEntry, Long>> indexedAttrs = new HashSet<Index<?, ServerEntry, Long>>(); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.1")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.2")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.3")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.4")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.5")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.6")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("1.3.6.1.4.1.18060.0.4.1.2.7")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("ou")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("dc")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("objectClass")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("cn")); indexedAttrs.add(new JdbmIndex<String, ServerEntry>("uid")); partition.setIndexedAttributes(indexedAttrs); String message = MessageFormat.format( "Partition created with following attributes, partition id - {0}, Partition " + "domain - {1}, Partition working directory {2}", partitionId, partitionSuffix, partitionDirectoryName); if (logger.isDebugEnabled()) { logger.debug(message); } return partition; } catch (LdapInvalidDnException e) { String msg = "Could not add a new partition with partition id " + partitionId + " and suffix " + partitionSuffix; logger.error(msg, e); throw new DirectoryServerException(msg, e); } }