org.xnio.channels.AcceptingChannel Java Examples
The following examples show how to use
org.xnio.channels.AcceptingChannel.
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: UndertowAcceptingSslChannel.java From lams with GNU General Public License v2.0 | 6 votes |
UndertowAcceptingSslChannel(final UndertowXnioSsl ssl, final AcceptingChannel<? extends StreamConnection> tcpServer, final OptionMap optionMap, final ByteBufferPool applicationBufferPool, final boolean startTls) { this.tcpServer = tcpServer; this.ssl = ssl; this.applicationBufferPool = applicationBufferPool; this.startTls = startTls; clientAuthMode = optionMap.get(Options.SSL_CLIENT_AUTH_MODE); useClientMode = optionMap.get(Options.SSL_USE_CLIENT_MODE, false) ? 1 : 0; enableSessionCreation = optionMap.get(Options.SSL_ENABLE_SESSION_CREATION, true) ? 1 : 0; final Sequence<String> enabledCipherSuites = optionMap.get(Options.SSL_ENABLED_CIPHER_SUITES); cipherSuites = enabledCipherSuites != null ? enabledCipherSuites.toArray(new String[enabledCipherSuites.size()]) : null; final Sequence<String> enabledProtocols = optionMap.get(Options.SSL_ENABLED_PROTOCOLS); protocols = enabledProtocols != null ? enabledProtocols.toArray(new String[enabledProtocols.size()]) : null; //noinspection ThisEscapedInObjectConstruction closeSetter = ChannelListeners.<AcceptingChannel<SslConnection>>getDelegatingSetter(tcpServer.getCloseSetter(), this); //noinspection ThisEscapedInObjectConstruction acceptSetter = ChannelListeners.<AcceptingChannel<SslConnection>>getDelegatingSetter(tcpServer.getAcceptSetter(), this); useCipherSuitesOrder = optionMap.get(UndertowOptions.SSL_USER_CIPHER_SUITES_ORDER, false); }
Example #2
Source File: AbstractStreamServerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
AbstractStreamServerService( final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer, final Supplier<Endpoint> endpointSupplier, final Supplier<SecurityRealm> securityRealmSupplier, final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier, final Supplier<SSLContext> sslContextSupplier, final Supplier<SocketBindingManager> socketBindingManagerSupplier, final OptionMap connectorPropertiesOptionMap) { this.streamServerConsumer = streamServerConsumer; this.endpointSupplier = endpointSupplier; this.securityRealmSupplier = securityRealmSupplier; this.saslAuthenticationFactorySupplier = saslAuthenticationFactorySupplier; this.sslContextSupplier = sslContextSupplier; this.socketBindingManagerSupplier = socketBindingManagerSupplier; this.connectorPropertiesOptionMap = connectorPropertiesOptionMap; }
Example #3
Source File: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void installConnectorServicesForSocketBinding(final ServiceTarget serviceTarget, final ServiceName endpointName, final String connectorName, final ServiceName socketBindingName, final OptionMap connectorPropertiesOptionMap, final ServiceName securityRealm, final ServiceName saslAuthenticationFactory, final ServiceName sslContext, final ServiceName socketBindingManager) { final ServiceName serviceName = serverServiceName(connectorName); final ServiceBuilder<?> builder = serviceTarget.addService(serviceName); final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName); final Supplier<Endpoint> eSupplier = builder.requires(endpointName); final Supplier<SecurityRealm> srSupplier = securityRealm != null ? builder.requires(securityRealm) : null; final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? builder.requires(saslAuthenticationFactory) : null; final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requires(sslContext) : null; final Supplier<SocketBindingManager> sbmSupplier = builder.requires(socketBindingManager); final Supplier<SocketBinding> sbSupplier = builder.requires(socketBindingName); builder.setInstance(new InjectedSocketBindingStreamServerService(streamServerConsumer, eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, sbSupplier, connectorPropertiesOptionMap)); builder.install(); }
Example #4
Source File: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Deprecated public static void installConnectorServicesForNetworkInterfaceBinding(final ServiceTarget serviceTarget, final ServiceName endpointName, final String connectorName, final ServiceName networkInterfaceBindingName, final int port, final OptionMap connectorPropertiesOptionMap, final ServiceName securityRealm, final ServiceName saslAuthenticationFactory, final ServiceName sslContext, final ServiceName socketBindingManager) { final ServiceName serviceName= serverServiceName(connectorName); final ServiceBuilder<?> builder = serviceTarget.addService(serviceName); final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName); final Supplier<Endpoint> eSupplier = builder.requires(endpointName); final Supplier<SecurityRealm> srSupplier = securityRealm != null ? builder.requires(securityRealm) : null; final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? builder.requires(saslAuthenticationFactory) : null; final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requires(sslContext): null; final Supplier<SocketBindingManager> sbmSupplier = socketBindingManager != null ? builder.requires(socketBindingManager) : null; final Supplier<NetworkInterfaceBinding> ibSupplier = builder.requires(networkInterfaceBindingName); builder.setInstance(new InjectedNetworkBindingStreamServerService(streamServerConsumer, eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, ibSupplier, connectorPropertiesOptionMap, port)); builder.install(); }
Example #5
Source File: Undertow.java From lams with GNU General Public License v2.0 | 5 votes |
public synchronized void stop() { UndertowLogger.ROOT_LOGGER.debugf("stopping undertow server %s", this); if (channels != null) { for (AcceptingChannel<? extends StreamConnection> channel : channels) { IoUtils.safeClose(channel); } channels = null; } /* * Only shutdown the worker if it was created during start() */ if (internalWorker && worker != null) { Integer shutdownTimeoutMillis = serverOptions.get(UndertowOptions.SHUTDOWN_TIMEOUT); worker.shutdown(); try { if (shutdownTimeoutMillis == null) { worker.awaitTermination(); } else { if (!worker.awaitTermination(shutdownTimeoutMillis, TimeUnit.MILLISECONDS)) { worker.shutdownNow(); } } } catch (InterruptedException e) { worker.shutdownNow(); throw new RuntimeException(e); } worker = null; } xnio = null; listenerInfo = null; }
Example #6
Source File: Undertow.java From lams with GNU General Public License v2.0 | 5 votes |
public ListenerInfo(String protcol, SocketAddress address, OpenListener openListener, UndertowXnioSsl ssl, AcceptingChannel<? extends StreamConnection> channel) { this.protcol = protcol; this.address = address; this.openListener = openListener; this.ssl = ssl; this.channel = channel; }
Example #7
Source File: UndertowNetwork.java From actframework with Apache License 2.0 | 5 votes |
@Override protected void close() { if (null == channels) { // not booted yet return; } for (AcceptingChannel<? extends StreamConnection> channel : channels) { IO.close(channel); } channels.clear(); worker.shutdownNow(); }
Example #8
Source File: ChannelServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ChannelServer(final Endpoint endpoint, final Registration registration, final AcceptingChannel<StreamConnection> streamServer) { this.endpoint = endpoint; this.registration = registration; this.streamServer = streamServer; }
Example #9
Source File: ChannelServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static ChannelServer create(final Configuration configuration) throws IOException { if (configuration == null) { throw new IllegalArgumentException("Null configuration"); } configuration.validate(); // Hack WFCORE-3302/REM3-303 workaround if (firstCreate) { firstCreate = false; } else { try { // wait in case the previous socket has not closed Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } // TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build(); final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class); final SecurityDomain.Builder domainBuilder = SecurityDomain.builder(); final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm(); domainBuilder.addRealm("default", realm).build(); domainBuilder.setDefaultRealmName("default"); domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL); SecurityDomain testDomain = domainBuilder.build(); SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder() .setSecurityDomain(testDomain) .setMechanismConfigurationSelector(mechanismInformation -> "ANONYMOUS".equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null) .setFactory(new AnonymousServerFactory()) .build(); System.out.println(configuration.getBindAddress()); AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null); return new ChannelServer(endpoint, null, streamServer); }
Example #10
Source File: AbstractXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 5 votes |
@Override protected void doBeginRead() throws Exception { AcceptingChannel channel = xnioChannel(); if (channel == null) { return; } channel.resumeAccepts(); }
Example #11
Source File: InjectedSocketBindingStreamServerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
InjectedSocketBindingStreamServerService( final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer, final Supplier<Endpoint> endpointSupplier, final Supplier<SecurityRealm> securityRealmSupplier, final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier, final Supplier<SSLContext> sslContextSupplier, final Supplier<SocketBindingManager> socketBindingManagerSupplier, final Supplier<SocketBinding> socketBindingSupplier, final OptionMap connectorPropertiesOptionMap) { super(streamServerConsumer, endpointSupplier, securityRealmSupplier, saslAuthenticationFactorySupplier, sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap); this.socketBindingSupplier = socketBindingSupplier; }
Example #12
Source File: InjectedNetworkBindingStreamServerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
InjectedNetworkBindingStreamServerService( final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer, final Supplier<Endpoint> endpointSupplier, final Supplier<SecurityRealm> securityRealmSupplier, final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier, final Supplier<SSLContext> sslContextSupplier, final Supplier<SocketBindingManager> socketBindingManagerSupplier, final Supplier<NetworkInterfaceBinding> interfaceBindingSupplier, final OptionMap connectorPropertiesOptionMap, int port) { super(streamServerConsumer, endpointSupplier, securityRealmSupplier, saslAuthenticationFactorySupplier, sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap); this.interfaceBindingSupplier = interfaceBindingSupplier; this.port = port; }
Example #13
Source File: AbstractXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 5 votes |
@Override protected void doClose() throws Exception { AcceptingChannel channel = xnioChannel(); if (channel == null) { return; } channel.suspendAccepts(); channel.close(); }
Example #14
Source File: AbstractXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 5 votes |
@Override protected SocketAddress localAddress0() { AcceptingChannel channel = xnioChannel(); if (channel == null) { return null; } return channel.getLocalAddress(); }
Example #15
Source File: JaxRsServer.java From testfun with Apache License 2.0 | 5 votes |
public int getJaxrsPort() { try { Field channelsField = server.getClass().getDeclaredField("channels"); List<AcceptingChannel<? extends StreamConnection>> channels = InjectionUtils.readObjectFromField(server, channelsField); return ((InetSocketAddress)channels.get(0).getLocalAddress()).getPort(); } catch (NoSuchFieldException e) { throw new JaxRsException("Failed getting listener port", e); } }
Example #16
Source File: WrappingXnioSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 5 votes |
/** * Create a new {@link WrappingXnioSocketChannel} which was created via the given {@link AcceptingChannel} and uses * the given {@link StreamConnection} under the covers. */ public WrappingXnioSocketChannel(AcceptingChannel<StreamConnection> parent, StreamConnection channel) { this(new WrappingXnioServerSocketChannel(parent), channel); // register a EventLoop and start read unsafe().register(new XnioEventLoop(thread), unsafe().voidPromise()); read(); }
Example #17
Source File: WrappingXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 5 votes |
/** * Create a new instance wrapping the given {@link AcceptingChannel} */ @SuppressWarnings("unchecked") public WrappingXnioServerSocketChannel(AcceptingChannel channel) { if (channel == null) { throw new NullPointerException("channel"); } this.channel = channel; thread = channel.getIoThread(); channel.getAcceptSetter().set(new AcceptListener()); // register a EventLoop and start read unsafe().register(new XnioEventLoop(channel.getWorker().getIoThread()), unsafe().voidPromise()); read(); }
Example #18
Source File: AbstractXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public boolean isOpen() { AcceptingChannel channel = xnioChannel(); return channel == null || channel.isOpen(); }
Example #19
Source File: UndertowAcceptingSslChannel.java From lams with GNU General Public License v2.0 | 4 votes |
public ChannelListener.Setter<? extends AcceptingChannel<SslConnection>> getCloseSetter() { return closeSetter; }
Example #20
Source File: WrappingXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override protected AcceptingChannel xnioChannel() { return channel; }
Example #21
Source File: XnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override protected AcceptingChannel xnioChannel() { return channel; }
Example #22
Source File: ChannelServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public static ChannelServer create(final Configuration configuration) throws IOException { if (configuration == null) { throw new IllegalArgumentException("Null configuration"); } configuration.validate(); // Hack WFCORE-3302/REM3-303 workaround if (firstCreate) { firstCreate = false; } else { try { // wait in case the previous socket has not closed Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } // TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build(); final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class); final SecurityDomain.Builder domainBuilder = SecurityDomain.builder(); final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm(); realm.setPasswordMap("bob", ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, "pass".toCharArray())); domainBuilder.addRealm("default", realm).build(); domainBuilder.setDefaultRealmName("default"); domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL); SecurityDomain testDomain = domainBuilder.build(); SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder() .setSecurityDomain(testDomain) .setMechanismConfigurationSelector(mechanismInformation -> { switch (mechanismInformation.getMechanismName()) { case "ANONYMOUS": case "PLAIN": { return MechanismConfiguration.EMPTY; } default: return null; } }) .setFactory(SaslFactories.getElytronSaslServerFactory()) .build(); AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null); return new ChannelServer(endpoint, streamServer); }
Example #23
Source File: ChannelServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ChannelServer(final Endpoint endpoint, final AcceptingChannel<StreamConnection> streamServer) { this.endpoint = endpoint; this.streamServer = streamServer; }
Example #24
Source File: UndertowXnioSsl.java From lams with GNU General Public License v2.0 | 4 votes |
public AcceptingChannel<SslConnection> createSslConnectionServer(final XnioWorker worker, final InetSocketAddress bindAddress, final ChannelListener<? super AcceptingChannel<SslConnection>> acceptListener, final OptionMap optionMap) throws IOException { final UndertowAcceptingSslChannel server = new UndertowAcceptingSslChannel(this, worker.createStreamConnectionServer(bindAddress, null, optionMap), optionMap, bufferPool, false); if (acceptListener != null) server.getAcceptSetter().set(acceptListener); return server; }
Example #25
Source File: UndertowAcceptingSslChannel.java From lams with GNU General Public License v2.0 | 4 votes |
public ChannelListener.Setter<? extends AcceptingChannel<SslConnection>> getAcceptSetter() { return acceptSetter; }
Example #26
Source File: AbstractXnioServerSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 2 votes |
/** * Return the underyling {@link AcceptingChannel} */ protected abstract AcceptingChannel xnioChannel();