org.xnio.Options Java Examples
The following examples show how to use
org.xnio.Options.
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: UndertowLauncher.java From seed with Mozilla Public License 2.0 | 6 votes |
private void createWorker(Coffig config) throws Exception { UndertowConfig undertowConfig = config.get(UndertowConfig.class); try { xnioWorker = Xnio.getInstance().createWorker(OptionMap.builder() .set(Options.WORKER_IO_THREADS, undertowConfig.getIoThreads()) .set(Options.WORKER_TASK_CORE_THREADS, undertowConfig.getWorkerThreads()) .set(Options.WORKER_TASK_MAX_THREADS, undertowConfig.getWorkerThreads()) .set(Options.TCP_NODELAY, undertowConfig.isTcpNoDelay()) .set(Options.READ_TIMEOUT, undertowConfig.getReadTimeout()) .set(Options.WRITE_TIMEOUT, undertowConfig.getWriteTimeout()) .getMap()); } catch (RuntimeException e) { throw unwrapUndertowException(e); } }
Example #2
Source File: HttpClientProvider.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioIoThread ioThread, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals("https")) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(ioThread, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(ioThread, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #3
Source File: UndertowSslConnection.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException { if (option == Options.SSL_CLIENT_AUTH_MODE) { try { return option.cast(engine.getNeedClientAuth() ? SslClientAuthMode.REQUIRED : engine.getWantClientAuth() ? SslClientAuthMode.REQUESTED : SslClientAuthMode.NOT_REQUESTED); } finally { engine.setNeedClientAuth(value == SslClientAuthMode.REQUIRED); engine.setWantClientAuth(value == SslClientAuthMode.REQUESTED); } } else if (option == Options.SECURE) { throw new IllegalArgumentException(); } else { return delegate.setOption(option, value); } }
Example #4
Source File: ManagementHttpServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void start() { try { OptionMap.Builder serverOptionsBuilder = OptionMap.builder() .set(Options.TCP_NODELAY, true) .set(Options.REUSE_ADDRESSES, true); ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener); if (httpAddress != null) { normalServer = worker.createStreamConnectionServer(httpAddress, acceptListener, serverOptionsBuilder.getMap()); normalServer.resumeAccepts(); } if (secureAddress != null) { if (sslClientAuthMode != null) { serverOptionsBuilder.set(SSL_CLIENT_AUTH_MODE, sslClientAuthMode); } OptionMap secureOptions = serverOptionsBuilder.getMap(); XnioSsl xnioSsl = new UndertowXnioSsl(worker.getXnio(), secureOptions, sslContext); secureServer = xnioSsl.createSslConnectionServer(worker, secureAddress, acceptListener, secureOptions); secureServer.resumeAccepts(); } } catch (IOException e) { throw new RuntimeException(e); } }
Example #5
Source File: UndertowAcceptingSslChannel.java From lams with GNU General Public License v2.0 | 6 votes |
public <T> T getOption(final Option<T> option) throws IOException { if (option == Options.SSL_CLIENT_AUTH_MODE) { return option.cast(clientAuthMode); } else if (option == Options.SSL_USE_CLIENT_MODE) { return option.cast(Boolean.valueOf(useClientMode != 0)); } else if (option == Options.SSL_ENABLE_SESSION_CREATION) { return option.cast(Boolean.valueOf(enableSessionCreation != 0)); } else if (option == Options.SSL_ENABLED_CIPHER_SUITES) { final String[] cipherSuites = this.cipherSuites; return cipherSuites == null ? null : option.cast(Sequence.of(cipherSuites)); } else if (option == Options.SSL_ENABLED_PROTOCOLS) { final String[] protocols = this.protocols; return protocols == null ? null : option.cast(Sequence.of(protocols)); } else { return tcpServer.getOption(option); } }
Example #6
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 #7
Source File: ManagementWorkerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void installService(ServiceTarget serviceTarget){ //todo make configurable ManagementWorkerService service = new ManagementWorkerService(OptionMap.builder() .set(Options.WORKER_IO_THREADS, 2) .set(Options.WORKER_TASK_CORE_THREADS, 5) .set(Options.WORKER_TASK_MAX_THREADS, 10) .set(Options.TCP_NODELAY, true) .set(Options.CORK, true) .set(Options.WORKER_NAME, "management") .getMap()); serviceTarget.addService(SERVICE_NAME, service) .setInitialMode(ServiceController.Mode.ON_DEMAND) //have it on demand as it might not be needed in certain scenarios .install(); }
Example #8
Source File: UndertowOptionMapConfiguration.java From galeb with Apache License 2.0 | 6 votes |
public OptionMap buildUndertowOptionMapFromEnvironment(String prefix, Map<String, String> environmentVariables) { if (!prefix.endsWith("_")) { prefix = prefix + "_"; } String prefixWithoutUnderscoreAtEnd = prefix.substring(0, prefix.length() - 1); Properties properties = new Properties(); for (Entry<String, String> entry : environmentVariables.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { String keyWithoutPrefix = key.substring(prefix.length()); String fieldValue = entry.getValue(); String className = Options.class.getName(); String propertyKey = prefixWithoutUnderscoreAtEnd + "." + className + "." + keyWithoutPrefix; properties.put(propertyKey, fieldValue); } } OptionMap optionMap = OptionMap.builder().parseAll(properties, prefixWithoutUnderscoreAtEnd).getMap(); return optionMap; }
Example #9
Source File: UndertowConfiguration.java From galeb with Apache License 2.0 | 6 votes |
@Bean public Undertow undertow() { return Undertow.builder().addHttpListener(port, "0.0.0.0", rootHandler) .setIoThreads(Integer.parseInt(SystemEnv.IO_THREADS.getValue())) .setWorkerThreads(Integer.parseInt(SystemEnv.WORKER_THREADS.getValue())) .setBufferSize(Integer.parseInt(SystemEnv.BUFFER_SIZE.getValue())) .setDirectBuffers(Boolean.parseBoolean(SystemEnv.DIRECT_BUFFER.getValue())) .setSocketOption(Options.BACKLOG, Integer.parseInt(SystemEnv.BACKLOG.getValue())) .setSocketOption(Options.KEEP_ALIVE, true) .setSocketOption(Options.REUSE_ADDRESSES, true) .setSocketOption(Options.TCP_NODELAY, true) .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, true) .setServerOption(UndertowOptions.ENABLE_STATISTICS, true) .setServerOption(UndertowOptions.ALLOW_UNESCAPED_CHARACTERS_IN_URL, true) .build(); }
Example #10
Source File: HttpClientProvider.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals("https")) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #11
Source File: ConnectorUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected static OptionMap getFullOptions(OperationContext context, ModelNode fullModel) throws OperationFailedException { OptionMap.Builder builder = OptionMap.builder(); builder.set(Options.TCP_NODELAY, true); builder.set(Options.REUSE_ADDRESSES, true); builder.set(RemotingOptions.SASL_PROTOCOL, ConnectorCommon.SASL_PROTOCOL.resolveModelAttribute(context, fullModel).asString()); ModelNode serverName = ConnectorCommon.SERVER_NAME.resolveModelAttribute(context, fullModel); if (serverName.isDefined()) { builder.set(RemotingOptions.SERVER_NAME, serverName.asString()); } ModelNode properties = fullModel.get(PROPERTY); if (properties.isDefined() && properties.asInt() > 0) { addOptions(context, properties, builder); } if (fullModel.hasDefined(SECURITY)) { ModelNode security = fullModel.require(SECURITY); if (security.hasDefined(SASL)) { ModelNode sasl = security.require(SASL); addSasl(context, sasl, builder); } } return builder.getMap(); }
Example #12
Source File: Http2SslSessionInfo.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, RenegotiationRequiredException { try { return channel.getSslSession().getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { throw new RenegotiationRequiredException(); } } catch (IOException e1) { //ignore, will not actually happen } throw e; } }
Example #13
Source File: UndertowHTTPServerEngine.java From cxf with Apache License 2.0 | 6 votes |
private Builder configureThreads(Builder builder) { if (this.threadingParameters != null) { if (this.threadingParameters.isWorkerIOThreadsSet()) { builder = builder.setWorkerOption(Options.WORKER_IO_THREADS, this.threadingParameters.getWorkerIOThreads()); } if (this.threadingParameters.isMinThreadsSet()) { builder = builder.setWorkerOption(Options.WORKER_TASK_CORE_THREADS, this.threadingParameters.getMinThreads()); } if (this.threadingParameters.isMaxThreadsSet()) { builder = builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS, this.threadingParameters.getMaxThreads()); } if (this.threadingParameters.isWorkerIONameSet()) { builder = builder.setWorkerOption(Options.WORKER_NAME, this.threadingParameters.getWorkerIOName()); } } return builder; }
Example #14
Source File: ConnectionSSLSessionInfo.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, RenegotiationRequiredException { if(unverified != null) { throw unverified; } if(renegotiationRequiredException != null) { throw renegotiationRequiredException; } try { return channel.getSslSession().getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { renegotiationRequiredException = RENEGOTIATION_REQUIRED_EXCEPTION; throw renegotiationRequiredException; } } catch (IOException e1) { //ignore, will not actually happen } unverified = PEER_UNVERIFIED_EXCEPTION; throw unverified; } }
Example #15
Source File: ConnectionSSLSessionInfo.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException, RenegotiationRequiredException { if(unverified != null) { throw unverified; } if(renegotiationRequiredException != null) { throw renegotiationRequiredException; } try { return channel.getSslSession().getPeerCertificateChain(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { renegotiationRequiredException = RENEGOTIATION_REQUIRED_EXCEPTION; throw renegotiationRequiredException; } } catch (IOException e1) { //ignore, will not actually happen } unverified = PEER_UNVERIFIED_EXCEPTION; throw unverified; } }
Example #16
Source File: IOSubsystem11TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(mainServices.getBootError().toString()); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default"); ModelNode op = Util.createOperation("read-resource", addr); op.get("include-runtime").set(true); mainServices.executeOperation(op); }
Example #17
Source File: MCMPHandler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Check whether a host is up. * * @param scheme the scheme * @param host the host * @param port the port * @param exchange the http server exchange * @param callback the ping callback */ protected void checkHostUp(final String scheme, final String host, final int port, final HttpServerExchange exchange, final NodePingUtil.PingCallback callback) { final XnioSsl xnioSsl = null; // TODO final OptionMap options = OptionMap.builder() .set(Options.TCP_NODELAY, true) .getMap(); try { // http, ajp and maybe more in future if ("ajp".equalsIgnoreCase(scheme) || "http".equalsIgnoreCase(scheme)) { final URI uri = new URI(scheme, null, host, port, "/", null, null); NodePingUtil.pingHttpClient(uri, callback, exchange, container.getClient(), xnioSsl, options); } else { final InetSocketAddress address = new InetSocketAddress(host, port); NodePingUtil.pingHost(address, exchange, callback, options); } } catch (URISyntaxException e) { callback.failed(); } }
Example #18
Source File: WriteTimeoutStreamSinkConduit.java From lams with GNU General Public License v2.0 | 6 votes |
private Integer getTimeout() { Integer timeout = 0; try { timeout = connection.getSourceChannel().getOption(Options.WRITE_TIMEOUT); } catch (IOException ignore) { // should never happen, ignoring } Integer idleTimeout = openListener.getUndertowOptions().get(UndertowOptions.IDLE_TIMEOUT); if ((timeout == null || timeout <= 0) && idleTimeout != null) { timeout = idleTimeout; } else if (timeout != null && idleTimeout != null && idleTimeout > 0) { timeout = Math.min(timeout, idleTimeout); } return timeout; }
Example #19
Source File: RemoteChannelPairSetup.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void startChannels() throws IOException, URISyntaxException { ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(channelServer.getEndpoint(), new URI("" + URI_SCHEME + "://127.0.0.1:" + PORT + ""), OptionMap.create(Options.SASL_POLICY_NOANONYMOUS, Boolean.FALSE, Options.SSL_ENABLED, Boolean.FALSE)); configuration.setClientBindAddress("127.0.0.1"); // we set this to exercise this code path in ProtocolConnectionUtils.connectSync // The path with no client bind address gets used all the time connection = ProtocolConnectionUtils.connectSync(configuration); clientChannel = connection.openChannel(TEST_CHANNEL, OptionMap.EMPTY).get(); try { clientConnectedLatch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
Example #20
Source File: ProtocolConnectionUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static AuthenticationConfiguration configureSaslMechanisms(Map<String, String> saslOptions, boolean isLocal, AuthenticationConfiguration authenticationConfiguration) { String[] mechanisms = null; String listed; if (saslOptions != null && (listed = saslOptions.get(Options.SASL_DISALLOWED_MECHANISMS.getName())) != null) { // Disallowed mechanisms were passed via the saslOptions map; need to convert to an XNIO option String[] split = listed.split(" "); if (isLocal) { mechanisms = new String[split.length + 1]; mechanisms[0] = JBOSS_LOCAL_USER; System.arraycopy(split, 0, mechanisms, 1, split.length); } else { mechanisms = split; } } else if (!isLocal) { mechanisms = new String[]{ JBOSS_LOCAL_USER }; } return (mechanisms != null && mechanisms.length > 0) ? authenticationConfiguration.setSaslMechanismSelector(SaslMechanismSelector.DEFAULT.forbidMechanisms(mechanisms)) : authenticationConfiguration; }
Example #21
Source File: Http2SslSessionInfo.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException, RenegotiationRequiredException { try { return channel.getSslSession().getPeerCertificateChain(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { throw new RenegotiationRequiredException(); } } catch (IOException e1) { //ignore, will not actually happen } throw e; } }
Example #22
Source File: Light4jHttpClientProvider.java From light-4j with Apache License 2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals(HTTPS)) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #23
Source File: Light4jHttpClientProvider.java From light-4j with Apache License 2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioIoThread ioThread, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals(HTTPS)) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(ioThread, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(ioThread, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #24
Source File: IOSubsystem20TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(String.valueOf(mainServices.getBootError())); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default"); ModelNode op = Util.createOperation("read-resource", addr); op.get("include-runtime").set(true); mainServices.executeOperation(op); }
Example #25
Source File: EndpointConfigFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * creates option map for remoting connections * @param resolver * @param model * @param defaults * @return * @throws OperationFailedException * @deprecated configuring xnio worker options is no longer supported and should be replaced for referencing IO subsystem */ @Deprecated public static OptionMap create(final ExpressionResolver resolver, final ModelNode model, final OptionMap defaults) throws OperationFailedException { final OptionMap map = OptionMap.builder() .addAll(defaults) .set(Options.WORKER_READ_THREADS, RemotingSubsystemRootResource.WORKER_READ_THREADS.resolveModelAttribute(resolver, model).asInt()) .set(Options.WORKER_TASK_CORE_THREADS, RemotingSubsystemRootResource.WORKER_TASK_CORE_THREADS.resolveModelAttribute(resolver, model).asInt()) .set(Options.WORKER_TASK_KEEPALIVE, RemotingSubsystemRootResource.WORKER_TASK_KEEPALIVE.resolveModelAttribute(resolver, model).asInt()) .set(Options.WORKER_TASK_LIMIT, RemotingSubsystemRootResource.WORKER_TASK_LIMIT.resolveModelAttribute(resolver, model).asInt()) .set(Options.WORKER_TASK_MAX_THREADS, RemotingSubsystemRootResource.WORKER_TASK_MAX_THREADS.resolveModelAttribute(resolver, model).asInt()) .set(Options.WORKER_WRITE_THREADS, RemotingSubsystemRootResource.WORKER_WRITE_THREADS.resolveModelAttribute(resolver, model).asInt()) .set(Options.WORKER_READ_THREADS, RemotingSubsystemRootResource.WORKER_READ_THREADS.resolveModelAttribute(resolver, model).asInt()) .getMap(); return map; }
Example #26
Source File: IOSubsystem10TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(mainServices.getBootError().toString()); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); }
Example #27
Source File: IOSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSequence() throws Exception { OptionMap.Builder builder = OptionMap.builder(); ModelNode model = new ModelNode(); ModelNode operation = new ModelNode(); operation.get(ENABLED_PROTOCOLS.getName()).set("TLSv1, TLSv1.1, TLSv1.2"); ENABLED_PROTOCOLS.validateAndSet(operation, model); ENABLED_PROTOCOLS.resolveOption(ExpressionResolver.SIMPLE, model, builder); Sequence<String> protocols = builder.getMap().get(Options.SSL_ENABLED_PROTOCOLS); Assert.assertEquals(3, protocols.size()); Assert.assertEquals("TLSv1", protocols.get(0)); Assert.assertEquals("TLSv1.1", protocols.get(1)); Assert.assertEquals("TLSv1.2", protocols.get(2)); }
Example #28
Source File: IOSubsystem20TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSequence() throws Exception { OptionMap.Builder builder = OptionMap.builder(); ModelNode model = new ModelNode(); ModelNode operation = new ModelNode(); operation.get(ENABLED_PROTOCOLS.getName()).set("TLSv1, TLSv1.1, TLSv1.2"); ENABLED_PROTOCOLS.validateAndSet(operation, model); ENABLED_PROTOCOLS.resolveOption(ExpressionResolver.SIMPLE, model, builder); Sequence<String> protocols = builder.getMap().get(Options.SSL_ENABLED_PROTOCOLS); Assert.assertEquals(3, protocols.size()); Assert.assertEquals("TLSv1", protocols.get(0)); Assert.assertEquals("TLSv1.1", protocols.get(1)); Assert.assertEquals("TLSv1.2", protocols.get(2)); }
Example #29
Source File: IOSubsystem11TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSequence() throws Exception { OptionMap.Builder builder = OptionMap.builder(); ModelNode model = new ModelNode(); ModelNode operation = new ModelNode(); operation.get(ENABLED_PROTOCOLS.getName()).set("TLSv1, TLSv1.1, TLSv1.2"); ENABLED_PROTOCOLS.validateAndSet(operation, model); ENABLED_PROTOCOLS.resolveOption(ExpressionResolver.SIMPLE, model, builder); Sequence<String> protocols = builder.getMap().get(Options.SSL_ENABLED_PROTOCOLS); Assert.assertEquals(3, protocols.size()); Assert.assertEquals("TLSv1", protocols.get(0)); Assert.assertEquals("TLSv1.1", protocols.get(1)); Assert.assertEquals("TLSv1.2", protocols.get(2)); }
Example #30
Source File: JBoss.java From ysoserial with MIT License | 5 votes |
private static void doRun ( URI u, final Object payloadObject, String username, String password ) { ConnectionProvider instance = null; ConnectionProviderContextImpl context = null; ConnectionHandler ch = null; Channel c = null; VersionedConnection vc = null; try { Logger logger = LogManager.getLogManager().getLogger(""); logger.addHandler(new ConsoleLogHandler()); logger.setLevel(Level.INFO); OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap(); context = new ConnectionProviderContextImpl(options, "endpoint"); instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options); String host = u.getHost(); int port = u.getPort() > 0 ? u.getPort() : 9990; SocketAddress destination = new InetSocketAddress(host, port); ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options); ch = chf.createInstance(new ConnectionHandlerContextImpl(context)); c = getChannel(context, ch, options); System.err.println("Connected"); vc = makeVersionedConnection(c); MBeanServerConnection mbc = vc.getMBeanServerConnection(null); doExploit(payloadObject, mbc); System.err.println("DONE"); } catch ( Throwable e ) { e.printStackTrace(System.err); } finally { cleanup(instance, context, ch, c, vc); } }