Search in sources :

Example 1 with UdpTransport

use of org.apache.directory.server.protocol.shared.transport.UdpTransport 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 2 with UdpTransport

use of org.apache.directory.server.protocol.shared.transport.UdpTransport 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 3 with UdpTransport

use of org.apache.directory.server.protocol.shared.transport.UdpTransport in project undertow by undertow-io.

the class KerberosKDCUtil method startKDC.

private static void startKDC() throws Exception {
    kdcServer = new KdcServer();
    kdcServer.setServiceName("Test KDC");
    kdcServer.setSearchBaseDn("ou=users,dc=undertow,dc=io");
    KerberosConfig config = kdcServer.getConfig();
    config.setServicePrincipal("krbtgt/UNDERTOW.IO@UNDERTOW.IO");
    config.setPrimaryRealm("UNDERTOW.IO");
    config.setPaEncTimestampRequired(false);
    UdpTransport udp = new UdpTransport("0.0.0.0", KDC_PORT);
    kdcServer.addTransports(udp);
    kdcServer.setDirectoryService(directoryService);
    kdcServer.start();
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) KerberosConfig(org.apache.directory.server.kerberos.KerberosConfig) KdcServer(org.apache.directory.server.kerberos.kdc.KdcServer)

Example 4 with UdpTransport

use of org.apache.directory.server.protocol.shared.transport.UdpTransport in project vert.x by eclipse.

the class FakeDNSServer method start.

@Override
public void start() throws IOException {
    UdpTransport transport = new UdpTransport("127.0.0.1", port);
    setTransports(transport);
    acceptor = transport.getAcceptor();
    acceptor.setHandler(new DnsProtocolHandler(this, store) {

        @Override
        public void sessionCreated(IoSession session) throws Exception {
            // Use our own codec to support AAAA testing
            session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
        }
    });
    // Allow the port to be reused even if the socket is in TIME_WAIT state
    ((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
    // Start the listener
    acceptor.bind();
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) DatagramSessionConfig(org.apache.mina.transport.socket.DatagramSessionConfig) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) DnsProtocolHandler(org.apache.directory.server.dns.protocol.DnsProtocolHandler) IOException(java.io.IOException) IoSession(org.apache.mina.core.session.IoSession)

Example 5 with UdpTransport

use of org.apache.directory.server.protocol.shared.transport.UdpTransport in project netty by netty.

the class TestDnsServer method start.

@Override
public void start() throws IOException {
    InetSocketAddress address = new InetSocketAddress(NetUtil.LOCALHOST4, 0);
    UdpTransport transport = new UdpTransport(address.getHostName(), address.getPort());
    setTransports(transport);
    DatagramAcceptor acceptor = transport.getAcceptor();
    acceptor.setHandler(new DnsProtocolHandler(this, store) {

        @Override
        public void sessionCreated(IoSession session) throws Exception {
            // USe our own codec to support AAAA testing
            session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
        }
    });
    ((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
    // Start the listener
    acceptor.bind();
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) DatagramAcceptor(org.apache.mina.transport.socket.DatagramAcceptor) InetSocketAddress(java.net.InetSocketAddress) DatagramSessionConfig(org.apache.mina.transport.socket.DatagramSessionConfig) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) DnsProtocolHandler(org.apache.directory.server.dns.protocol.DnsProtocolHandler) DnsException(org.apache.directory.server.dns.DnsException) IOException(java.io.IOException) IoSession(org.apache.mina.core.session.IoSession)

Aggregations

UdpTransport (org.apache.directory.server.protocol.shared.transport.UdpTransport)5 IOException (java.io.IOException)3 CreateTransport (org.apache.directory.server.annotations.CreateTransport)2 DnsProtocolHandler (org.apache.directory.server.dns.protocol.DnsProtocolHandler)2 KerberosConfig (org.apache.directory.server.kerberos.KerberosConfig)2 KdcServer (org.apache.directory.server.kerberos.kdc.KdcServer)2 TcpTransport (org.apache.directory.server.protocol.shared.transport.TcpTransport)2 Transport (org.apache.directory.server.protocol.shared.transport.Transport)2 IoSession (org.apache.mina.core.session.IoSession)2 ProtocolCodecFilter (org.apache.mina.filter.codec.ProtocolCodecFilter)2 DatagramSessionConfig (org.apache.mina.transport.socket.DatagramSessionConfig)2 InetSocketAddress (java.net.InetSocketAddress)1 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)1 CreateChngPwdServer (org.apache.directory.server.annotations.CreateChngPwdServer)1 CreateKdcServer (org.apache.directory.server.annotations.CreateKdcServer)1 DnsException (org.apache.directory.server.dns.DnsException)1 ChangePasswordConfig (org.apache.directory.server.kerberos.ChangePasswordConfig)1 ChangePasswordServer (org.apache.directory.server.kerberos.changepwd.ChangePasswordServer)1 DatagramAcceptor (org.apache.mina.transport.socket.DatagramAcceptor)1