Java Code Examples for org.apache.directory.server.ldap.LdapServer#start()
The following examples show how to use
org.apache.directory.server.ldap.LdapServer#start() .
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: KerberosKDCUtil.java From quarkus-http with Apache License 2.0 | 8 votes |
private static void startLdapServer() throws Exception { createWorkingDir(); DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory(); dsf.init(DIRECTORY_NAME); directoryService = dsf.getDirectoryService(); directoryService.addLast(new KeyDerivationInterceptor()); // Derives the Kerberos keys for new entries. directoryService.getChangeLog().setEnabled(false); SchemaManager schemaManager = directoryService.getSchemaManager(); createPartition(dsf, schemaManager, "users", "ou=users,dc=undertow,dc=io"); CoreSession adminSession = directoryService.getAdminSession(); Map<String, String> mappings = Collections.singletonMap("hostname", DefaultServer.getDefaultServerAddress().getHostString()); processLdif(schemaManager, adminSession, "partition.ldif", mappings); processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings); processLdif(schemaManager, adminSession, "user.ldif", mappings); processLdif(schemaManager, adminSession, "server.ldif", mappings); ldapServer = new LdapServer(); ldapServer.setServiceName("DefaultLDAP"); Transport ldap = new TcpTransport( "0.0.0.0", LDAP_PORT, 3, 5 ); ldapServer.addTransports(ldap); ldapServer.setDirectoryService(directoryService); ldapServer.start(); }
Example 2
Source File: LdapTestSuite.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static void startMasterLdapServer() throws Exception { masterWorkingDir = createWorkingDir(masterWorkingDir, "master"); DirectoryServiceFactory dsf = new InMemoryDirectoryServiceFactory(); dsf.init(MASTER_DIRECTORY_NAME); masterDirectoryService = dsf.getDirectoryService(); masterDirectoryService.getChangeLog().setEnabled(false); SchemaManager schemaManager = masterDirectoryService.getSchemaManager(); createPartition(dsf, schemaManager, "simple", "dc=simple,dc=wildfly,dc=org", masterDirectoryService, masterWorkingDir); createPartition(dsf, schemaManager, "group-to-principal", "dc=group-to-principal,dc=wildfly,dc=org", masterDirectoryService, masterWorkingDir); createPartition(dsf, schemaManager, "principal-to-group", "dc=principal-to-group,dc=wildfly,dc=org", masterDirectoryService, masterWorkingDir); CoreSession adminSession = masterDirectoryService.getAdminSession(); processLdif(schemaManager, adminSession, "memberOf-schema.ldif"); processLdif(schemaManager, adminSession, "simple-partition.ldif"); processLdif(schemaManager, adminSession, "group-to-principal.ldif"); processLdif(schemaManager, adminSession, "principal-to-group.ldif"); masterLdapServer = new LdapServer(); masterLdapServer.setServiceName("DefaultLDAP"); Transport ldap = new TcpTransport( "0.0.0.0", MASTER_LDAP_PORT, 3, 5 ); masterLdapServer.addTransports(ldap); masterLdapServer.setDirectoryService(masterDirectoryService); masterLdapServer.start(); }
Example 3
Source File: LdapTestSuite.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static void startSlaveLdapServer() throws Exception { slaveWorkingDir = createWorkingDir(slaveWorkingDir, "slave"); DirectoryServiceFactory dsf = new InMemoryDirectoryServiceFactory(); dsf.init(SLAVE_DIRECTORY_NAME); slaveDirectoryService = dsf.getDirectoryService(); slaveDirectoryService.getChangeLog().setEnabled(false); SchemaManager schemaManager = slaveDirectoryService.getSchemaManager(); createPartition(dsf, schemaManager, "simple", "dc=simple,dc=wildfly,dc=org", slaveDirectoryService, slaveWorkingDir); createPartition(dsf, schemaManager, "group-to-principal", "dc=group-to-principal,dc=wildfly,dc=org", slaveDirectoryService, slaveWorkingDir); createPartition(dsf, schemaManager, "principal-to-group", "dc=principal-to-group,dc=wildfly,dc=org", slaveDirectoryService, slaveWorkingDir); CoreSession adminSession = slaveDirectoryService.getAdminSession(); processLdif(schemaManager, adminSession, "memberOf-schema.ldif"); processLdif(schemaManager, adminSession, "simple-partition-slave.ldif"); processLdif(schemaManager, adminSession, "group-to-principal-slave.ldif"); processLdif(schemaManager, adminSession, "principal-to-group-slave.ldif"); slaveLdapServer = new LdapServer(); slaveLdapServer.setServiceName("DefaultLDAP"); Transport ldap = new TcpTransport( "0.0.0.0", SLAVE_LDAP_PORT, 3, 5 ); slaveLdapServer.addTransports(ldap); slaveLdapServer.setDirectoryService(slaveDirectoryService); slaveLdapServer.start(); }
Example 4
Source File: ApacheDirectoryServer.java From light-oauth2 with Apache License 2.0 | 5 votes |
private static void startLdapServer() throws Exception { createWorkingDir(); DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory(); dsf.init(DIRECTORY_NAME); directoryService = dsf.getDirectoryService(); directoryService.addLast(new KeyDerivationInterceptor()); // Derives the Kerberos keys for new entries. directoryService.getChangeLog().setEnabled(false); SchemaManager schemaManager = directoryService.getSchemaManager(); createPartition(dsf, schemaManager, "users", "ou=users,dc=undertow,dc=io"); CoreSession adminSession = directoryService.getAdminSession(); //Map<String, String> mappings = Collections.singletonMap("hostname", DefaultServer.getDefaultServerAddress().getHostString()); Map<String, String> mappings = Collections.singletonMap("hostname", "localhost"); processLdif(schemaManager, adminSession, "partition.ldif", mappings); processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings); processLdif(schemaManager, adminSession, "user.ldif", mappings); processLdif(schemaManager, adminSession, "server.ldif", mappings); ldapServer = new LdapServer(); ldapServer.setServiceName("DefaultLDAP"); Transport ldap = new TcpTransport( "0.0.0.0", LDAPS_PORT, 3, 5 ); ldap.enableSSL(true); ldapServer.addTransports(ldap); ldapServer.setKeystoreFile(ApacheDirectoryServer.class.getResource("/config/server.keystore").getFile()); ldapServer.setCertificatePassword("password"); ldapServer.loadKeyStore(); ldapServer.setDirectoryService(directoryService); ldapServer.start(); }
Example 5
Source File: ApacheDirectoryServer.java From light-oauth2 with Apache License 2.0 | 5 votes |
private static void startLdapServer() throws Exception { createWorkingDir(); DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory(); dsf.init(DIRECTORY_NAME); directoryService = dsf.getDirectoryService(); directoryService.addLast(new KeyDerivationInterceptor()); // Derives the Kerberos keys for new entries. directoryService.getChangeLog().setEnabled(false); SchemaManager schemaManager = directoryService.getSchemaManager(); createPartition(dsf, schemaManager, "users", "ou=users,dc=undertow,dc=io"); CoreSession adminSession = directoryService.getAdminSession(); //Map<String, String> mappings = Collections.singletonMap("hostname", DefaultServer.getDefaultServerAddress().getHostString()); Map<String, String> mappings = Collections.singletonMap("hostname", "localhost"); processLdif(schemaManager, adminSession, "partition.ldif", mappings); processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings); processLdif(schemaManager, adminSession, "user.ldif", mappings); processLdif(schemaManager, adminSession, "server.ldif", mappings); ldapServer = new LdapServer(); ldapServer.setServiceName("DefaultLDAP"); Transport ldap = new TcpTransport( "0.0.0.0", LDAPS_PORT, 3, 5 ); ldap.enableSSL(true); ldapServer.addTransports(ldap); ldapServer.setKeystoreFile(ApacheDirectoryServer.class.getResource("/config/server.keystore").getFile()); ldapServer.setCertificatePassword("password"); ldapServer.loadKeyStore(); ldapServer.setDirectoryService(directoryService); ldapServer.start(); }
Example 6
Source File: LDAPServer.java From Benchmark with GNU General Public License v2.0 | 5 votes |
/** * starts the LdapServer * * @throws Exception */ public void startServer() throws Exception { server = new LdapServer(); int serverPort = 10389; server.setTransports(new TcpTransport(serverPort)); server.setDirectoryService(service); server.start(); }
Example 7
Source File: EmbeddedLDAPServer.java From cukes with Apache License 2.0 | 5 votes |
public void start() throws Exception { DirectoryServiceFactory factory = new DefaultDirectoryServiceFactory(); factory.init("server"); service = factory.getDirectoryService(); service.addPartition(createPartition("default", "cn=test")); service.addPartition(createPartition("domain", "dc=example,dc=com")); server = new LdapServer(); server.setDirectoryService(service); server.setTransports(new TcpTransport(PORT)); server.start(); }
Example 8
Source File: LdapService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public LdapService start() throws Exception { assertNotStarted(); started = true; for (LdapServer current : servers) { current.start(); } return new LdapService(directoryService, servers); }
Example 9
Source File: EmbeddedADS.java From vertx-auth with Apache License 2.0 | 5 votes |
/** * starts the LdapServer * * @throws Exception */ public void startServer() throws Exception { server = new LdapServer(); int serverPort = 10389; server.setTransports(new TcpTransport(serverPort)); server.setDirectoryService(service); server.start(); }
Example 10
Source File: Runner.java From aws-iam-ldap-bridge with Apache License 2.0 | 5 votes |
/** * starts the LdapServer * * @throws Exception */ public void startServer() throws Exception { server = new LdapServer(); server.setTransports( new TcpTransport( serverPort ) ); server.setDirectoryService( service ); server.start(); }
Example 11
Source File: SpliceTestKDCPlatform.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public void startLdapServer(MiniKdc miniKdc) throws Exception { ldapServer = new LdapServer(); Field f = MiniKdc.class.getDeclaredField("ds"); f.setAccessible(true); DirectoryService ds = (DirectoryService) f.get(miniKdc); ldapServer.setDirectoryService(ds); TcpTransport tcpTransport = new TcpTransport(4016); ldapServer.setTransports(tcpTransport); LOG.info(ds.getAdminSession().getAuthenticatedPrincipal().getDn()); ldapServer.start(); }
Example 12
Source File: EmbeddedLdapServer.java From spring-ldap with Apache License 2.0 | 5 votes |
public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, String defaultPartitionSuffix, int port) throws Exception{ workingDirectory = new File(System.getProperty("java.io.tmpdir") + "/apacheds-test1"); FileUtils.deleteDirectory(workingDirectory); DefaultDirectoryService directoryService = new DefaultDirectoryService(); directoryService.setShutdownHookEnabled(true); directoryService.setAllowAnonymousAccess(true); directoryService.setWorkingDirectory(workingDirectory); directoryService.getChangeLog().setEnabled( false ); JdbmPartition partition = new JdbmPartition(); partition.setId(defaultPartitionName); partition.setSuffix(defaultPartitionSuffix); directoryService.addPartition(partition); directoryService.startup(); // Inject the apache root entry if it does not already exist if ( !directoryService.getAdminSession().exists( partition.getSuffixDn() ) ) { ServerEntry entry = directoryService.newEntry(new LdapDN(defaultPartitionSuffix)); entry.add("objectClass", "top", "domain", "extensibleObject"); entry.add("dc", defaultPartitionName); directoryService.getAdminSession().add( entry ); } LdapServer ldapServer = new LdapServer(); ldapServer.setDirectoryService(directoryService); TcpTransport ldapTransport = new TcpTransport(port); ldapServer.setTransports( ldapTransport ); ldapServer.start(); return new EmbeddedLdapServer(directoryService, ldapServer); }
Example 13
Source File: LdapTestEnvironment.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * starts the LdapServer * * @throws Exception */ public void startServer() throws Exception { ldapService = new LdapServer(); Properties properties = loadTestProperties(); String port = properties.getProperty("ldap.server.port"); ldapService.setTransports(new TcpTransport(Integer.parseInt(port))); ldapService.setDirectoryService(service); ldapService.start(); }