Search in sources :

Example 6 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport 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();
}
Also used : KeyDerivationInterceptor(org.apache.directory.server.core.kerberos.KeyDerivationInterceptor) LdapServer(org.apache.directory.server.ldap.LdapServer) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) CoreSession(org.apache.directory.server.core.api.CoreSession) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) Transport(org.apache.directory.server.protocol.shared.transport.Transport) DirectoryServiceFactory(org.apache.directory.server.core.factory.DirectoryServiceFactory) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory)

Example 7 with TcpTransport

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

the class NoReplayKdcServer method createTransport.

private static Transport createTransport(CreateTransport transportBuilder, int startPort) {
    String protocol = transportBuilder.protocol();
    int port = transportBuilder.port();
    int nbThreads = transportBuilder.nbThreads();
    int backlog = transportBuilder.backlog();
    String address = transportBuilder.address();
    if (port == -1) {
        port = AvailablePortFinder.getNextAvailable(startPort);
        startPort = port + 1;
    }
    if (protocol.equalsIgnoreCase("TCP")) {
        Transport tcp = new TcpTransport(address, port, nbThreads, backlog);
        return tcp;
    } else if (protocol.equalsIgnoreCase("UDP")) {
        UdpTransport udp = new UdpTransport(address, port);
        return udp;
    } else {
        throw new IllegalArgumentException(I18n.err(I18n.ERR_689, protocol));
    }
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) CreateTransport(org.apache.directory.server.annotations.CreateTransport) UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) Transport(org.apache.directory.server.protocol.shared.transport.Transport)

Example 8 with TcpTransport

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

the class NoReplayKdcServer method createKdcServer.

// Private methods -------------------------------------------------------
/**
 * Creates and starts {@link KdcServer} instance based on given configuration.
 *
 * @param createKdcServer
 * @param directoryService
 * @param startPort
 * @return
 */
private static KdcServer createKdcServer(CreateKdcServer createKdcServer, DirectoryService directoryService, int startPort, String bindAddress) {
    if (createKdcServer == null) {
        return null;
    }
    KerberosConfig kdcConfig = new KerberosConfig();
    kdcConfig.setServicePrincipal(createKdcServer.kdcPrincipal());
    kdcConfig.setPrimaryRealm(createKdcServer.primaryRealm());
    kdcConfig.setMaximumTicketLifetime(createKdcServer.maxTicketLifetime());
    kdcConfig.setMaximumRenewableLifetime(createKdcServer.maxRenewableLifetime());
    kdcConfig.setPaEncTimestampRequired(false);
    KdcServer kdcServer = new NoReplayKdcServer(kdcConfig);
    kdcServer.setSearchBaseDn(createKdcServer.searchBaseDn());
    CreateTransport[] transportBuilders = createKdcServer.transports();
    if (transportBuilders == null) {
        // create only UDP transport if none specified
        UdpTransport defaultTransport = new UdpTransport(bindAddress, AvailablePortFinder.getNextAvailable(startPort));
        kdcServer.addTransports(defaultTransport);
    } else if (transportBuilders.length > 0) {
        for (CreateTransport transportBuilder : transportBuilders) {
            String protocol = transportBuilder.protocol();
            int port = transportBuilder.port();
            int nbThreads = transportBuilder.nbThreads();
            int backlog = transportBuilder.backlog();
            final String address = bindAddress != null ? bindAddress : transportBuilder.address();
            if (port == -1) {
                port = AvailablePortFinder.getNextAvailable(startPort);
                startPort = port + 1;
            }
            if (protocol.equalsIgnoreCase("TCP")) {
                Transport tcp = new TcpTransport(address, port, nbThreads, backlog);
                kdcServer.addTransports(tcp);
            } else if (protocol.equalsIgnoreCase("UDP")) {
                UdpTransport udp = new UdpTransport(address, port);
                kdcServer.addTransports(udp);
            } else {
                throw new IllegalArgumentException(I18n.err(I18n.ERR_689, protocol));
            }
        }
    }
    CreateChngPwdServer[] createChngPwdServers = createKdcServer.chngPwdServer();
    if (createChngPwdServers.length > 0) {
        CreateChngPwdServer createChngPwdServer = createChngPwdServers[0];
        ChangePasswordConfig config = new ChangePasswordConfig(kdcConfig);
        config.setServicePrincipal(createChngPwdServer.srvPrincipal());
        ChangePasswordServer chngPwdServer = new ChangePasswordServer(config);
        for (CreateTransport transportBuilder : createChngPwdServer.transports()) {
            Transport t = createTransport(transportBuilder, startPort);
            startPort = t.getPort() + 1;
            chngPwdServer.addTransports(t);
        }
        chngPwdServer.setDirectoryService(directoryService);
        kdcServer.setChangePwdServer(chngPwdServer);
    }
    kdcServer.setDirectoryService(directoryService);
    // Launch the server
    try {
        kdcServer.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return kdcServer;
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) KerberosConfig(org.apache.directory.server.kerberos.KerberosConfig) CreateTransport(org.apache.directory.server.annotations.CreateTransport) ChangePasswordServer(org.apache.directory.server.kerberos.changepwd.ChangePasswordServer) IOException(java.io.IOException) LdapInvalidDnException(org.apache.directory.api.ldap.model.exception.LdapInvalidDnException) ChangePasswordConfig(org.apache.directory.server.kerberos.ChangePasswordConfig) CreateChngPwdServer(org.apache.directory.server.annotations.CreateChngPwdServer) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) CreateTransport(org.apache.directory.server.annotations.CreateTransport) UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport) Transport(org.apache.directory.server.protocol.shared.transport.Transport) KdcServer(org.apache.directory.server.kerberos.kdc.KdcServer) CreateKdcServer(org.apache.directory.server.annotations.CreateKdcServer)

Example 9 with TcpTransport

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

the class EmbeddedLdapServer method init.

public void init() throws Exception {
    if (getDirectoryService() == null) {
        if (getDeleteInstanceDirectoryOnStartup()) {
            deleteDirectory(getGuessedInstanceDirectory());
        }
        DefaultDirectoryServiceFactory serviceFactory = new DefaultDirectoryServiceFactory();
        serviceFactory.init(getDirectoryServiceName());
        setDirectoryService(serviceFactory.getDirectoryService());
        getDirectoryService().getChangeLog().setEnabled(false);
        getDirectoryService().setDenormalizeOpAttrsEnabled(true);
        createBasePartition();
        getDirectoryService().startup();
        createRootEntry();
    }
    if (getLdapServer() == null) {
        setLdapServer(new LdapServer());
        getLdapServer().setDirectoryService(getDirectoryService());
        getLdapServer().setTransports(new TcpTransport(getLdapServerPort()));
        getLdapServer().start();
    }
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) DefaultDirectoryServiceFactory(org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory) TcpTransport(org.apache.directory.server.protocol.shared.transport.TcpTransport)

Example 10 with TcpTransport

use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project aws-iam-ldap-bridge by denismo.

the class Runner method startServer.

/**
 * starts the LdapServer
 *
 * @throws Exception
 */
public void startServer() throws Exception {
    server = new LdapServer();
    server.setTransports(new TcpTransport(serverPort));
    server.setDirectoryService(service);
    server.start();
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) 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