org.apache.directory.server.protocol.shared.transport.UdpTransport Java Examples

The following examples show how to use org.apache.directory.server.protocol.shared.transport.UdpTransport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KerberosKDCUtil.java    From quarkus-http with Apache License 2.0 6 votes vote down vote up
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/[email protected]");
    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();
}
 
Example #2
Source File: TestDnsServer.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #3
Source File: TestDnsServer.java    From servicetalk with Apache License 2.0 6 votes vote down vote up
@Override
public void start() throws IOException {
    InetSocketAddress address = AddressUtils.localAddress(0);
    UdpTransport transport = new UdpTransport(address.getHostString(), address.getPort());
    setTransports(transport);

    DatagramAcceptor acceptor = transport.getAcceptor();

    acceptor.setHandler(new DnsProtocolHandler(this, store) {
        @Override
        public void sessionCreated(IoSession session) {
            // 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();
}
 
Example #4
Source File: ApacheDirectoryServer.java    From light-oauth2 with Apache License 2.0 6 votes vote down vote up
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/[email protected]");
    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();
}
 
Example #5
Source File: ApacheDirectoryServer.java    From light-oauth2 with Apache License 2.0 6 votes vote down vote up
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/[email protected]");
    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();
}
 
Example #6
Source File: LdapServer.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * @return The underlying TCP transport port, or -1 if no transport has been 
 * initialized
 */
public int getPort()
{
    if ( transports == null )
    {
        return -1;
    }

    for ( Transport transport : transports )
    {
        if ( transport instanceof UdpTransport )
        {
            continue;
        }

        if ( !transport.isSSLEnabled() )
        {
            return transport.getPort();
        }
    }

    return -1;
}
 
Example #7
Source File: LdapServer.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * @return The underlying SSL enabled TCP transport port, or -1 if no transport has been 
 * initialized
 */
public int getPortSSL()
{
    if ( transports == null )
    {
        return -1;
    }

    for ( Transport transport : transports )
    {
        if ( transport instanceof UdpTransport )
        {
            continue;
        }

        if ( transport.isSSLEnabled() )
        {
            return transport.getPort();
        }
    }

    return -1;
}
 
Example #8
Source File: LdapServer.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * @return The underlying TCP transport port, or -1 if no transport has been 
 * initialized
 */
public int getPort()
{
    if ( transports == null )
    {
        return -1;
    }

    for ( Transport transport : transports )
    {
        if ( transport instanceof UdpTransport )
        {
            continue;
        }

        if ( !transport.isSSLEnabled() )
        {
            return transport.getPort();
        }
    }

    return -1;
}
 
Example #9
Source File: LdapServer.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * @return The underlying SSL enabled TCP transport port, or -1 if no transport has been 
 * initialized
 */
public int getPortSSL()
{
    if ( transports == null )
    {
        return -1;
    }

    for ( Transport transport : transports )
    {
        if ( transport instanceof UdpTransport )
        {
            continue;
        }

        if ( transport.isSSLEnabled() )
        {
            return transport.getPort();
        }
    }

    return -1;
}
 
Example #10
Source File: ApacheKDCServer.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private void configureTransportHandlers(KdcConfiguration configuration) {

        int port = getServerPort(configuration);
        if (configuration.getKdcCommunicationProtocol() ==
                KdcConfiguration.ProtocolType.UDP_PROTOCOL) {

            logger.info("Starting KDC on UDP mode at port - " + port + " at host - " +
                    configuration.getKdcHostAddress());

            UdpTransport defaultTransport = new UdpTransport(port);
            this.kdcServer.addTransports(defaultTransport);

        } else {

            logger.info("Starting KDC on a TCP port " + port + " at host " +
                    configuration.getKdcHostAddress());
            Transport tcp =
                    new TcpTransport(configuration.getKdcHostAddress(), port,
                            configuration.getNumberOfThreads(),
                            configuration.getBackLogCount());
            this.kdcServer.addTransports(tcp);

        }
    }
 
Example #11
Source File: KerberosEmbeddedServer.java    From keycloak with Apache License 2.0 6 votes vote down vote up
protected KdcServer createAndStartKdcServer() throws Exception {
    KerberosConfig kdcConfig = new KerberosConfig();
    kdcConfig.setServicePrincipal("krbtgt/" + this.kerberosRealm + "@" + this.kerberosRealm);
    kdcConfig.setPrimaryRealm(this.kerberosRealm);
    kdcConfig.setMaximumTicketLifetime(60000 * 1440);
    kdcConfig.setMaximumRenewableLifetime(60000 * 10080);
    kdcConfig.setPaEncTimestampRequired(false);
    Set<EncryptionType> encryptionTypes = convertEncryptionTypes();
    kdcConfig.setEncryptionTypes(encryptionTypes);

    kdcServer = new NoReplayKdcServer(kdcConfig);
    kdcServer.setSearchBaseDn(this.baseDN);

    UdpTransport udp = new UdpTransport(this.bindHost, this.kdcPort);
    kdcServer.addTransports(udp);

    kdcServer.setDirectoryService(directoryService);

    // Launch the server
    kdcServer.start();

    return kdcServer;
}
 
Example #12
Source File: KDCServerAnnotationProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 ) );
    }
}