当前位置: 首页>>代码示例>>Java>>正文


Java SSLSocket.setWantClientAuth方法代码示例

本文整理汇总了Java中javax.net.ssl.SSLSocket.setWantClientAuth方法的典型用法代码示例。如果您正苦于以下问题:Java SSLSocket.setWantClientAuth方法的具体用法?Java SSLSocket.setWantClientAuth怎么用?Java SSLSocket.setWantClientAuth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.ssl.SSLSocket的用法示例。


在下文中一共展示了SSLSocket.setWantClientAuth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildServerSslSocketFactory

import javax.net.ssl.SSLSocket; //导入方法依赖的package包/类
public SSLSocketFactory buildServerSslSocketFactory(final ClientAuth clientAuth) {
  SslClient serverSslClient = new SslClient.Builder()
      .addTrustedCertificate(serverRootCa.certificate)
      .addTrustedCertificate(clientRootCa.certificate)
      .certificateChain(serverCert, serverIntermediateCa)
      .build();

  return new DelegatingSSLSocketFactory(serverSslClient.socketFactory) {
    @Override protected SSLSocket configureSocket(SSLSocket sslSocket) throws IOException {
      if (clientAuth == ClientAuth.NEEDS) {
        sslSocket.setNeedClientAuth(true);
      } else if (clientAuth == ClientAuth.WANTS) {
        sslSocket.setWantClientAuth(true);
      }

      return super.configureSocket(sslSocket);
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ClientAuthTest.java

示例2: runServerApplication

import javax.net.ssl.SSLSocket; //导入方法依赖的package包/类
@Override
protected void runServerApplication(SSLSocket socket) throws Exception {
    String ciphers[] = {
            "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
            "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
            "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" };
    socket.setEnabledCipherSuites(ciphers);
    socket.setWantClientAuth(true);

    InputStream sslIS = socket.getInputStream();
    OutputStream sslOS = socket.getOutputStream();

    sslIS.read();
    sslOS.write(85);
    sslOS.flush();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:AnonCipherWithWantClientAuth.java

示例3: runServerApplication

import javax.net.ssl.SSLSocket; //导入方法依赖的package包/类
@Override
protected void runServerApplication(SSLSocket socket) throws Exception {
    String ciphers[] = {
            "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
            "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
            "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
            "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};

    socket.setEnabledCipherSuites(ciphers);
    socket.setWantClientAuth(true);

    InputStream sslIS = socket.getInputStream();
    OutputStream sslOS = socket.getOutputStream();

    sslIS.read();
    sslOS.write(85);
    sslOS.flush();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:UseStrongDHSizes.java

示例4: sslNegotiation

import javax.net.ssl.SSLSocket; //导入方法依赖的package包/类
/**
 * SSL/TLS negotiation. Acquires an SSL socket of a control
 * connection and carries out handshake processing.
 * @throws java.io.IOException If server negotiation fails
 */
protected void sslNegotiation() throws IOException {
    plainSocket = _socket_;
    initSslContext();

    SSLSocketFactory ssf = context.getSocketFactory();
    String ip = _socket_.getInetAddress().getHostAddress();
    int port = _socket_.getPort();
    SSLSocket socket =
        (SSLSocket) ssf.createSocket(_socket_, ip, port, false);
    socket.setEnableSessionCreation(isCreation);
    socket.setUseClientMode(isClientMode);
    // server mode
    if (!isClientMode) {
        socket.setNeedClientAuth(isNeedClientAuth);
        socket.setWantClientAuth(isWantClientAuth);
    }

    if (protocols != null) {
        socket.setEnabledProtocols(protocols);
    }
    if (suites != null) {
        socket.setEnabledCipherSuites(suites);
    }
    socket.startHandshake();

    _socket_ = socket;
    _controlInput_ = new BufferedReader(new InputStreamReader(
            socket .getInputStream(), getControlEncoding()));
    _controlOutput_ = new BufferedWriter(new OutputStreamWriter(
            socket.getOutputStream(), getControlEncoding()));
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:37,代码来源:FTPSClient.java

示例5: _openDataConnection_

import javax.net.ssl.SSLSocket; //导入方法依赖的package包/类
/**
 * Returns a socket of the data connection.
 * Wrapped as an {@link javax.net.ssl.SSLSocket}, which carries out handshake processing.
 * @param command The textual representation of the FTP command to send.
 * @param arg The arguments to the FTP command.
 * If this parameter is set to null, then the command is sent with
 * no arguments.
 * @return corresponding to the established data connection.
 * Null is returned if an FTP protocol error is reported at any point
 * during the establishment and initialization of the connection.
 * @throws java.io.IOException If there is any problem with the connection.
 * @see org.apache.commons.net.ftp.FTPClient#_openDataConnection_(int, String)
 * @since 3.2
 */
@Override
protected Socket _openDataConnection_(String command, String arg)
        throws IOException {
    Socket socket = super._openDataConnection_(command, arg);
    _prepareDataSocket_(socket);
    if (socket instanceof SSLSocket) {
        SSLSocket sslSocket = (SSLSocket)socket;

        sslSocket.setUseClientMode(isClientMode);
        sslSocket.setEnableSessionCreation(isCreation);

        // server mode
        if (!isClientMode) {
            sslSocket.setNeedClientAuth(isNeedClientAuth);
            sslSocket.setWantClientAuth(isWantClientAuth);
        }
        if (suites != null) {
            sslSocket.setEnabledCipherSuites(suites);
        }
        if (protocols != null) {
            sslSocket.setEnabledProtocols(protocols);
        }
        sslSocket.startHandshake();
    }

    return socket;
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:42,代码来源:FTPSClient.java


注:本文中的javax.net.ssl.SSLSocket.setWantClientAuth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。