use of org.apache.directory.server.core.factory.DirectoryServiceFactory in project wildfly-camel by wildfly-extras.
the class DirectoryServiceBuilder method setupDirectoryService.
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;
}
use of org.apache.directory.server.core.factory.DirectoryServiceFactory 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