當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。