use of org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory in project undertow by undertow-io.
the class KerberosKDCUtil method startLdapServer.
private static void startLdapServer() throws Exception {
createWorkingDir();
DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory();
dsf.init(DIRECTORY_NAME);
directoryService = dsf.getDirectoryService();
// Derives the Kerberos keys for new entries.
directoryService.addLast(new KeyDerivationInterceptor());
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();
}
Aggregations