org.apache.directory.server.core.api.partition.Partition Java Examples
The following examples show how to use
org.apache.directory.server.core.api.partition.Partition.
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: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException { Dn dn = hasEntryContext.getDn(); if ( IS_DEBUG ) { LOG.debug( "Check if Dn '" + dn + "' exists." ); } if ( dn.isRootDse() ) { return true; } Partition partition = getPartition( dn ); return partition.hasEntry( hasEntryContext ); }
Example #2
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void modify( ModifyOperationContext modifyContext ) throws LdapException { // Special case : if we don't have any modification to apply, just return if ( modifyContext.getModItems().size() == 0 ) { return; } Partition partition = getPartition( modifyContext.getDn() ); partition.modify( modifyContext ); if ( modifyContext.isPushToEvtInterceptor() ) { directoryService.getInterceptor( InterceptorEnum.EVENT_INTERCEPTOR.getName() ).modify( modifyContext ); } }
Example #3
Source File: LdapService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Add a new partition to the directory server. * * @param partitionName - The name of the partition. * @param indexes - The attributes to index. * @return This Builder for subsequent changes. */ public Builder addPartition(final String id, final String partitionName, final int indexSize, final String ... indexes) throws Exception { assertNotStarted(); if (directoryService == null) { throw new IllegalStateException("The Directory service has not been created."); } SchemaManager schemaManager = directoryService.getSchemaManager(); PartitionFactory partitionFactory = directoryServiceFactory.getPartitionFactory(); Partition partition = partitionFactory.createPartition(schemaManager, directoryService.getDnFactory(), id, partitionName, 1000, workingDir); for (String current : indexes) { partitionFactory.addIndex(partition, current, indexSize); } partition.setCacheService(directoryService.getCacheService()); partition.initialize(); directoryService.addPartition(partition); return this; }
Example #4
Source File: ApacheDSStartStopListener.java From syncope with Apache License 2.0 | 6 votes |
private void initSystemPartition() throws Exception { JdbmPartitionFactory partitionFactory = new JdbmPartitionFactory(); Partition systemPartition = partitionFactory.createPartition( service.getSchemaManager(), service.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(service.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(service.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); service.setSystemPartition(systemPartition); }
Example #5
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public Entry delete( DeleteOperationContext deleteContext ) throws LdapException { Partition partition = getPartition( deleteContext.getDn() ); Entry deletedEntry = partition.delete( deleteContext ); Entry entry = deleteContext.getEntry(); // MyVD doesn't care about csn // Attribute csn = entry.get( ENTRY_CSN_AT ); // can be null while doing subentry deletion // //TODO verify if this gets in the way of replication // if ( csn != null ) // { // directoryService.setContextCsn( csn.getString() ); // } return deletedEntry; }
Example #6
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException { Dn dn = hasEntryContext.getDn(); if ( IS_DEBUG ) { LOG.debug( "Check if Dn '" + dn + "' exists." ); } if ( dn.isRootDse() ) { return true; } Partition partition = getPartition( dn ); return partition.hasEntry( hasEntryContext ); }
Example #7
Source File: Runner.java From aws-iam-ldap-bridge with Apache License 2.0 | 6 votes |
public void createStructure() throws Exception { String rootDN = AWSIAMAuthenticator.getConfig().rootDN; Dn dnIAM = service.getDnFactory().create(rootDN); if (!utils.exists(dnIAM)) { IAM_LOG.info("Creating partition " + rootDN); Partition iamPartition = utils.addPartition("iam", rootDN, service.getDnFactory()); // Index some attributes on the apache partition utils.addIndex(iamPartition, "objectClass", "ou", "uid", "gidNumber", "uidNumber", "cn"); if (!utils.exists(dnIAM)) { IAM_LOG.info("Creating root node " + rootDN); Rdn rdn = dnIAM.getRdn(0); Entry entryIAM = new DefaultEntry(service.getSchemaManager(), dnIAM, "objectClass: top", "objectClass: domain", "entryCsn: " + service.getCSN(), SchemaConstants.ENTRY_UUID_AT + ": " + UUID.randomUUID().toString(), rdn.getType() + ": " + rdn.getValue()); service.getAdminSession().add(entryIAM); checkErrors(); } } service.sync(); }
Example #8
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void modify( ModifyOperationContext modifyContext ) throws LdapException { // Special case : if we don't have any modification to apply, just return if ( modifyContext.getModItems().size() == 0 ) { return; } Partition partition = getPartition( modifyContext.getDn() ); partition.modify( modifyContext ); if ( modifyContext.isPushToEvtInterceptor() ) { directoryService.getInterceptor( InterceptorEnum.EVENT_INTERCEPTOR.getName() ).modify( modifyContext ); } Entry alteredEntry = modifyContext.getAlteredEntry(); if ( alteredEntry != null ) { // MyVD doesn't care about csn // directoryService.setContextCsn( alteredEntry.get( ENTRY_CSN_AT ).getString() ); } }
Example #9
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public Partition getPartition( Dn dn ) throws LdapException { Partition parent = null; if ( !dn.isSchemaAware() ) { dn.apply( schemaManager ); } synchronized ( partitionLookupTree ) { parent = partitionLookupTree.getElement( dn ); } if ( parent == null ) { throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_268, dn ) ); } else { return parent; } }
Example #10
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException { Dn base = searchContext.getDn(); // TODO since we're handling the *, and + in the EntryFilteringCursor // we may not need this code: we need see if this is actually the // case and remove this code. if ( base.size() == 0 ) { return searchFromRoot( searchContext ); } // Not sure we need this code... base.apply( schemaManager ); // Normal case : do a search on the specific partition Partition backend = getPartition( base ); return backend.search( searchContext ); }
Example #11
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public Partition getPartition( Dn dn ) throws LdapException { Partition parent = null; synchronized ( partitionLookupTree ) { parent = partitionLookupTree.getElement( dn ); } if ( parent == null ) { throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_268, dn ) ); } else { return parent; } }
Example #12
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException { Dn base = searchContext.getDn(); // TODO since we're handling the *, and + in the EntryFilteringCursor // we may not need this code: we need see if this is actually the // case and remove this code. if ( base.size() == 0 ) { return searchFromRoot( searchContext ); } // Not sure we need this code... base.apply( schemaManager ); // Normal case : do a search on the specific partition Partition backend = getPartition( base ); return backend.search( searchContext ); }
Example #13
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void move( MoveOperationContext moveContext ) throws LdapException { // Get the current partition Partition partition = getPartition( moveContext.getDn() ); partition.move( moveContext ); Entry entry = moveContext.getModifiedEntry(); // MyVD doesn't care about csn // directoryService.setContextCsn( entry.get( ENTRY_CSN_AT ).getString() ); }
Example #14
Source File: ApacheDirectoryServer.java From light-oauth2 with Apache License 2.0 | 5 votes |
private static void createPartition(final DirectoryServiceFactory dsf, final SchemaManager schemaManager, final String id, final String suffix) throws Exception { PartitionFactory pf = dsf.getPartitionFactory(); Partition p = pf.createPartition(schemaManager, id, suffix, 1000, workingDir.toFile()); pf.addIndex(p, "krb5PrincipalName", 10); p.initialize(); directoryService.addPartition(p); }
Example #15
Source File: ApacheDirectoryServer.java From light-oauth2 with Apache License 2.0 | 5 votes |
private static void createPartition(final DirectoryServiceFactory dsf, final SchemaManager schemaManager, final String id, final String suffix) throws Exception { PartitionFactory pf = dsf.getPartitionFactory(); Partition p = pf.createPartition(schemaManager, id, suffix, 1000, workingDir.toFile()); pf.addIndex(p, "krb5PrincipalName", 10); p.initialize(); directoryService.addPartition(p); }
Example #16
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void add( AddOperationContext addContext ) throws LdapException { Partition partition = getPartition( addContext.getDn() ); partition.add( addContext ); // MyVD doesn't care about csn // Attribute at = addContext.getEntry().get( SchemaConstants.ENTRY_CSN_AT ); // directoryService.setContextCsn( at.getString() ); }
Example #17
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Entry lookup( LookupOperationContext lookupContext ) throws LdapException { Dn dn = lookupContext.getDn(); if ( dn.equals( subschemSubentryDn ) ) { return new ClonedServerEntry( rootDse.clone() ); } // This is for the case we do a lookup on the rootDSE if ( dn.isRootDse() ) { Entry retval = new ClonedServerEntry( rootDse ); return retval; } Partition partition = getPartition( dn ); Entry entry = partition.lookup( lookupContext ); if ( entry == null ) { LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: " + dn.getName() ); throw e; } return entry; }
Example #18
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void rename( RenameOperationContext renameContext ) throws LdapException { Partition partition = getPartition( renameContext.getDn() ); partition.rename( renameContext ); Entry entry = renameContext.getModifiedEntry(); // MyVD doesn't care about csn // directoryService.setContextCsn( entry.get( ENTRY_CSN_AT ).getString() ); }
Example #19
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException { Partition partition = getPartition( moveAndRenameContext.getDn() ); partition.moveAndRename( moveAndRenameContext ); Entry entry = moveAndRenameContext.getModifiedEntry(); // MyVD doesn't care about csn // directoryService.setContextCsn( entry.get( ENTRY_CSN_AT ).getString() ); }
Example #20
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
public void sync() throws Exception { MultiException error = null; for ( Partition partition : this.partitions.values() ) { try { partition.saveContextCsn(); partition.sync(); } catch ( Exception e ) { LOG.warn( "Failed to flush partition data out.", e ); if ( error == null ) { //noinspection ThrowableInstanceNeverThrown error = new MultiException( I18n.err( I18n.ERR_265 ) ); } // @todo really need to send this info to a monitor error.addThrowable( e ); } } if ( error != null ) { throw error; } }
Example #21
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 #22
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Entry delete( DeleteOperationContext deleteContext ) throws LdapException { Partition partition = getPartition( deleteContext.getDn() ); Entry deletedEntry = partition.delete( deleteContext ); return deletedEntry; }
Example #23
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void move( MoveOperationContext moveContext ) throws LdapException { // Get the current partition Partition partition = getPartition( moveContext.getDn() ); partition.move( moveContext ); }
Example #24
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 #25
Source File: ApacheDSUtils.java From aws-iam-ldap-bridge with Apache License 2.0 | 5 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 */ public Partition addPartition(String partitionId, String partitionDn, 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(service.getSchemaManager(), partitionDn)); partition.initialize(); service.addPartition( partition ); return partition; }
Example #26
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void unbind( UnbindOperationContext unbindContext ) throws LdapException { Dn unbindContextDn = unbindContext.getDn(); if ( !Dn.isNullOrEmpty( unbindContextDn ) ) { Partition partition = getPartition( unbindContext.getDn() ); partition.unbind( unbindContext ); } }
Example #27
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Dn getSuffixDn( Dn dn ) throws LdapException { Partition partition = getPartition( dn ); return partition.getSuffixDn(); }
Example #28
Source File: Runner.java From aws-iam-ldap-bridge with Apache License 2.0 | 5 votes |
public Partition getPartition(DirectoryService directory, String id) throws LdapException { Set<? extends Partition> partitions = directory.getPartitions(); for (Partition part : partitions) { if (part.getId().equalsIgnoreCase(id)) return part; } throw new LdapException("No partition with the ID " + id); }
Example #29
Source File: KerberosKDCUtil.java From quarkus-http with Apache License 2.0 | 5 votes |
private static void createPartition(final DirectoryServiceFactory dsf, final SchemaManager schemaManager, final String id, final String suffix) throws Exception { PartitionFactory pf = dsf.getPartitionFactory(); Partition p = pf.createPartition(schemaManager, id, suffix, 1000, workingDir.toFile()); pf.addIndex(p, "krb5PrincipalName", 10); p.initialize(); directoryService.addPartition(p); }
Example #30
Source File: LdapTestSuite.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void createPartition(final DirectoryServiceFactory dsf, final SchemaManager schemaManager, final String id, final String suffix, final DirectoryService directoryService, final File workingDir) throws Exception { PartitionFactory pf = dsf.getPartitionFactory(); Partition p = pf.createPartition(schemaManager, id, suffix, 1000, workingDir); pf.addIndex(p, "uid", 10); pf.addIndex(p, "departmentNumber", 10); pf.addIndex(p, "member", 10); pf.addIndex(p, "memberOf", 10); p.initialize(); directoryService.addPartition(p); }