Search in sources :

Example 1 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project jackrabbit-oak by apache.

the class AbstractServer method setupLdapServer.

protected void setupLdapServer() throws Exception {
    ldapServer.setTransports(new TcpTransport(port));
    ldapServer.setDirectoryService(directoryService);
    ldapServer.addExtendedOperationHandler(new StartTlsHandler());
    ldapServer.addExtendedOperationHandler(new StoredProcedureExtendedOperationHandler());
}
Also used : StoredProcedureExtendedOperationHandler(org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler) StartTlsHandler(org.apache.directory.server.ldap.handlers.extended.StartTlsHandler) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport)

Example 2 with TcpTransport

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

the class SimpleLdapDirectoryServer method main.

public static void main(String[] args) throws Exception {
    PropertyConfigurator.configure(System.getProperty("log4j.configuration"));
    SimpleLdapDirectoryServer ldap;
    File file;
    if (args.length < 1) {
        file = new File("conf/users.ldif");
    } else {
        File dir = new File(args[0]);
        if (!dir.exists() || !dir.isDirectory()) {
            throw new FileNotFoundException(dir.getAbsolutePath());
        }
        file = new File(dir, "users.ldif");
    }
    if (!file.exists() || !file.canRead()) {
        throw new FileNotFoundException(file.getAbsolutePath());
    }
    int port = 33389;
    // Make sure the port is free.
    ServerSocket socket = new ServerSocket(port);
    socket.close();
    TcpTransport transport = new TcpTransport(port);
    ldap = new SimpleLdapDirectoryServer("dc=hadoop,dc=apache,dc=org", file, transport);
    ldap.start();
}
Also used : FileNotFoundException(java.io.FileNotFoundException) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) ServerSocket(java.net.ServerSocket) File(java.io.File)

Example 3 with TcpTransport

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

the class GatewayHealthFuncTest method setupLdap.

public static void setupLdap() throws Exception {
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }
    final Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/users.ldif");
    ldapTransport = new TcpTransport(0);
    ldap = new SimpleLdapDirectoryServer("dc=hadoop,dc=apache,dc=org", path.toFile(), ldapTransport);
    ldap.start();
    LOG.info("LDAP port = " + ldapTransport.getPort());
}
Also used : JsonPath(io.restassured.path.json.JsonPath) Path(java.nio.file.Path) SimpleLdapDirectoryServer(org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) File(java.io.File)

Example 4 with TcpTransport

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

the class ApacheDSStartStopListener method contextInitialized.

/**
 * Startup ApacheDS embedded.
 *
 * @param sce ServletContext event
 */
@Override
public void contextInitialized(final ServletContextEvent sce) {
    File workDir = (File) sce.getServletContext().getAttribute("javax.servlet.context.tempdir");
    workDir = new File(workDir, "server-work");
    final boolean loadDefaultContent = !workDir.exists();
    if (loadDefaultContent && !workDir.mkdirs()) {
        throw new RuntimeException("Could not create " + workDir.getAbsolutePath());
    }
    Entry result;
    try {
        initDirectoryService(sce.getServletContext(), workDir, loadDefaultContent);
        server = new LdapServer();
        server.setTransports(new TcpTransport(Integer.parseInt(WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()).getBean("testds.port", String.class))));
        server.setDirectoryService(service);
        server.start();
        // store directoryService in context to provide it to servlets etc.
        sce.getServletContext().setAttribute(DirectoryService.JNDI_KEY, service);
        result = service.getAdminSession().lookup(new Dn("o=isp"));
    } catch (Exception e) {
        LOG.error("Fatal error in context init", e);
        throw new RuntimeException(e);
    }
    if (result == null) {
        throw new RuntimeException("Base DN not found");
    } else {
        LOG.info("ApacheDS startup completed succesfully");
    }
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) Entry(org.apache.directory.api.ldap.model.entry.Entry) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) Dn(org.apache.directory.api.ldap.model.name.Dn) File(java.io.File)

Example 5 with TcpTransport

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

the class LDAPServerService method initialize.

@Override
public boolean initialize(final StructrServices services) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    logger.info("Initializing directory service");
    try {
        ds = new DefaultDirectoryService();
        final SchemaManager schemaManager = new DefaultSchemaManager();
        final SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
        final StructrPartition structrSchemaPartition = new StructrPartition(schemaManager, "schema", new Dn("ou=system"));
        schemaPartition.setWrappedPartition(structrSchemaPartition);
        ds.setInstanceLayout(new InstanceLayout(new File("/tmp/ldap-test")));
        ds.setSchemaPartition(schemaPartition);
        ds.setSchemaManager(schemaManager);
        ds.setSystemPartition(new StructrPartition(schemaManager, "system", new Dn("ou=system")));
        ds.startup();
        logger.info("Importing schema..");
        initSchema(schemaManager, ds.getAdminSession(), structrSchemaPartition);
        server = new LdapServer();
        int serverPort = 10389;
        server.setTransports(new TcpTransport(serverPort));
        server.setDirectoryService(ds);
        server.start();
    } catch (Throwable t) {
        t.printStackTrace();
        logger.warn("Unable to start LDAP server: {}", t.getMessage());
        return false;
    }
    return true;
}
Also used : DefaultDirectoryService(org.apache.directory.server.core.DefaultDirectoryService) SchemaPartition(org.apache.directory.server.core.api.schema.SchemaPartition) InstanceLayout(org.apache.directory.server.core.api.InstanceLayout) LdapServer(org.apache.directory.server.ldap.LdapServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) Dn(org.apache.directory.api.ldap.model.name.Dn) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) JarFile(java.util.jar.JarFile) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)

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