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

Java DN类代码示例

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

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



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

示例1: EmbeddedLdapServer

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
public EmbeddedLdapServer(
    File workingDir,
    String partitionDn,
    String partitionId,
    int port,
    boolean enableChangelog,
    boolean allowAnonymousAccess,
    long maxSizeLimit)
    throws Exception {
  requireNonNull(partitionDn, "Required non-null partition dn");
  requireNonNull(partitionId, "Required non-null partition id");
  this.workingDir = workingDir;
  this.baseDn = new DN(partitionDn);
  this.port = port > 0 ? port : PORT_SERVICE.acquire();
  this.url = "ldap://localhost:" + this.port;
  ldapServer = new LdapServer();
  ldapServer.setTransports(new TcpTransport(this.port));
  if (maxSizeLimit > 0) {
    ldapServer.setMaxSizeLimit(maxSizeLimit);
  }
  service =
      initDirectoryService(
          workingDir, partitionId, partitionDn, enableChangelog, allowAnonymousAccess);
  ldapServer.setDirectoryService(service);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:26,代码来源:EmbeddedLdapServer.java


示例2: main

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
/**
 * Main class.
 *
 * @param args Not used.
 */
public static void main(String[] args) {
  try {
    File workDir = new File(System.getProperty("java.io.tmpdir") + "/server-work/" + UUID.randomUUID().toString());
    workDir.mkdirs();

    // Create the server
    EmbeddedADS ads = new EmbeddedADS(workDir);

    // Read an entry
    //Entry result = ads.service.getAdminSession().lookup(new DN("dc=foo,dc=com"));

    Entry result = ads.service.getAdminSession().lookup(new DN("ou=users,dc=foo,dc=com"));

    // And print it if available
    System.out.println("Found entry : " + result);

    // optionally we can start a server too
    ads.startServer();
  } catch (Exception e) {
    // Ok, we have something wrong going on ...
    e.printStackTrace();
  }
}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:29,代码来源:EmbeddedADS.java


示例3: addAttribute

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
public void addAttribute(String dn, String attrName, String attrValue)
    throws Exception {
  EntryAttribute attr = new DefaultClientAttribute(attrName, attrValue);
  Modification addValue = new ClientModification(
      ModificationOperation.ADD_ATTRIBUTE, attr);
  service.getAdminSession().modify(new DN(dn),
      Collections.singletonList(addValue));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:9,代码来源:LdapTestServer.java


示例4: removeAttribute

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
public void removeAttribute(String dn, String attrName, String attrValue)
    throws Exception {
  EntryAttribute attr = new DefaultClientAttribute(attrName, attrValue);
  Modification removeValue = new ClientModification(
      ModificationOperation.REMOVE_ATTRIBUTE, attr);
  service.getAdminSession().modify(new DN(dn),
      Collections.singletonList(removeValue));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:9,代码来源:LdapTestServer.java


示例5: contextInitialized

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
/**
 * Startup ApacheDS embedded.
 *
 * @param sce ServletContext event
 */
@Override
public void contextInitialized(final ServletContextEvent sce) {
    File workDir = (File) sce.getServletContext().getAttribute(
            "javax.servlet.context.tempdir");
    workDir = new File(workDir, "server-work");
    if (!workDir.mkdirs()) {
        throw new RuntimeException("Could not create " + workDir.
                getAbsolutePath());
    }

    Entry result;
    try {
        initDirectoryService(sce.getServletContext(), workDir);

        server = new LdapServer();
        server.setTransports(new TcpTransport(Integer.valueOf(
                sce.getServletContext().
                getInitParameter("testds.port"))));
        server.setDirectoryService(service);

        server.start();

        // store directoryService in context to provide it to servlets etc.
        sce.getServletContext().setAttribute(DirectoryService.JNDI_KEY,
                service);

        result = service.getAdminSession().lookup(new DN("o=isp"));
    } catch (Exception e) {
        sce.getServletContext().log("Fatal error in context init", e);
        throw new RuntimeException(e);
    }

    if (result == null) {
        throw new RuntimeException("Base DN not found");
    } else {
        sce.getServletContext().log(
                "ApacheDS startup completed succesfully");
    }
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:45,代码来源:ApacheDSStartStopListener.java


示例6: addPartitionAttributes

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
private void addPartitionAttributes(String partitionDN, List<String> objectClasses,
                                    String realm, String dc)
        throws DirectoryServerException {

    try {
        DN adminDN = new DN(partitionDN);
        ServerEntry serverEntry = this.directoryService.newEntry(adminDN);

        addObjectClasses(serverEntry, objectClasses);

        serverEntry.add("o", realm);

        if (dc == null) {
            logger.warn("Domain component not found for partition with DN - " + partitionDN +
                    ". Not setting domain component.");
        } else {
            serverEntry.add("dc", dc);
        }

        addAccessControlAttributes(serverEntry);

        this.directoryService.getAdminSession().add(serverEntry);

    } catch (Exception e) {

        String msg = "Could not add partition attributes for partition - " + partitionDN;
        throwDirectoryServerException(msg, e);
    }

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:31,代码来源:ApacheDirectoryPartitionManager.java


示例7: initDirectoryService

import org.apache.directory.shared.ldap.name.DN; //导入依赖的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


示例8: newEntry

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
public ServerEntry newEntry(String name, String value, ServerEntry parent) throws Exception {
  return service.newEntry(new DN(name + '=' + value + ',' + parent.getDn()));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:4,代码来源:EmbeddedLdapServer.java


示例9: removeEntry

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
/** Removes an entity with rdn {name}={value} in base dn. */
public void removeEntry(String name, String value) throws Exception {
  service.getAdminSession().delete(new DN(name + '=' + value + ',' + baseDn));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:5,代码来源:EmbeddedLdapServer.java


示例10: modify

import org.apache.directory.shared.ldap.name.DN; //导入依赖的package包/类
/** Applies given modifications on the entity with rdn {rdnKey}={rdnValue} in base dn. */
public void modify(String rdnKey, String rdnValue, Modification... mods) throws Exception {
  service
      .getAdminSession()
      .modify(new DN(rdnKey + '=' + rdnValue + ',' + baseDn), Arrays.asList(mods));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:7,代码来源:EmbeddedLdapServer.java


示例11: initDirectoryService

import org.apache.directory.shared.ldap.name.DN; //导入依赖的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


示例12: initDirectoryService

import org.apache.directory.shared.ldap.name.DN; //导入依赖的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);

  // first load the schema
  initSchemaPartition();

  // 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
  // Create some new partitions named 'foo', 'bar' and 'apache'.
  Partition fooPartition = addPartition("foo", "dc=foo,dc=com");

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

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

  DN dnFoo = new DN("dc=foo,dc=com");
  ServerEntry entryFoo = service.newEntry(dnFoo);
  entryFoo.add("objectClass", "top", "domain", "extensibleObject");
  entryFoo.add("dc", "foo");
  service.getAdminSession().add(entryFoo);

  DN usersDN=new DN("ou=users,dc=foo,dc=com");
  ServerEntry usersEntry=service.newEntry(usersDN);
  usersEntry.add("objectClass","organizationalUnit","top");
  usersEntry.add("ou","users");
  service.getAdminSession().add(usersEntry);

}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:48,代码来源:EmbeddedADS.java



注:本文中的org.apache.directory.shared.ldap.name.DN类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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