use of com.unboundid.ldap.listener.InMemoryListenerConfig in project gocd by gocd.
the class InMemoryLdapServerForTests method startServer.
private InMemoryDirectoryServer startServer(int port, String baseDn, String bindDn, String bindPassword) throws LDAPException, BindException {
InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", port);
InMemoryDirectoryServerConfig serverConfig = new InMemoryDirectoryServerConfig(new DN(baseDn));
/* Ignore schema so that it does not complain that some attributes (like sAMAccountName) are not valid. */
serverConfig.setSchema(null);
serverConfig.setListenerConfigs(listenerConfig);
serverConfig.addAdditionalBindCredentials(bindDn, bindPassword);
InMemoryDirectoryServer server = new InMemoryDirectoryServer(serverConfig);
try {
server.startListening();
} catch (LDAPException e) {
throw new RuntimeException(e);
}
new LDIFAddChangeRecord(baseDn, new Attribute("objectClass", "domain", "top")).processChange(server);
return server;
}
use of com.unboundid.ldap.listener.InMemoryListenerConfig in project spring-boot by spring-projects.
the class EmbeddedLdapAutoConfiguration method directoryServer.
@Bean
public InMemoryDirectoryServer directoryServer() throws LDAPException {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(this.embeddedProperties.getBaseDn());
if (hasCredentials(this.embeddedProperties.getCredential())) {
config.addAdditionalBindCredentials(this.embeddedProperties.getCredential().getUsername(), this.embeddedProperties.getCredential().getPassword());
}
setSchema(config);
InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("LDAP", this.embeddedProperties.getPort());
config.setListenerConfigs(listenerConfig);
this.server = new InMemoryDirectoryServer(config);
importLdif();
this.server.startListening();
setPortProperty(this.applicationContext, this.server.getListenPort());
return this.server;
}
Aggregations