org.apache.directory.server.protocol.shared.store.LdifFileLoader Java Examples
The following examples show how to use
org.apache.directory.server.protocol.shared.store.LdifFileLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApacheDSUtils.java From aws-iam-ldap-bridge with Apache License 2.0 | 5 votes |
public void loadLdif(String s) throws LdapException { if (getClass().getClassLoader().getResourceAsStream(s) == null) { s = new File("E:\\WS\\ApacheDS_AWSIAM\\dist\\apacheds\\" + s).getAbsolutePath(); } LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), s); loader.execute(); }
Example #2
Source File: LdapTestUtils.java From spring-ldap with Apache License 2.0 | 5 votes |
public static void loadLdif(DefaultDirectoryService directoryService, Resource ldifFile) throws IOException { File tempFile = File.createTempFile("spring_ldap_test", ".ldif"); try { InputStream inputStream = ldifFile.getInputStream(); IOUtils.copy(inputStream, new FileOutputStream(tempFile)); LdifFileLoader fileLoader = new LdifFileLoader(directoryService.getSession(), tempFile.getAbsolutePath()); fileLoader.execute(); } finally { try { tempFile.delete(); } catch (Exception e) { // Ignore this } } }
Example #3
Source File: ApacheDSContainerWithSecurity.java From spring-cloud-dashboard with Apache License 2.0 | 4 votes |
private void importLdifs() throws Exception { // Import any ldif files Resource[] ldifs; if (ctxt == null) { // Not running within an app context ldifs = new PathMatchingResourcePatternResolver().getResources(ldifResources); } else { ldifs = ctxt.getResources(ldifResources); } // Note that we can't just import using the ServerContext returned // from starting Apache DS, apparently because of the long-running issue // DIRSERVER-169. // We need a standard context. // DirContext dirContext = contextSource.getReadWriteContext(); if (ldifs == null || ldifs.length == 0) { return; } if (ldifs.length == 1) { String ldifFile; try { ldifFile = ldifs[0].getFile().getAbsolutePath(); } catch (IOException e) { ldifFile = ldifs[0].getURI().toString(); } logger.info("Loading LDIF file: " + ldifFile); LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), new File(ldifFile), null, getClass().getClassLoader()); loader.execute(); } else { throw new IllegalArgumentException( "More than one LDIF resource found with the supplied pattern:" + ldifResources + " Got " + Arrays.toString(ldifs)); } }
Example #4
Source File: LdapTestServer.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * 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); } } }
Example #5
Source File: LdapTestServer.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * 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); } } }
Example #6
Source File: EmbeddedLDAPServer.java From cukes with Apache License 2.0 | 4 votes |
public void loadLDIF(String fileName) { File ldifFile = new File(fileName); LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), ldifFile, null, getClass().getClassLoader()); loader.execute(); }