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


Java LDIFReader类代码示例

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


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

示例1: importLdifFileInLdap

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
public ResultCode importLdifFileInLdap(InputStream is) throws LDAPException {
	ResultCode result = ResultCode.UNAVAILABLE;

	LDAPConnection connection = ldapEntryManager.getOperationService().getConnection();
	try {
		LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
		LDIFReader importLdifReader = new LDIFReader(is);

		result = ldifDataUtility.importLdifFile(connection, importLdifReader);
		importLdifReader.close();
	} catch (Exception ex) {
		log.error("Failed to import ldif file: ", ex);
	} finally {
		ldapEntryManager.getOperationService().releaseConnection(connection);
	}

	return result;

}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:20,代码来源:LdifService.java

示例2: start

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
@Override
public void start() {
    try {
        InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=MyDomain");
        config.addAdditionalBindCredentials("cn=Directory Manager", "password");
        config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 1389));
        config.setSchema(null);

        ds = new InMemoryDirectoryServer(config);
        ds.startListening();
        ds.importFromLDIF(true, new LDIFReader(getClass().getResourceAsStream("/conf/realm.ldif")));
    } catch (LDAPException e) {
        ds = null;
        log.error("Failed to start UnboundID LDAP server!", e);
    }
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:17,代码来源:Components.java

示例3: loadLdifFiles

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
/**
 * Load any LDIF files identified within the annotation @Ldif
 */
protected void loadLdifFiles() throws Exception {
	Iterable<String> ldifResources = ldifResources();
	for (String ldif : ldifResources) {
		Class clazz = (annotatedClass != null) ? annotatedClass : getClass();
		InputStream resourceAsStream = clazz.getResourceAsStream(ldif);
		if (resourceAsStream == null) {
			throw new FileNotFoundException("Should be able to load " + ldif);
		}
		LDIFReader r = new LDIFReader(resourceAsStream);
		LDIFChangeRecord readEntry = null;
		while ((readEntry = r.readChangeRecord()) != null) {
			readEntry.processChange(server);
		}
		resourceAsStream.close();
	}
}
 
开发者ID:trevershick,项目名称:ldap-test-utils,代码行数:20,代码来源:LdapServerResource.java

示例4: init

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
@Before
public void init() throws Exception {
    ds.clear();
    ds.importFromLDIF(true, new LDIFReader(getClass().getResourceAsStream("/conf/realm.ldif")));

    Map<String, Object> settings = getSettings();
    ldap = newRealm(settings);
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:9,代码来源:LdapRealmTest.java

示例5: loadLdifFiles

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
/**
 * Loads LDIF files as specified in the configuration file.
 *
 * @throws Exception
 */
protected void loadLdifFiles() throws Exception {
    LOG.info(">>>loadLdifFiles()");

    LOG.debug("{}", System.getProperty("java.class.path"));
    LOG.info("   ...loading LDIF resources: ");

    int ldifLoadCount = 0;
    for (Ldif ldif : configuration.getLdifs()) {
        LOG.info("----------------------------------------------------------");
        LOG.info("   loading LDIF: {}", ldif.getName());
        ldifLoadCount++;
        InputStream resourceAsStream = null;
        try {
            LOG.info("       file: '{}'", ldif.getName());
            resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(ldif.getName());
            if (resourceAsStream == null) {
                throw new FileNotFoundException("Should be able to load: " + ldif.getName());
            }
            LDIFReader r = new LDIFReader(resourceAsStream);
            LDIFChangeRecord readEntry = null;
            int entryCount = 0;
            while ((readEntry = r.readChangeRecord()) != null) {
                LOG.debug("      ...readEntry");
                LOG.debug("{}", ToStringBuilder.reflectionToString(readEntry, ToStringStyle.MULTI_LINE_STYLE));
                entryCount++;
                readEntry.processChange(server);
            }
            LOG.info("   # of entries loaded: {}", entryCount);
        } finally {
            if (resourceAsStream != null) {
                resourceAsStream.close();
            }
        }
    }
    LOG.info("----------------------------------------------------------");
    LOG.info("   # of LDIF files loaded: {}", ldifLoadCount);
    LOG.info("   Post LDIF load server entry count: {}", server.countEntries());
    LOG.info("<<<loadLdifFiles()");
}
 
开发者ID:inbloom,项目名称:ldap-in-memory,代码行数:45,代码来源:LdapServerImpl.java

示例6: validateLdifFile

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
public ResultCode validateLdifFile(InputStream is, String dn) throws LDAPException {
	ResultCode result = ResultCode.UNAVAILABLE;
	try {
		LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
		LDIFReader validateLdifReader = new LDIFReader(is);

		result = ldifDataUtility.validateLDIF(validateLdifReader, dn);
		validateLdifReader.close();
	} catch (Exception ex) {
		log.error("Failed to validate ldif file: ", ex);
	}

	return result;

}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:16,代码来源:LdifService.java

示例7: importLdifFile

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
/**
 * Performs ldif file import
 * 
 * @param connection
 *            Connection to LDAP server
 * @param ldifFileName
 *            LDIF file
 * @return The result code for the processing that was performed
 */
public ResultCode importLdifFile(LDAPConnection connection, String ldifFileName) {
	LDIFReader ldifReader = createLdifReader(ldifFileName);
	if (ldifReader == null) {
		return ResultCode.LOCAL_ERROR;
	}
	try {
		return importLdifFile(connection, ldifReader);
	} finally {
	    disposeLdifReader(ldifReader);
	}
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:21,代码来源:LdifDataUtility.java

示例8: disposeLdifReader

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
private void disposeLdifReader(LDIFReader ldifReader) {
	if (ldifReader != null) {
		try {
			ldifReader.close();
		} catch (IOException ex) {
		}
	}
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:9,代码来源:LdifDataUtility.java

示例9: validateLDIF

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
public ResultCode validateLDIF(LDIFReader ldifReader, String dn) {
	String baseDn = dn.toLowerCase();
	ResultCode resultCode = ResultCode.SUCCESS;
	while (true) {
		// Read the next change to process
		LDIFChangeRecord ldifRecord = null;
		try {
			ldifRecord = ldifReader.readChangeRecord(true);
			if (ldifRecord != null) {
				if (StringHelper.isNotEmpty(baseDn)) {
					if (!ldifRecord.getDN().toLowerCase().endsWith(baseDn)) {
						resultCode = ResultCode.NOT_SUPPORTED;
						break;
					}
				}
			}

		} catch (LDIFException le) {
			log.info("Malformed ldif record " + ldifRecord);
			log.error("Malformed ldif record", le);
			resultCode = ResultCode.DECODING_ERROR;
			break;
		} catch (IOException ioe) {
			log.error("I/O error encountered while reading a change record", ioe);
			resultCode = ResultCode.LOCAL_ERROR;
			break;
		}

		// If the change record was null, then it means there are no more
		// changes to be processed.
		if (ldifRecord == null) {
			break;
		}
	}

	return resultCode;
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:38,代码来源:LdifDataUtility.java

示例10: EmbeddedDirectoryServer

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
private EmbeddedDirectoryServer(@NotNull String dn, @NotNull URL ldifStream) throws Exception {
  baseDn = new DN(dn);

  final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(dn);
  server = new InMemoryDirectoryServer(config);

  try (InputStream in = ldifStream.openStream()) {
    server.importFromLDIF(false, new LDIFReader(in));
  }

  server.startListening();
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:13,代码来源:EmbeddedDirectoryServer.java

示例11: loadLdifFiles

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
protected void loadLdifFiles() throws Exception {
    Iterable<String> ldifResources = ldifResources();
    for (String ldif : ldifResources) {
        InputStream ldifStream = new FileInputStream(ldif);
        try {
            LDIFReader r = new LDIFReader(ldifStream);
            LDIFChangeRecord readEntry;
            while ((readEntry = r.readChangeRecord()) != null) {
                readEntry.processChange(server);
            }
        } finally {
            ldifStream.close();
        }
    }
}
 
开发者ID:zoldar,项目名称:ldap-test-server-py4j,代码行数:16,代码来源:LdapPatchedServerResource.java

示例12: createInMemoryLdapServer

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
@BeforeClass
public static void createInMemoryLdapServer() throws Exception {
	InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=MyDomain");
	config.addAdditionalBindCredentials("cn=Directory Manager", "password");
	config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", ldapPort));
	config.setSchema(null);
	
	InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
	ds.importFromLDIF(true, new LDIFReader(LdapUserServiceTest.class.getResourceAsStream("resources/ldapUserServiceSampleData.ldif")));
	ds.startListening();
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:12,代码来源:LdapUserServiceTest.java

示例13: loadLdifs

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
private void loadLdifs(InMemoryDirectoryServer ds) {
    try {
        for (InputStream ldif : _ldifs) {
            LDIFReader ldifReader = new LDIFReader(ldif);
            ds.importFromLDIF(CLEAR_BEFORE_LDIF_IMPORT, ldifReader);
        }
    } catch (LDAPException e) {
        throw propagate(e);
    }
}
 
开发者ID:zagyi,项目名称:adsync4j,代码行数:11,代码来源:EmbeddedUnboundIDLdapServer.java

示例14: addEntries

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
/**
 * Attempts to add a set of entries provided in LDIF form in which each
 * element of the provided array is a line of the LDIF representation, with
 * empty strings as separators between entries (as you would have for blank
 * lines in an LDIF file).  If a problem is encountered while attempting to
 * add any of the provided entries, then the server will remain populated with
 * the data it held before this method was called.
 * <BR><BR>
 * This method may be used regardless of whether the server is listening for
 * client connections, and regardless of whether add operations are allowed in
 * the server.
 *
 * @param  ldifEntryLines  The lines comprising the LDIF representation of the
 *                         entries to be added.
 *
 * @throws  LDAPException  If a problem is encountered while attempting to add
 *                         any of the provided entries.
 */
public void addEntries(final String... ldifEntryLines)
       throws LDAPException
{
  final ByteStringBuffer buffer = new ByteStringBuffer();
  for (final String line : ldifEntryLines)
  {
    buffer.append(line);
    buffer.append(StaticUtils.EOL_BYTES);
  }

  final ArrayList<Entry> entryList = new ArrayList<Entry>(10);
  final LDIFReader reader = new LDIFReader(buffer.asInputStream());
  while (true)
  {
    try
    {
      final Entry entry = reader.readEntry();
      if (entry == null)
      {
        break;
      }
      else
      {
        entryList.add(entry);
      }
    }
    catch (final Exception e)
    {
      Debug.debugException(e);
      throw new LDAPException(ResultCode.PARAM_ERROR,
           ERR_MEM_DS_ADD_ENTRIES_LDIF_PARSE_EXCEPTION.get(
                StaticUtils.getExceptionMessage(e)),
           e);
    }
  }

  addEntries(entryList);
}
 
开发者ID:zagyi,项目名称:adsync4j,代码行数:57,代码来源:InMemoryDirectoryServer.java

示例15: reset

import com.unboundid.ldif.LDIFReader; //导入依赖的package包/类
public void reset() throws LDAPException, IOException {
  logger.warn("Resetting embedded LDAP");

  InputStream ldifStream = getClass().getResourceAsStream("/testuser.ldif");
  dirServer.importFromLDIF(true, new LDIFReader(ldifStream));
}
 
开发者ID:sinnerschrader,项目名称:SkillWill,代码行数:7,代码来源:EmbeddedLdap.java


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