gpt4 book ai didi

org.xnio.ssl.XnioSsl类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 02:57:05 25 4
gpt4 key购买 nike

本文整理了Java中org.xnio.ssl.XnioSsl类的一些代码示例,展示了XnioSsl类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XnioSsl类的具体详情如下:
包路径:org.xnio.ssl.XnioSsl
类名称:XnioSsl

XnioSsl介绍

[英]An SSL provider for XNIO.
[中]

代码示例

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 *
 * @return the SSL connection
 */
@Deprecated
public IoFuture<ConnectedSslStreamChannel> connectSsl(XnioWorker worker, InetSocketAddress destination, ChannelListener<? super ConnectedSslStreamChannel> openListener, OptionMap optionMap) {
  return connectSsl(worker, ANY_INET_ADDRESS, destination, openListener, null, optionMap);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param ioThread the IO Thread to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param bindListener the bind listener
 * @param optionMap the option map
 * @return the SSL connection
 */
public IoFuture<SslConnection> openSslConnection(final XnioIoThread ioThread, final InetSocketAddress destination, final ChannelListener<? super SslConnection> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  return openSslConnection(ioThread, ANY_INET_ADDRESS, destination, openListener, bindListener, optionMap);
}

代码示例来源:origin: wildfly/wildfly

@Override
protected void startListening(XnioWorker worker, InetSocketAddress socketAddress, ChannelListener<AcceptingChannel<StreamConnection>> acceptListener) throws IOException {
  if(proxyProtocol) {
    sslServer = worker.createStreamConnectionServer(socketAddress, (ChannelListener) acceptListener, getSSLOptions(sslContextSupplier.get()));
  } else {
    XnioSsl ssl = getSsl();
    sslServer = ssl.createSslConnectionServer(worker, socketAddress, (ChannelListener) acceptListener, getSSLOptions(sslContextSupplier.get()));
  }
  sslServer.resumeAccepts();
  final InetSocketAddress boundAddress = sslServer.getLocalAddress(InetSocketAddress.class);
  UndertowLogger.ROOT_LOGGER.listenerStarted("HTTPS", getName(), NetworkUtils.formatIPAddressForURI(boundAddress.getAddress()), boundAddress.getPort());
}

代码示例来源:origin: org.jboss.remoting3/jboss-remoting

public AcceptingChannel<? extends ConnectedStreamChannel> createServer(final SocketAddress bindAddress, final OptionMap optionMap, final ServerAuthenticationProvider authenticationProvider, XnioSsl xnioSsl) throws IOException {
    final AccessControlContext accessControlContext = AccessController.getContext();
    final boolean sslCapable = sslEnabled;
    final AcceptListener acceptListener = new AcceptListener(optionMap, authenticationProvider, accessControlContext);
    final AcceptingChannel<? extends ConnectedStreamChannel> result;
    if (sslCapable && optionMap.get(Options.SSL_ENABLED, true)) {
      if (xnioSsl == null) {
        try {
          xnioSsl = xnio.getSslProvider(optionMap);
        } catch (GeneralSecurityException e) {
          throw sslConfigFailure(e);
        }
      }
      result = xnioSsl.createSslTcpServer(xnioWorker, (InetSocketAddress) bindAddress, acceptListener, optionMap);
    } else {
      result = xnioWorker.createStreamServer(bindAddress, acceptListener, optionMap);
    }
    addCloseHandler(new CloseHandler<ConnectionProvider>() {
      public void handleClose(final ConnectionProvider closed, final IOException exception) {
        IoUtils.safeClose(result);
      }
    });
    result.resumeAccepts();
    return result;
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-undertow

@Override
protected void startListening(XnioWorker worker, InetSocketAddress socketAddress, ChannelListener<AcceptingChannel<StreamConnection>> acceptListener) throws IOException {
  if(proxyProtocol) {
    sslServer = worker.createStreamConnectionServer(socketAddress, (ChannelListener) acceptListener, getSSLOptions(sslContextSupplier.get()));
  } else {
    XnioSsl ssl = getSsl();
    sslServer = ssl.createSslConnectionServer(worker, socketAddress, (ChannelListener) acceptListener, getSSLOptions(sslContextSupplier.get()));
  }
  sslServer.resumeAccepts();
  final InetSocketAddress boundAddress = sslServer.getLocalAddress(InetSocketAddress.class);
  UndertowLogger.ROOT_LOGGER.listenerStarted("HTTPS", getName(), NetworkUtils.formatIPAddressForURI(boundAddress.getAddress()), boundAddress.getPort());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 *
 * @return the SSL connection
 */
public IoFuture<SslConnection> openSslConnection(XnioWorker worker, InetSocketAddress destination, ChannelListener<? super SslConnection> openListener, OptionMap optionMap) {
  return openSslConnection(worker, ANY_INET_ADDRESS, destination, openListener, null, optionMap);
}

代码示例来源:origin: org.wildfly/wildfly-undertow

@Override
protected void startListening(XnioWorker worker, InetSocketAddress socketAddress, ChannelListener<AcceptingChannel<StreamConnection>> acceptListener) throws IOException {
  if(proxyProtocol) {
    sslServer = worker.createStreamConnectionServer(socketAddress, (ChannelListener) acceptListener, getSSLOptions(sslContextSupplier.get()));
  } else {
    XnioSsl ssl = getSsl();
    sslServer = ssl.createSslConnectionServer(worker, socketAddress, (ChannelListener) acceptListener, getSSLOptions(sslContextSupplier.get()));
  }
  sslServer.resumeAccepts();
  final InetSocketAddress boundAddress = sslServer.getLocalAddress(InetSocketAddress.class);
  UndertowLogger.ROOT_LOGGER.listenerStarted("HTTPS", getName(), NetworkUtils.formatIPAddressForURI(boundAddress.getAddress()), boundAddress.getPort());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param bindAddress the local bind address
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 * @return the SSL connection
 */
@Deprecated
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final OptionMap optionMap) {
  return connectSsl(worker, bindAddress, destination, openListener, null, optionMap);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param ioThread the IO thread to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 *
 * @return the SSL connection
 */
public IoFuture<SslConnection> openSslConnection(XnioIoThread ioThread, InetSocketAddress destination, ChannelListener<? super SslConnection> openListener, OptionMap optionMap) {
  return openSslConnection(ioThread, ANY_INET_ADDRESS, destination, openListener, null, optionMap);
}

代码示例来源:origin: actframework/actframework

@Override
protected void setUpClient(NetworkHandler client, int port, boolean secure) throws IOException {
  HttpHandler handler = new ActHttpHandler(client);
  ByteBufferPool buffers = new DefaultByteBufferPool(true, 16 * 1024, -1, 4);
  HttpOpenListener openListener = new HttpOpenListener(buffers, serverOptions);
  openListener.setRootHandler(handler);
  ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(openListener);
  if (!secure) {
    AcceptingChannel<? extends StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, socketOptions);
    server.resumeAccepts();
    channels.add(server);
  } else {
    XnioSsl xnioSsl;
    try {
      SSLContext sslContext = createSSLContext(loadKeyStore("server.keystore"), loadKeyStore("server.truststore"));
      xnioSsl = new UndertowXnioSsl(xnio, OptionMap.create(Options.USE_DIRECT_BUFFERS, true), sslContext);
      AcceptingChannel<SslConnection> sslServer = xnioSsl.createSslConnectionServer(worker, new InetSocketAddress(port), (ChannelListener)acceptListener, socketOptions);
      sslServer.resumeAccepts();
      channels.add(sslServer);
    } catch (Exception e) {
      throw E.unexpected(e);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param bindListener the bind listener
 * @param optionMap the option map
 * @return the SSL connection
 */
@Deprecated
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  return connectSsl(worker, ANY_INET_ADDRESS, destination, openListener, bindListener, optionMap);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param bindListener the bind listener
 * @param optionMap the option map
 * @return the SSL connection
 */
public IoFuture<SslConnection> openSslConnection(final XnioWorker worker, final InetSocketAddress destination, final ChannelListener<? super SslConnection> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  return openSslConnection(worker, ANY_INET_ADDRESS, destination, openListener, bindListener, optionMap);
}

代码示例来源:origin: org.actframework/act

@Override
protected void setUpClient(NetworkHandler client, int port, boolean secure) throws IOException {
  HttpHandler handler = new ActHttpHandler(client);
  ByteBufferPool buffers = new DefaultByteBufferPool(true, 16 * 1024, -1, 4);
  HttpOpenListener openListener = new HttpOpenListener(buffers, serverOptions);
  openListener.setRootHandler(handler);
  ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(openListener);
  if (!secure) {
    AcceptingChannel<? extends StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, socketOptions);
    server.resumeAccepts();
    channels.add(server);
  } else {
    XnioSsl xnioSsl;
    try {
      SSLContext sslContext = createSSLContext(loadKeyStore("server.keystore"), loadKeyStore("server.truststore"));
      xnioSsl = new UndertowXnioSsl(xnio, OptionMap.create(Options.USE_DIRECT_BUFFERS, true), sslContext);
      AcceptingChannel<SslConnection> sslServer = xnioSsl.createSslConnectionServer(worker, new InetSocketAddress(port), (ChannelListener)acceptListener, socketOptions);
      sslServer.resumeAccepts();
      channels.add(sslServer);
    } catch (Exception e) {
      throw E.unexpected(e);
    }
  }
}

代码示例来源:origin: org.jboss.remoting3/jboss-remoting

protected IoFuture<ConnectedSslStreamChannel> createSslConnection(final SocketAddress bindAddress, final InetSocketAddress destination, final OptionMap connectOptions, final XnioSsl xnioSsl, final ChannelListener<ConnectedStreamChannel> openListener) {
  return bindAddress == null ? xnioSsl.connectSsl(xnioWorker, destination, openListener, connectOptions) : xnioSsl.connectSsl(xnioWorker, (InetSocketAddress) bindAddress, destination, openListener, connectOptions);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param bindAddress the local bind address
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 * @return the SSL connection
 */
public IoFuture<SslConnection> openSslConnection(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super SslConnection> openListener, final OptionMap optionMap) {
  return openSslConnection(worker, bindAddress, destination, openListener, null, optionMap);
}

代码示例来源:origin: wildfly/wildfly-core

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);
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param bindAddress the local bind address
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 * @return the SSL connection
 */
@Deprecated
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final OptionMap optionMap) {
  return connectSsl(worker, bindAddress, destination, openListener, null, optionMap);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an SSL connection to a remote host.
 *
 * @param ioThread the IO Thread to use
 * @param bindAddress the local bind address
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 * @return the SSL connection
 */
public IoFuture<SslConnection> openSslConnection(final XnioIoThread ioThread, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super SslConnection> openListener, final OptionMap optionMap) {
  return openSslConnection(ioThread, bindAddress, destination, openListener, null, optionMap);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Create an SSL connection to a remote host.
 *
 * @param worker the worker to use
 * @param destination the destination connection address
 * @param openListener the initial open-connection listener
 * @param optionMap the option map
 *
 * @return the SSL connection
 */
@Deprecated
public IoFuture<ConnectedSslStreamChannel> connectSsl(XnioWorker worker, InetSocketAddress destination, ChannelListener<? super ConnectedSslStreamChannel> openListener, OptionMap optionMap) {
  return connectSsl(worker, ANY_INET_ADDRESS, destination, openListener, null, optionMap);
}

代码示例来源:origin: wildfly/wildfly

@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap options) {
  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, uri, ssl, bufferPool, tlsOptions), tlsOptions).addNotifier(createNotifier(listener), null);
  } else {
    ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, tlsOptions), tlsOptions).addNotifier(createNotifier(listener), null);
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com