当前位置: 首页>>代码示例>>Java>>正文


Java LdifReader类代码示例

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


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

示例1: loadLdif

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
/**
 * Loads an LDIF from an input stream and adds the entries it contains to the server. It appears
 * as though the administrator added these entries to the server.
 *
 * @param in
 *            the input stream containing the LDIF entries to load
 * @param verifyEntries
 *            whether or not all entry additions are checked to see if they were in fact
 *            correctly added to the server
 * @return a list of entries added to the server in the order they were added
 * @throws Exception
 *             of the load fails
 */
protected List<LdifEntry> loadLdif(InputStream in, boolean verifyEntries) throws Exception {
    if (in == null) {
        return EMPTY_LIST;
    }

    LdifReader ldifReader = new LdifReader(in);
    ArrayList<LdifEntry> entries = new ArrayList<LdifEntry>();

    for (LdifEntry entry : ldifReader) {
        getRootDSE()
                .add(new DefaultServerEntry(getDirectoryService().getRegistries(), entry
                .getEntry()));

        if (verifyEntries) {
            verify(entry);
            LOG.info("Successfully verified addition of entry " + entry.getDn());
        } else {
            LOG.info("Added entry " + entry.getDn() + " without verification");
        }

        entries.add(entry);
    }

    return entries;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:39,代码来源:AbstractApacheDSServer.java

示例2: injectLdifFiles

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
public static void injectLdifFiles(String... ldifFiles) throws Exception {
    if (ldifFiles != null && ldifFiles.length > 0) {
        for (String ldifFile : ldifFiles) {
            InputStream is = null;
            try {
                is = LdapTestParent.class.getClassLoader().getResourceAsStream(ldifFile);
                if (is == null) {
                    throw new FileNotFoundException("LDIF file '" + ldifFile + "' not found.");
                } else {
                    try {
                        LdifReader ldifReader = new LdifReader(is);
                        for (LdifEntry entry : ldifReader) {
                            injectEntry(entry);
                        }
                        ldifReader.close();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            } finally {
                IOUtils.closeQuietly(is);
            }
        }
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:26,代码来源:LdapTestParent.java

示例3: injectLdifFiles

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
public static void injectLdifFiles(String... ldifFiles) throws Exception {
    if (ldifFiles != null && ldifFiles.length > 0) {
        for (String ldifFile : ldifFiles) {
            InputStream is = null;
            try {
                is = BasicAuthLDAPTest.class.getClassLoader().getResourceAsStream(ldifFile);
                if (is == null) {
                    throw new FileNotFoundException("LDIF file '" + ldifFile + "' not found.");
                } else {
                    try {
                        LdifReader ldifReader = new LdifReader(is);
                        for (LdifEntry entry : ldifReader) {
                            injectEntry(entry);
                        }
                        ldifReader.close();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            } finally {
                IOUtils.closeQuietly(is);
            }
        }
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:26,代码来源:BasicAuthLDAPTest.java

示例4: injectLdifFiles

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
public static void injectLdifFiles(String... ldifFiles) throws Exception {
    if (ldifFiles != null && ldifFiles.length > 0) {
        for (String ldifFile : ldifFiles) {
            InputStream is = null;
            try {
                is = ApimanLdapServer.class.getClassLoader().getResourceAsStream(ldifFile);
                if (is == null) {
                    throw new FileNotFoundException("LDIF file '" + ldifFile + "' not found.");
                } else {
                    try {
                        LdifReader ldifReader = new LdifReader(is);
                        for (LdifEntry entry : ldifReader) {
                            injectEntry(entry);
                        }
                        ldifReader.close();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            } finally {
                IOUtils.closeQuietly(is);
            }
        }
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:26,代码来源:ApimanLdapServer.java

示例5: importLdif

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
/**
 * Stream will be closed automatically.
 */
public void importLdif(@WillClose InputStream is) throws Exception {
  Preconditions.checkState(directoryService.isStarted(), "Directory service not started");
  try {
    LdifReader entries = new LdifReader(is);
    CoreSession rootDSE = directoryService.getAdminSession();
    for (LdifEntry ldifEntry : entries) {
      rootDSE.add(new DefaultServerEntry(rootDSE.getDirectoryService().getRegistries(), ldifEntry.getEntry()));
    }
  } finally {
    Closeables.closeQuietly(is);
  }
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:16,代码来源:ApacheDS.java

示例6: importLdif

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
/**
 * Imports the LDIF entries packaged with the Eve JNDI provider jar into the newly created
 * system partition to prime it up for operation. Note that only ou=system entries will be added
 * - entries for other partitions cannot be imported and will blow chunks.
 *
 * @throws Exception
 *             if there are problems reading the ldif file and adding those entries to the
 *             system partition
 * @param in
 *            the input stream with the ldif
 */
protected void importLdif(InputStream in) throws Exception {
    try {
        for (LdifEntry ldifEntry : new LdifReader(in)) {
            getRootDSE().add(
                    new DefaultServerEntry(getRootDSE().getDirectoryService().getRegistries(),
                            ldifEntry.getEntry()));
        }
    } catch (Exception e) {
        String msg = "failed while trying to parse system ldif file";
        Exception ne = new LdapConfigurationException(msg, e);
        throw ne;
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:25,代码来源:AbstractApacheDSServer.java

示例7: injectEntries

import org.apache.directory.shared.ldap.ldif.LdifReader; //导入依赖的package包/类
/**
 * Inject an ldif String into the server. DN must be relative to the root.
 *
 * @param ldif
 *            the entries to inject
 * @throws Exception
 *             if the entries cannot be added
 */
protected void injectEntries(String ldif) throws Exception {
    LdifReader reader = new LdifReader();
    List<LdifEntry> entries = reader.parseLdif(ldif);

    for (LdifEntry entry : entries) {
        getRootDSE().add(
                new DefaultServerEntry(getRootDSE().getDirectoryService().getRegistries(),
                        entry.getEntry()));
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:19,代码来源:AbstractApacheDSServer.java


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