org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory Java Examples
The following examples show how to use
org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.
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: 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 #3
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 #4
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 #5
Source File: EmbeddedLdapServer.java From cloudstack with Apache License 2.0 | 5 votes |
public void init() throws Exception { if (getDirectoryService() == null) { if (getDeleteInstanceDirectoryOnStartup()) { deleteDirectory(getGuessedInstanceDirectory()); } DefaultDirectoryServiceFactory serviceFactory = new DefaultDirectoryServiceFactory(); serviceFactory.init(getDirectoryServiceName()); setDirectoryService(serviceFactory.getDirectoryService()); getDirectoryService().getChangeLog().setEnabled(false); getDirectoryService().setDenormalizeOpAttrsEnabled(true); createBasePartition(); getDirectoryService().startup(); createRootEntry(); } if (getLdapServer() == null) { setLdapServer(new LdapServer()); getLdapServer().setDirectoryService(getDirectoryService()); getLdapServer().setTransports(new TcpTransport(getLdapServerPort())); getLdapServer().start(); } }
Example #6
Source File: DirectoryServiceBuilder.java From wildfly-camel with Apache License 2.0 | 5 votes |
public static SetupResult setupDirectoryService(Class<?> testClass) throws Exception { // Define a default class DS then DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.class.newInstance(); SetupResult result = new SetupResult(); result.directoryService = dsf.getDirectoryService(); result.directoryService.getChangeLog().setEnabled(true); dsf.init("default" + UUID.randomUUID().toString()); // Apply the class LDIFs ApplyLdifFiles applyLdifFiles = testClass.getAnnotation(ApplyLdifFiles.class); if (applyLdifFiles != null) { LOG.debug("Applying {} to {}", applyLdifFiles.value(), testClass.getName()); DSAnnotationProcessor.injectLdifFiles(applyLdifFiles.clazz(), result.directoryService, applyLdifFiles.value()); } // check if it has a LdapServerBuilder then use the DS created above CreateLdapServer ldapServerAnnotation = testClass.getAnnotation(CreateLdapServer.class); if (ldapServerAnnotation != null) { result.ldapServer = ServerAnnotationProcessor.instantiateLdapServer(ldapServerAnnotation, result.directoryService); result.ldapServer.setDirectoryService(result.directoryService); result.ldapServer.start(); } // print out information which partition factory we use DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance(); PartitionFactory partitionFactory = dsFactory.getPartitionFactory(); LOG.debug("Using partition factory {}", partitionFactory.getClass().getSimpleName()); return result; }