• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ServerDNConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.directory.server.constants.ServerDNConstants的典型用法代码示例。如果您正苦于以下问题:Java ServerDNConstants类的具体用法?Java ServerDNConstants怎么用?Java ServerDNConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerDNConstants类属于org.apache.directory.server.constants包,在下文中一共展示了ServerDNConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createLdapConfiguration

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Creates the ldap configuration.
 *
 * @return the authentication configuration
 * @throws Exception
 *             Exception.
 */
public LdapConfiguration createLdapConfiguration() throws Exception {
    LdapConfiguration config = LdapConfiguration.Factory.newInstance();
    config.setAllowExternalAuthentication(false);
    config.setPrimaryAuthentication(false);
    config.setUrl(getEnvironment().get(Context.PROVIDER_URL).toString());
    config.setManagerDN(ServerDNConstants.ADMIN_SYSTEM_DN);
    config.setManagerPassword(LDAP_MANAGER_PASSWORD);
    config.setUserSearch(LdapSearchConfiguration.Factory.newInstance());
    config.getUserSearch().setPropertyMapping(LDAP_PROPERTY_MAPPING);
    config.getUserSearch().setSearchFilter(LDAP_SEARCH_FILTER);
    LdapSearchBaseDefinition searchBaseDef = LdapSearchBaseDefinition.Factory.newInstance();
    searchBaseDef.setSearchBase(LDAP_SEARCH_BASE);
    searchBaseDef.setSearchSubtree(LDAP_SEARCH_SUBTREE);
    config.getUserSearch().getSearchBases().add(searchBaseDef);
    config.setSystemId(EXTERNAL_SYSTEM_ID);
    return config;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:25,代码来源:LdapCommunoteIntegrationTest.java


示例2: setUp

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Get's the initial context factory for the provider's ou=system context root.
 *
 * @throws Exception
 *             if there is a failure of any kind
 */
protected void setUp() throws Exception {
    setStart(getStart() + 1);
    setDirectoryService(new DefaultDirectoryService());
    getDirectoryService().setShutdownHookEnabled(false);
    setPort(AvailablePortFinder.getNextAvailable(1024));
    setLdapServer(new LdapServer());
    getLdapServer().setTransports(new TcpTransport(getPort()));
    getLdapServer().setDirectoryService(getDirectoryService());

    setupSaslMechanisms(getLdapServer());
    getDirectoryService().setWorkingDirectory(
            new File("target" + File.separator + "server-work"));
    doDelete(getDirectoryService().getWorkingDirectory());
    configureDirectoryService();
    getDirectoryService().startup();

    configureLdapServer();

    // TODO shouldn't this be before calling configureLdapServer() ???
    getLdapServer().addExtendedOperationHandler(new StartTlsHandler());
    getLdapServer().addExtendedOperationHandler(new StoredProcedureExtendedOperationHandler());

    getLdapServer().start();
    setContexts(ServerDNConstants.ADMIN_SYSTEM_DN, "secret");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:32,代码来源:AbstractApacheDSServer.java


示例3: initSystemPartition

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Inits the system partition.
 *
 * @throws Exception the exception
 */
private void initSystemPartition()
        throws Exception {
    // change the working apacheds to something that is unique
    // on the system and somewhere either under target apacheds
    // or somewhere in a temp area of the machine.

    // Inject the System Partition
    Partition systemPartition = partitionFactory.createPartition(
            "system", ServerDNConstants.SYSTEM_DN, PARTITION_CACHE_SIZE,
            new File(directoryService.getWorkingDirectory(), "system"));
    systemPartition.setSchemaManager(directoryService.getSchemaManager());

    partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT,
            INDEX_CACHE_SIZE);

    directoryService.setSystemPartition(systemPartition);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:23,代码来源:CarbonDirectoryServiceFactory.java


示例4: startKerberos

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
@SuppressWarnings("unused")
private ApacheDS startKerberos() throws Exception {
  Preconditions.checkState(ldapServer.isStarted());

  kdcServer.setDirectoryService(directoryService);
  // FIXME hard-coded ports
  kdcServer.setTransports(new TcpTransport(6088), new UdpTransport(6088));
  kdcServer.setEnabled(true);
  kdcServer.setPrimaryRealm(realm);
  kdcServer.setSearchBaseDn(baseDn);
  kdcServer.setKdcPrincipal("krbtgt/" + realm + "@" + baseDn);
  kdcServer.start();

  // -------------------------------------------------------------------
  // Enable the krb5kdc schema
  // -------------------------------------------------------------------

  Hashtable<String, Object> env = new Hashtable<String, Object>();
  env.put(DirectoryService.JNDI_KEY, directoryService);
  env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());
  env.put(Context.PROVIDER_URL, ServerDNConstants.OU_SCHEMA_DN);
  InitialLdapContext schemaRoot = new InitialLdapContext(env, null);

  // check if krb5kdc is disabled
  Attributes krb5kdcAttrs = schemaRoot.getAttributes("cn=Krb5kdc");
  boolean isKrb5KdcDisabled = false;
  if (krb5kdcAttrs.get("m-disabled") != null) {
    isKrb5KdcDisabled = ((String) krb5kdcAttrs.get("m-disabled").get()).equalsIgnoreCase("TRUE");
  }

  // if krb5kdc is disabled then enable it
  if (isKrb5KdcDisabled) {
    Attribute disabled = new BasicAttribute("m-disabled");
    ModificationItem[] mods = new ModificationItem[] {new ModificationItem(DirContext.REMOVE_ATTRIBUTE, disabled)};
    schemaRoot.modifyAttributes("cn=Krb5kdc", mods);
  }
  return this;
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:39,代码来源:ApacheDS.java


示例5: isAdministrator

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * TODO - perhaps we should just use a flag that is calculated on creation
 * of this session
 * 
 * @see org.apache.directory.server.core.api.CoreSession#isAdministrator()
 */
public boolean isAdministrator()
{
    String normName = getEffectivePrincipal().getName();

    return normName.equals( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:13,代码来源:DefaultCoreSession.java


示例6: DefaultPartitionNexus

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Creates the root nexus singleton of the entire system.  The root DSE has
 * several attributes that are injected into it besides those that may
 * already exist.  As partitions are added to the system more namingContexts
 * attributes are added to the rootDSE.
 *
 * @see <a href="http://www.faqs.org/rfcs/rfc3045.html">Vendor Information</a>
 * @param rootDse the root entry for the DSA
 * @throws javax.naming.Exception on failure to initialize
 */
public DefaultPartitionNexus( Entry rootDse ) throws Exception
{
    id = ID;
    suffixDn = null;

    // setup that root DSE
    this.rootDse = rootDse;

    // Add the basic informations
    rootDse.put( SchemaConstants.SUBSCHEMA_SUBENTRY_AT, ServerDNConstants.CN_SCHEMA_DN );
    rootDse.put( SchemaConstants.SUPPORTED_LDAP_VERSION_AT, "3" );
    rootDse.put( SchemaConstants.SUPPORTED_FEATURES_AT, SchemaConstants.FEATURE_ALL_OPERATIONAL_ATTRIBUTES );
    rootDse.put( SchemaConstants.SUPPORTED_EXTENSION_AT, NoticeOfDisconnect.EXTENSION_OID );

    // Add the objectClasses
    rootDse.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );

    // Add the 'vendor' name and version infos
    rootDse.put( SchemaConstants.VENDOR_NAME_AT, ASF );

    Properties props = new Properties();

    try
    {
        props.load( getClass().getResourceAsStream( "version.properties" ) );
    }
    catch ( IOException e )
    {
        LOG.error( I18n.err( I18n.ERR_33 ) );
    }

    rootDse.put( SchemaConstants.VENDOR_VERSION_AT, props.getProperty( "apacheds.version", "UNKNOWN" ) );

    // The rootDSE uuid has been randomly created
    rootDse.put( SchemaConstants.ENTRY_UUID_AT, "f290425c-8272-4e62-8a67-92b06f38dbf5" );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:47,代码来源:DefaultPartitionNexus.java


示例7: createGroupConfiguration

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Create the group configuration of ldap.
 *
 * @param memberMode
 *            Set to true for memberMode.
 * @param binaryGroupIdentifier
 *            Set to true if the group identifier is binary.
 * @param synchronizationAttribute
 *            The synchronization attribute.
 * @return {@link LdapConfiguration}.
 * @throws Exception
 *             Exception.
 */
public LdapConfiguration createGroupConfiguration(boolean memberMode,
        boolean binaryGroupIdentifier, String synchronizationAttribute) throws Exception {
    LdapSearchBaseDefinition searchBase = LdapSearchBaseDefinition.Factory.newInstance();
    searchBase.setSearchBase("ou=Groups,dc=communote,dc=com");
    List<LdapSearchBaseDefinition> searchBases = new ArrayList<LdapSearchBaseDefinition>();
    searchBases.add(searchBase);
    LdapSearchConfiguration groupSearchConfiguration = LdapSearchConfiguration.Factory
            .newInstance();
    groupSearchConfiguration.setPropertyMapping(LdapGroupAttribute.NAME + "=cn,"
            + LdapGroupAttribute.ALIAS + "=cn," + LdapGroupAttribute.DESCRIPTION
            + "=description," + LdapGroupAttribute.UID + "=cn," + LdapGroupAttribute.MEMBERSHIP
            + "=" + synchronizationAttribute);
    groupSearchConfiguration.setSearchBases(searchBases);
    groupSearchConfiguration.setSearchFilter("objectClass=*");
    LdapGroupSyncConfiguration groupConfiguration = LdapGroupSyncConfiguration.Factory
            .newInstance();
    groupConfiguration.setGroupIdentifierIsBinary(binaryGroupIdentifier);
    groupConfiguration.setMemberMode(memberMode);
    groupConfiguration.setGroupSearch(groupSearchConfiguration);
    LdapConfiguration configuration = LdapConfiguration.Factory.newInstance();
    configuration.setManagerDN(ServerDNConstants.ADMIN_SYSTEM_DN);
    configuration.setManagerPassword("secret");
    configuration.setSystemId(EXTERNAL_SYSTEM_ID);
    configuration.setGroupSyncConfig(groupConfiguration);
    configuration.setUrl(getEnvironment().get(Context.PROVIDER_URL).toString());
    configuration.setUserSearch(createLdapConfiguration().getUserSearch());
    return configuration;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:42,代码来源:LdapCommunoteIntegrationTest.java


示例8: setContexts

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Sets the contexts of this class taking into account the extras and overrides properties.
 *
 * @param env
 *            an environment to use while setting up the system root.
 * @throws Exception
 *             if there is a failure of any kind
 */
protected void setContexts(Hashtable<String, Object> env) throws Exception {
    Hashtable<String, Object> envFinal = new Hashtable<String, Object>(env);
    envFinal.put(Context.PROVIDER_URL, ServerDNConstants.SYSTEM_DN);
    setSysRoot(new InitialLdapContext(envFinal, null));

    envFinal.put(Context.PROVIDER_URL, "");
    setRootDSE(getDirectoryService().getAdminSession());

    envFinal.put(Context.PROVIDER_URL, ServerDNConstants.OU_SCHEMA_DN);
    setSchemaRoot(new InitialLdapContext(envFinal, null));
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:20,代码来源:AbstractApacheDSServer.java


示例9: getWiredContext

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
private LdapContext getWiredContext(int port) throws Exception {
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + port);
    env.put(Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN);
    env.put(Context.SECURITY_CREDENTIALS, "secret");
    LdapApiService ldapApiService = new StandaloneLdapApiService();
    return new InitialLdapContext(env, JndiUtils.toJndiControls(ldapApiService));
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:10,代码来源:LdapIntegrationTest.java


示例10: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:69,代码来源:MiniKdc.java


示例11: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
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);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:65,代码来源:MiniKdc.java


示例12: init

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * {@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();
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:62,代码来源:InMemoryDirectoryServiceFactory.java


示例13: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, injects the context
 * entries for the created partitions, and loads an LDIF file (
 * {@link #ldifLoadFile}) for initial entries.
 *
 * @param workDir
 *          the directory to be used for storing the data
 * @throws Exception
 *           if there were some problems while initializing the system
 */
private void initDirectoryService(File workDir) throws Exception {
  // Initialize the LDAP service
  service = new DefaultDirectoryService();
  service.setWorkingDirectory(workDir);

  // first load the schema
  initSchemaPartition();

  // then the system partition
  // this is a MANDATORY partition
  Partition systemPartition = addPartition("system",
      ServerDNConstants.SYSTEM_DN);
  service.setSystemPartition(systemPartition);

  // create the partition for testing
  Partition testingPartition = addPartition("ldapTesting",
      "ou=ldapTesting,dc=pune,dc=gemstone,dc=com");

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

  // And start the service
  service.startup();

  // inject the entry for testing
  if (!service.getAdminSession().exists(testingPartition.getSuffixDn())) {
    DN dnTesting = new DN("ou=ldapTesting,dc=pune,dc=gemstone,dc=com");
    ServerEntry entryTesting = service.newEntry(dnTesting);
    entryTesting.add("objectClass", "top", "domain", "extensibleObject");
    entryTesting.add("dc", "pune");
    service.getAdminSession().add(entryTesting);
  }

  // load schema from LDIF
  if (ldifLoadFile != null) {
    LdifFileLoader ldifLoader = new LdifFileLoader(
        service.getAdminSession(), ldifLoadFile);
    int numLoaded = ldifLoader.execute();
    if (numLoaded <= 0) {
      throw new Exception(
          "Failed to load any entries from " + ldifLoadFile);
    } else {
      System.out.println(
          "LDAP loaded " + numLoaded + " entries from " + ldifLoadFile);
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:61,代码来源:LdapTestServer.java


示例14: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, adds the index, and
 * injects the context entries for the created partitions.
 *
 * @param workDir the directory to be used for storing the data
 * @throws Exception if there were some problems while initializing
 */
private void initDirectoryService(final ServletContext servletContext,
        final File workDir)
        throws Exception {

    // Initialize the LDAP service
    service = new DefaultDirectoryService();
    service.setWorkingDirectory(workDir);

    // first load the schema
    initSchemaPartition(servletContext);

    // then the system partition
    // this is a MANDATORY partition
    Partition systemPartition = addPartition("system",
            ServerDNConstants.SYSTEM_DN);
    service.setSystemPartition(systemPartition);

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

    // Now we can create as many partitions as we need
    Partition ispPartition = addPartition("isp", "o=isp");
    addIndex(ispPartition, "objectClass", "ou", "uid");

    // And start the service
    service.startup();

    // Inject the foo root entry if it does not already exist
    try {
        service.getAdminSession().lookup(ispPartition.getSuffixDn());
    } catch (LdapException lnnfe) {
        DN dnIsp = new DN("o=isp");
        ServerEntry rootEntry = service.newEntry(dnIsp);
        rootEntry.add("objectClass", "top", "organization");
        rootEntry.add("o", "isp");
        service.getAdminSession().add(rootEntry);

        DN dnPeople = new DN("ou=People,o=isp");
        ServerEntry peopleEntry = service.newEntry(dnPeople);
        peopleEntry.add("objectClass", "top", "organizationalUnit");
        peopleEntry.add("ou", "People");
        service.getAdminSession().add(peopleEntry);
    }
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:53,代码来源:ApacheDSStartStopListener.java


示例15: init

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * {@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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:60,代码来源:InMemoryDirectoryServiceFactory.java


示例16: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, adds the index, and injects the context entries for the created
 * partitions.
 *
 * @param workDir the directory to be used for storing the data
 * @param loadDefaultContent if default content should be loaded
 * @throws Exception if there were some problems while initializing
 */
private void initDirectoryService(final ServletContext servletContext, final File workDir,
        final boolean loadDefaultContent) throws Exception {

    // Initialize the LDAP service
    service = new DefaultDirectoryService();
    service.setInstanceLayout(new InstanceLayout(workDir));

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

    service.setCacheService(cacheService);

    // first load the schema
    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);

    // Now we can create as many partitions as we need
    Partition ispPartition = addPartition("isp", "o=isp", service.getDnFactory());

    // Index some attributes on the apache partition
    addIndex(ispPartition, "objectClass", "ou", "uid");

    // And start the service
    service.startup();

    if (loadDefaultContent) {
        Resource contentLdif = WebApplicationContextUtils.getWebApplicationContext(servletContext).
                getResource("classpath:/content.ldif");
        LdifInputStreamLoader contentLoader = new LdifInputStreamLoader(service.getAdminSession(),
                contentLdif.getInputStream());
        int numEntries = contentLoader.execute();
        LOG.info("Successfully created {} entries", numEntries);
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:61,代码来源:ApacheDSStartStopListener.java


示例17: init

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * {@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("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30)
            .timeToLiveSeconds(30).overflowToDisk(false);
    ehCacheConfig.addDefaultCache(defaultCache);
    cacheManager = new CacheManager(ehCacheConfig);
    CacheService cacheService = new CacheService(cacheManager);
    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(), "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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:64,代码来源:InMemoryDirectoryServiceFactory.java


示例18: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
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();
  String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase();

  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);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:69,代码来源:MiniKdc.java


示例19: initDirectoryService

import org.apache.directory.server.constants.ServerDNConstants; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, adds the index, and
 * injects the context entries for the created partitions.
 *
 * @param workDir the directory to be used for storing the data
 * @throws Exception if there were some problems while initializing the system
 */
private void initDirectoryService(File workDir) throws Exception {
  // Initialize the LDAP service
  service = new DefaultDirectoryService();
  service.setWorkingDirectory(workDir);

  // 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StorageException类代码示例发布时间:2022-05-21
下一篇:
Java SyncRequest类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap