Java Code Examples for org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition#setSuffix()

The following examples show how to use org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition#setSuffix() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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;
}