use of org.apache.directory.server.core.annotations.CreateDS in project wildfly by wildfly.
the class LdapServerSetupTask method startLdapServer.
@CreateDS(name = "JBossDS-LdapServerSetupTask", factory = org.jboss.as.test.integration.ldap.InMemoryDirectoryServiceFactory.class, partitions = { @CreatePartition(name = "jboss", suffix = "dc=jboss,dc=org", contextEntry = @ContextEntry(entryLdif = "dn: dc=jboss,dc=org\n" + "dc: jboss\n" + "objectClass: top\n" + "objectClass: domain\n\n"), indexes = { @CreateIndex(attribute = "objectClass"), @CreateIndex(attribute = "dc"), @CreateIndex(attribute = "ou") }) }, additionalInterceptors = { KeyDerivationInterceptor.class })
@CreateLdapServer(transports = { @CreateTransport(protocol = "LDAP", port = LDAP_PORT), @CreateTransport(protocol = "LDAPS", port = LDAPS_PORT) }, certificatePassword = "secret")
public //@formatter:on
void startLdapServer(final String hostname) throws Exception, IOException, ClassNotFoundException, FileNotFoundException {
final Map<String, String> map = new HashMap<String, String>();
map.put("hostname", NetworkUtils.formatPossibleIpv6Address(hostname));
directoryService = DSAnnotationProcessor.getDirectoryService();
final String ldifContent = StrSubstitutor.replace(IOUtils.toString(LdapServerSetupTask.class.getResourceAsStream("picketlink-idm-tests.ldif"), "UTF-8"), map);
final SchemaManager schemaManager = directoryService.getSchemaManager();
try {
for (LdifEntry ldifEntry : new LdifReader(IOUtils.toInputStream(ldifContent))) {
directoryService.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
final ManagedCreateLdapServer createLdapServer = new ManagedCreateLdapServer((CreateLdapServer) AnnotationUtils.getInstance(CreateLdapServer.class));
FileOutputStream fos = new FileOutputStream(KEYSTORE_FILE);
IOUtils.copy(getClass().getResourceAsStream(KEYSTORE_FILENAME), fos);
fos.close();
createLdapServer.setKeyStore(KEYSTORE_FILE.getAbsolutePath());
fixTransportAddress(createLdapServer, hostname);
ldapServer = ServerAnnotationProcessor.instantiateLdapServer(createLdapServer, directoryService);
ldapServer.start();
}
use of org.apache.directory.server.core.annotations.CreateDS in project wildfly by wildfly.
the class LdapExtLDAPServerSetupTask method createLdap2.
//@formatter:off
@CreateDS(name = "JBossComDS", factory = org.jboss.as.test.integration.ldap.InMemoryDirectoryServiceFactory.class, partitions = { @CreatePartition(name = "jbossCom", suffix = "dc=jboss,dc=com", contextEntry = @ContextEntry(entryLdif = "dn: dc=jboss,dc=com\n" + "dc: jboss\n" + "objectClass: top\n" + "objectClass: domain\n\n"), indexes = { @CreateIndex(attribute = "objectClass"), @CreateIndex(attribute = "dc"), @CreateIndex(attribute = "ou") }), @CreatePartition(name = "jbossOrg", suffix = "dc=jboss,dc=org", contextEntry = @ContextEntry(entryLdif = "dn: dc=jboss,dc=org\n" + "dc: jboss\n" + "objectClass: top\n" + "objectClass: domain\n\n"), indexes = { @CreateIndex(attribute = "objectClass"), @CreateIndex(attribute = "dc"), @CreateIndex(attribute = "ou") }) }, additionalInterceptors = { KeyDerivationInterceptor.class })
@CreateLdapServer(transports = { @CreateTransport(protocol = "LDAP", port = LDAP_PORT2) })
public //@formatter:on
void createLdap2(final String hostname) throws Exception {
directoryService2 = DSAnnotationProcessor.getDirectoryService();
final SchemaManager schemaManager = directoryService2.getSchemaManager();
try {
for (LdifEntry ldifEntry : new LdifReader(LdapExtLoginModuleTestCase.class.getResourceAsStream(LdapExtLoginModuleTestCase.class.getSimpleName() + "2.ldif"))) {
directoryService2.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
final ManagedCreateLdapServer createLdapServer = new ManagedCreateLdapServer((CreateLdapServer) AnnotationUtils.getInstance(CreateLdapServer.class));
fixTransportAddress(createLdapServer, hostname);
ldapServer2 = ServerAnnotationProcessor.instantiateLdapServer(createLdapServer, directoryService2);
ldapServer2.start();
LOGGER.trace("ldapServer2 = " + ldapServer2);
}
use of org.apache.directory.server.core.annotations.CreateDS in project wildfly by wildfly.
the class KerberosServerSetupTask method createLdap1.
//@formatter:off
@CreateDS(name = "JBossDS-KerberosServerSetupTask", factory = org.jboss.as.test.integration.ldap.InMemoryDirectoryServiceFactory.class, partitions = { @CreatePartition(name = "jboss", suffix = "dc=jboss,dc=org", contextEntry = @ContextEntry(entryLdif = "dn: dc=jboss,dc=org\n" + "dc: jboss\n" + "objectClass: top\n" + "objectClass: domain\n\n"), indexes = { @CreateIndex(attribute = "objectClass"), @CreateIndex(attribute = "dc"), @CreateIndex(attribute = "ou") }) }, additionalInterceptors = { KeyDerivationInterceptor.class })
@CreateLdapServer(transports = { @CreateTransport(protocol = "LDAP", port = LDAP_PORT), @CreateTransport(protocol = "LDAPS", port = LDAPS_PORT) }, certificatePassword = "secret")
@CreateKdcServer(primaryRealm = KERBEROS_PRIMARY_REALM, kdcPrincipal = "krbtgt/" + KERBEROS_PRIMARY_REALM + "@" + KERBEROS_PRIMARY_REALM, searchBaseDn = "dc=jboss,dc=org", transports = { @CreateTransport(protocol = "UDP", port = KERBEROS_PORT), @CreateTransport(protocol = "TCP", port = KERBEROS_PORT) })
public //@formatter:on
void createLdap1(ManagementClient managementClient, final String hostname) throws Exception {
final Map<String, String> map = new HashMap<String, String>();
final String cannonicalHost = NetworkUtils.formatPossibleIpv6Address(Utils.getCannonicalHost(managementClient));
map.put("hostname", cannonicalHost);
map.put("realm", KERBEROS_PRIMARY_REALM);
directoryService1 = DSAnnotationProcessor.getDirectoryService();
final String ldifContent = StrSubstitutor.replace(IOUtils.toString(KerberosServerSetupTask.class.getResourceAsStream(KerberosServerSetupTask.class.getSimpleName() + ".ldif"), "UTF-8"), map);
LOGGER.trace(ldifContent);
final SchemaManager schemaManager = directoryService1.getSchemaManager();
try {
for (LdifEntry ldifEntry : new LdifReader(IOUtils.toInputStream(ldifContent))) {
directoryService1.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
final ManagedCreateLdapServer createLdapServer = new ManagedCreateLdapServer((CreateLdapServer) AnnotationUtils.getInstance(CreateLdapServer.class));
FileOutputStream fos = new FileOutputStream(KEYSTORE_FILE);
IOUtils.copy(getClass().getResourceAsStream(KEYSTORE_FILENAME), fos);
fos.close();
createLdapServer.setKeyStore(KEYSTORE_FILE.getAbsolutePath());
fixTransportAddress(createLdapServer, cannonicalHost);
ldapServer1 = ServerAnnotationProcessor.instantiateLdapServer(createLdapServer, directoryService1);
krbServer1 = KDCServerAnnotationProcessor.getKdcServer(directoryService1, KERBEROS_PORT, cannonicalHost);
ldapServer1.start();
}
use of org.apache.directory.server.core.annotations.CreateDS in project wildfly by wildfly.
the class LdapExtLDAPServerSetupTask method createLdap1.
//@formatter:off
@CreateDS(name = "JBossDS-LdapExtLDAPServerSetupTask", factory = org.jboss.as.test.integration.ldap.InMemoryDirectoryServiceFactory.class, partitions = { @CreatePartition(name = "jboss", suffix = "dc=jboss,dc=org", contextEntry = @ContextEntry(entryLdif = "dn: dc=jboss,dc=org\n" + "dc: jboss\n" + "objectClass: top\n" + "objectClass: domain\n\n"), indexes = { @CreateIndex(attribute = "objectClass"), @CreateIndex(attribute = "dc"), @CreateIndex(attribute = "ou") }) }, additionalInterceptors = { KeyDerivationInterceptor.class })
@CreateLdapServer(transports = { @CreateTransport(protocol = "LDAP", port = LDAP_PORT), @CreateTransport(protocol = "LDAPS", port = LDAPS_PORT) }, certificatePassword = "secret")
public //@formatter:on
void createLdap1(final String hostname) throws Exception {
final Map<String, String> map = new HashMap<String, String>();
map.put("hostname", NetworkUtils.formatPossibleIpv6Address(hostname));
map.put("ldapPort2", Integer.toString(LDAP_PORT2));
directoryService1 = DSAnnotationProcessor.getDirectoryService();
final String ldifContent = StrSubstitutor.replace(IOUtils.toString(LdapExtLoginModuleTestCase.class.getResourceAsStream(LdapExtLoginModuleTestCase.class.getSimpleName() + ".ldif"), "UTF-8"), map);
LOGGER.debug(ldifContent);
final SchemaManager schemaManager = directoryService1.getSchemaManager();
try {
for (LdifEntry ldifEntry : new LdifReader(IOUtils.toInputStream(ldifContent))) {
directoryService1.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
final ManagedCreateLdapServer createLdapServer = new ManagedCreateLdapServer((CreateLdapServer) AnnotationUtils.getInstance(CreateLdapServer.class));
FileOutputStream fos = new FileOutputStream(KEYSTORE_FILE);
IOUtils.copy(getClass().getResourceAsStream(KEYSTORE_FILENAME), fos);
fos.close();
createLdapServer.setKeyStore(KEYSTORE_FILE.getAbsolutePath());
fixTransportAddress(createLdapServer, hostname);
ldapServer1 = ServerAnnotationProcessor.instantiateLdapServer(createLdapServer, directoryService1);
ldapServer1.start();
LOGGER.trace("ldapServer1 = " + ldapServer1);
}
Aggregations