org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition Java Examples

The following examples show how to use org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition. 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 vote down vote up
/**
 * 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: LdapTestEnvironment.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #3
Source File: ApacheDSContainerWithSecurity.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
public ApacheDSContainerWithSecurity(String root, String ldifs) throws Exception {
	this.ldifResources = ldifs;
	service = new DefaultDirectoryService();
	List<Interceptor> list = new ArrayList<Interceptor>();

	list.add(new NormalizationInterceptor());
	list.add(new AuthenticationInterceptor());
	list.add(new ReferralInterceptor());
	// list.add( new AciAuthorizationInterceptor() );
	// list.add( new DefaultAuthorizationInterceptor() );
	list.add(new ExceptionInterceptor());
	// list.add( new ChangeLogInterceptor() );
	list.add(new OperationalAttributeInterceptor());
	// list.add( new SchemaInterceptor() );
	list.add(new SubentryInterceptor());
	// list.add( new CollectiveAttributeInterceptor() );
	// list.add( new EventInterceptor() );
	// list.add( new TriggerInterceptor() );
	// list.add( new JournalInterceptor() );

	service.setInterceptors(list);
	partition = new JdbmPartition();
	partition.setId("rootPartition");
	partition.setSuffix(root);
	this.root = root;
	service.addPartition(partition);
	service.setExitVmOnShutdown(false);
	service.setShutdownHookEnabled(false);
	service.getChangeLog().setEnabled(false);
	service.setDenormalizeOpAttrsEnabled(true);
}
 
Example #4
Source File: LdapTestEnvironment.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
protected 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(partitionDn));
  service.addPartition(partition);

  return partition;
}
 
Example #5
Source File: EmbeddedLdapServer.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, String defaultPartitionSuffix, int port)
        throws Exception{
    workingDirectory = new File(System.getProperty("java.io.tmpdir") + "/apacheds-test1");
    FileUtils.deleteDirectory(workingDirectory);

    DefaultDirectoryService directoryService = new DefaultDirectoryService();
    directoryService.setShutdownHookEnabled(true);
    directoryService.setAllowAnonymousAccess(true);

    directoryService.setWorkingDirectory(workingDirectory);
    directoryService.getChangeLog().setEnabled( false );

    JdbmPartition partition = new JdbmPartition();
    partition.setId(defaultPartitionName);
    partition.setSuffix(defaultPartitionSuffix);
    directoryService.addPartition(partition);

    directoryService.startup();

    // Inject the apache root entry if it does not already exist
    if ( !directoryService.getAdminSession().exists( partition.getSuffixDn() ) )
    {
        ServerEntry entry = directoryService.newEntry(new LdapDN(defaultPartitionSuffix));
        entry.add("objectClass", "top", "domain", "extensibleObject");
        entry.add("dc", defaultPartitionName);
        directoryService.getAdminSession().add( entry );
    }

    LdapServer ldapServer = new LdapServer();
    ldapServer.setDirectoryService(directoryService);

    TcpTransport ldapTransport = new TcpTransport(port);
    ldapServer.setTransports( ldapTransport );
    ldapServer.start();

    return new EmbeddedLdapServer(directoryService, ldapServer);
}
 
Example #6
Source File: ApacheDSUtils.java    From aws-iam-ldap-bridge with Apache License 2.0 5 votes vote down vote up
/**
 * 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: ApacheDSUtils.java    From aws-iam-ldap-bridge with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #8
Source File: EmbeddedADS.java    From vertx-auth with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #9
Source File: EmbeddedADS.java    From vertx-auth with Apache License 2.0 5 votes vote down vote up
/**
 * Add a new partition to the server
 *
 * @param partitionId The partition Id
 * @param partitionDn The partition DN
 * @return The newly added partition
 * @throws Exception If the partition can't be added
 */
private Partition addPartition(String partitionId, String partitionDn) throws Exception {
  // Create a new partition named 'foo'.
  JdbmPartition partition = new JdbmPartition();
  partition.setId(partitionId);
  partition.setPartitionDir(new File(service.getWorkingDirectory(), partitionId));
  partition.setSuffix(partitionDn);
  service.addPartition(partition);

  return partition;
}
 
Example #10
Source File: LDAPServer.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #11
Source File: LdapTestServer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Add a new partition to the server
 *
 * @param partitionId
 *          The partition Id
 * @param partitionDn
 *          The partition DN
 * @return The newly added partition
 *
 * @throws Exception
 *           If the partition can't be added
 */
private Partition addPartition(String partitionId, String partitionDn)
    throws Exception {
  // Create a new partition named 'foo'.
  JdbmPartition partition = new JdbmPartition();
  partition.setId(partitionId);
  partition.setPartitionDir(
      new File(service.getWorkingDirectory(), partitionId));
  partition.setSuffix(partitionDn);
  service.addPartition(partition);

  return partition;
}
 
Example #12
Source File: EmbeddedLdapServer.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
private static Partition addPartition(
    DirectoryService service, String partitionId, String partitionDn) throws Exception {
  final JdbmPartition partition = new JdbmPartition();
  partition.setId(partitionId);
  partition.setPartitionDir(new File(service.getWorkingDirectory(), partitionId));
  partition.setSuffix(partitionDn);
  service.addPartition(partition);
  return partition;
}
 
Example #13
Source File: EmbeddedADS.java    From easybuggy with Apache License 2.0 5 votes vote down vote up
private static Partition addPartition(String partitionId, String partitionDn) throws Exception {
    // Create a new partition named
    Partition partition = new JdbmPartition();
    partition.setId(partitionId);
    partition.setSuffix(partitionDn);
    service.addPartition(partition);
    return partition;
}
 
Example #14
Source File: LdapTestServer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Add a new partition to the server
 *
 * @param partitionId
 *          The partition Id
 * @param partitionDn
 *          The partition DN
 * @return The newly added partition
 *
 * @throws Exception
 *           If the partition can't be added
 */
private Partition addPartition(String partitionId, String partitionDn)
    throws Exception {
  // Create a new partition named 'foo'.
  JdbmPartition partition = new JdbmPartition();
  partition.setId(partitionId);
  partition.setPartitionDir(
      new File(service.getWorkingDirectory(), partitionId));
  partition.setSuffix(partitionDn);
  service.addPartition(partition);

  return partition;
}
 
Example #15
Source File: ApacheDirectoryPartitionManager.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void addPartition(PartitionInfo partitionInformation)
        throws DirectoryServerException {

    try {
        JdbmPartition partition = createNewPartition(partitionInformation.getPartitionId(),
                partitionInformation.getRootDN());
        this.directoryService.addPartition(partition);

        CoreSession adminSession = this.directoryService.getAdminSession();

        if (!adminSession.exists(partition.getSuffixDn())) {

            addPartitionAttributes(partitionInformation.getRootDN(), partitionInformation.
                            getObjectClasses(), partitionInformation.getRealm(),
                    partitionInformation.getPreferredDomainComponent());

            // Create user ou
            addUserStoreToPartition(partition.getSuffix());

            // Create group ou
            addGroupStoreToPartition(partition.getSuffix());

            //Creates the shared groups ou
            addSharedGroupToPartition(partition.getSuffix());

            /*do not create admin user and admin group because it is anyway checked and created
             *in user core.*/

            // create tenant administrator entry at the time of tenant-partition created.
            addAdmin(partitionInformation.getPartitionAdministrator(), partition.getSuffix(),
                    partitionInformation.getRealm(), partitionInformation.isKdcEnabled());
            addAdminGroup(partitionInformation.getPartitionAdministrator(), partition.getSuffix());

            addAdminACLEntry(partitionInformation.getPartitionAdministrator().getAdminUserName(),
                    partition.getSuffix());

            this.directoryService.sync();
        }


    } catch (Exception e) {
        String errorMessage = "Could not add the partition";
        logger.error(errorMessage, e);
        throw new DirectoryServerException(errorMessage, e);

    }
}
 
Example #16
Source File: ApacheDirectoryPartitionManager.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
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);
    }
}
 
Example #17
Source File: EmbeddedLdapServer.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
public JdbmPartition getBasePartition() {
    return _basePartition;
}
 
Example #18
Source File: EmbeddedLdapServer.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
public void setBasePartition(JdbmPartition basePartition) {
    this._basePartition = basePartition;
}
 
Example #19
Source File: MiniKdc.java    From big-c with Apache License 2.0 4 votes vote down vote up
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 #20
Source File: LdapTestEnvironment.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the server. It creates the partition, adds the index, and
 * injects the context entries for the created partitions.
 *
 * @throws Exception if there were some problems while initializing the system
 */
protected void initializeDirectory() throws Exception {

  workingDirectory.mkdirs();

  service = new DefaultDirectoryService();
  InstanceLayout il = new InstanceLayout(workingDirectory);
  service.setInstanceLayout(il);

  CacheService cacheService = new CacheService();
  cacheService.initialize(service.getInstanceLayout());
  service.setCacheService(cacheService);

  initSchemaPartition();

  // then the system partition
  // this is a MANDATORY partition
  // DO NOT add this via addPartition() method, trunk code complains about duplicate partition
  // while initializing
  JdbmPartition systemPartition = new JdbmPartition(service.getSchemaManager(), service.getDnFactory());
  systemPartition.setId("system");
  systemPartition.setPartitionPath(new File(service.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI());
  systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
  systemPartition.setSchemaManager(service.getSchemaManager());

  // mandatory to call this method to set the system partition
  // Note: this system partition might be removed from trunk
  service.setSystemPartition(systemPartition);

  // Disable the ChangeLog system
  service.getChangeLog().setEnabled(false);
  service.setDenormalizeOpAttrsEnabled(true);

  Partition camundaPartition = addPartition("camunda", BASE_DN, service.getDnFactory());
  addIndex(camundaPartition, "objectClass", "ou", "uid");

  service.startup();

  // Create the root entry
  if (!service.getAdminSession().exists(camundaPartition.getSuffixDn())) {
    Dn dn = new Dn(BASE_DN);
    Entry entry = service.newEntry(dn);
    entry.add("objectClass", "top", "domain", "extensibleObject");
    entry.add("dc", "camunda");
    service.getAdminSession().add(entry);
  }
}
 
Example #21
Source File: MiniKdc.java    From hadoop with Apache License 2.0 4 votes vote down vote up
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 #22
Source File: LDAPServer.java    From Benchmark with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Add a new partition to the server
 *
 * @param partitionId
 *            The partition Id
 * @param partitionDn
 *            The partition DN
 * @return The newly added partition
 * @throws Exception
 *             If the partition can't be added
 */
private Partition addPartition(String partitionId, String partitionDn) throws Exception {
	// Create a new partition named 'foo'.
	JdbmPartition partition = new JdbmPartition();
	partition.setId(partitionId);
	partition.setPartitionDir(new File(service.getWorkingDirectory(), partitionId));
	partition.setSuffix(partitionDn);
	service.addPartition(partition);

	return partition;
}