Search in sources :

Example 11 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project sonarqube by SonarSource.

the class ApacheDS method startLdapServer.

private ApacheDS startLdapServer(int port) throws Exception {
    ldapServer.setTransports(new TcpTransport(port));
    ldapServer.setDirectoryService(directoryService);
    // Setup SASL mechanisms
    Map<String, MechanismHandler> mechanismHandlerMap = new HashMap<>();
    mechanismHandlerMap.put(SupportedSaslMechanisms.PLAIN, new PlainMechanismHandler());
    mechanismHandlerMap.put(SupportedSaslMechanisms.CRAM_MD5, new CramMd5MechanismHandler());
    mechanismHandlerMap.put(SupportedSaslMechanisms.DIGEST_MD5, new DigestMd5MechanismHandler());
    mechanismHandlerMap.put(SupportedSaslMechanisms.GSSAPI, new GssapiMechanismHandler());
    ldapServer.setSaslMechanismHandlers(mechanismHandlerMap);
    ldapServer.setSaslHost("localhost");
    ldapServer.setSaslRealms(Collections.singletonList(realm));
    // TODO ldapServer.setSaslPrincipal();
    // The base DN containing users that can be SASL authenticated.
    ldapServer.setSearchBaseDn(baseDn);
    ldapServer.start();
    return this;
}
Also used : PlainMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler) GssapiMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.gssapi.GssapiMechanismHandler) HashMap(java.util.HashMap) CramMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.cramMD5.CramMd5MechanismHandler) CramMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.cramMD5.CramMd5MechanismHandler) PlainMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler) DigestMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.digestMD5.DigestMd5MechanismHandler) GssapiMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.gssapi.GssapiMechanismHandler) MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.MechanismHandler) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) DigestMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.digestMD5.DigestMd5MechanismHandler)

Example 12 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project sonarqube by SonarSource.

the class ApacheDS method startLdapServer.

private ApacheDS startLdapServer(int port) throws Exception {
    ldapServer.setTransports(new TcpTransport(port));
    ldapServer.setDirectoryService(directoryService);
    // Setup SASL mechanisms
    Map<String, MechanismHandler> mechanismHandlerMap = new HashMap<>();
    mechanismHandlerMap.put(SupportedSaslMechanisms.PLAIN, new PlainMechanismHandler());
    mechanismHandlerMap.put(SupportedSaslMechanisms.CRAM_MD5, new CramMd5MechanismHandler());
    mechanismHandlerMap.put(SupportedSaslMechanisms.DIGEST_MD5, new DigestMd5MechanismHandler());
    mechanismHandlerMap.put(SupportedSaslMechanisms.GSSAPI, new GssapiMechanismHandler());
    ldapServer.setSaslMechanismHandlers(mechanismHandlerMap);
    ldapServer.setSaslHost("localhost");
    ldapServer.setSaslRealms(Collections.singletonList(realm));
    // TODO ldapServer.setSaslPrincipal();
    // The base DN containing users that can be SASL authenticated.
    ldapServer.setSearchBaseDn(baseDn);
    ldapServer.start();
    return this;
}
Also used : PlainMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler) GssapiMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.gssapi.GssapiMechanismHandler) HashMap(java.util.HashMap) CramMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.cramMD5.CramMd5MechanismHandler) CramMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.cramMD5.CramMd5MechanismHandler) PlainMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler) DigestMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.digestMD5.DigestMd5MechanismHandler) GssapiMechanismHandler(org.apache.directory.server.ldap.handlers.sasl.gssapi.GssapiMechanismHandler) MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.MechanismHandler) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) DigestMd5MechanismHandler(org.apache.directory.server.ldap.handlers.sasl.digestMD5.DigestMd5MechanismHandler)

Example 13 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project ranger by apache.

the class TestLdapUserGroup method setup.

@Before
public void setup() throws Exception {
    LdapServer ldapServer = new LdapServer();
    ldapServer.setSaslHost("127.0.0.1");
    ldapServer.setSearchBaseDn("DC=ranger,DC=qe,DC=hortonworks,DC=com");
    String ldapPort = System.getProperty("ldap.port");
    Assert.assertNotNull("Property 'ldap.port' null", ldapPort);
    ldapServer.setTransports(new TcpTransport("127.0.0.1", Integer.parseInt(ldapPort)));
    ldapServer.setDirectoryService(getService());
    ldapServer.setMaxSizeLimit(LdapServer.NO_SIZE_LIMIT);
    setLdapServer(ldapServer);
    getService().startup();
    getLdapServer().start();
    config = UserGroupSyncConfig.getInstance();
    ldapBuilder = new LdapUserGroupBuilder();
    sink = new PolicyMgrUserGroupBuilderTest();
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) LdapUserGroupBuilder(org.apache.ranger.ldapusersync.process.LdapUserGroupBuilder) Before(org.junit.Before)

Example 14 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project knox by apache.

the class SimpleLdapServerTest method setup.

@BeforeClass
public static void setup() throws Exception {
    ldifFile = new File(ClassLoader.getSystemResource("users.ldif").toURI());
    ldapTransport = new TcpTransport(0);
    ldap = new SimpleLdapDirectoryServer("dc=hadoop,dc=apache,dc=org", ldifFile, ldapTransport);
    ldap.start();
    port = ldapTransport.getAcceptor().getLocalAddress().getPort();
}
Also used : TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 15 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project knox by apache.

the class GatewayTestDriver method setupLdap.

public int setupLdap(int port, File ldifConfig) throws Exception {
    ldapTransport = new TcpTransport(port);
    ldap = new SimpleLdapDirectoryServer("dc=hadoop,dc=apache,dc=org", ldifConfig, ldapTransport);
    ldap.start();
    log.info("LDAP port = " + ldapTransport.getAcceptor().getLocalAddress().getPort());
    return port;
}
Also used : SimpleLdapDirectoryServer(org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport)

Aggregations

TcpTransport (org.apache.directory.server.protocol.shared.transport.TcpTransport)19 LdapServer (org.apache.directory.server.ldap.LdapServer)9 File (java.io.File)6 Transport (org.apache.directory.server.protocol.shared.transport.Transport)4 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)3 UdpTransport (org.apache.directory.server.protocol.shared.transport.UdpTransport)3 HashMap (java.util.HashMap)2 Dn (org.apache.directory.api.ldap.model.name.Dn)2 CreateTransport (org.apache.directory.server.annotations.CreateTransport)2 DefaultDirectoryService (org.apache.directory.server.core.DefaultDirectoryService)2 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)2 DefaultDirectoryServiceFactory (org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory)2 MechanismHandler (org.apache.directory.server.ldap.handlers.sasl.MechanismHandler)2 CramMd5MechanismHandler (org.apache.directory.server.ldap.handlers.sasl.cramMD5.CramMd5MechanismHandler)2 DigestMd5MechanismHandler (org.apache.directory.server.ldap.handlers.sasl.digestMD5.DigestMd5MechanismHandler)2 GssapiMechanismHandler (org.apache.directory.server.ldap.handlers.sasl.gssapi.GssapiMechanismHandler)2 PlainMechanismHandler (org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler)2 SimpleLdapDirectoryServer (org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer)2 JsonPath (io.restassured.path.json.JsonPath)1 FileNotFoundException (java.io.FileNotFoundException)1