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


Java SSLServerSocket.setSoTimeout方法代码示例

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


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

示例1: configureServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
 * Set the server socket configuration to our required
 * QOS values.
 *
 * A small experiment shows that setting either (want, need) parameter to either true or false sets the
 * other parameter to false.
 *
 * @param serverSocket
 *               The newly created SSLServerSocket.
 *
 * @throws IOException if server socket can't be configured
 */
private void configureServerSocket(SSLServerSocket serverSocket) throws IOException {
    // set the authentication value and cipher suite info.
    serverSocket.setEnabledCipherSuites(cipherSuites);
    if (clientAuthRequired) {
        serverSocket.setNeedClientAuth(true);
    } else if (clientAuthSupported) {
        serverSocket.setWantClientAuth(true);
    } else {
        serverSocket.setNeedClientAuth(false); //could set want with the same effect
    }
    serverSocket.setSoTimeout(SOCKET_TIMEOUT_MS);

    if (log.isDebugEnabled()) {
        log.debug("Created SSL server socket on port " + serverSocket.getLocalPort());
        log.debug("    client authentication " + (clientAuthSupported ? "SUPPORTED" : "UNSUPPORTED"));
        log.debug("    client authentication " + (clientAuthRequired ? "REQUIRED" : "OPTIONAL"));
        log.debug("    cipher suites:");

        for (int i = 0; i < cipherSuites.length; i++) {
            log.debug("    " + cipherSuites[i]);
        }
    }
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:36,代码来源:SocketFactory.java

示例2: JSSEServer

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public JSSEServer(SSLContext context, String constraint,
        boolean needClientAuth) throws Exception {
    TLSRestrictions.setConstraint("Server", constraint);

    SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
    server = (SSLServerSocket) serverFactory.createServerSocket(0);
    server.setSoTimeout(TLSRestrictions.TIMEOUT);
    server.setNeedClientAuth(needClientAuth); // for dual authentication
    System.out.println("Server: port=" + getPort());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:JSSEServer.java

示例3: JSSEServer

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
JSSEServer(CipherTest cipherTest) throws Exception {
    super(cipherTest);
    SSLContext serverContext = SSLContext.getInstance("TLS");
    serverContext.init(
            new KeyManager[] { CipherTest.keyManager },
            new TrustManager[] { CipherTest.trustManager },
            CipherTest.secureRandom);

    SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory();
    serverSocket = (SSLServerSocket)factory.createServerSocket(0);
    serverSocket.setSoTimeout(CipherTest.TIMEOUT);
    CipherTest.serverPort = serverSocket.getLocalPort();
    serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
    serverSocket.setWantClientAuth(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:JSSEServer.java

示例4: JSSEServer

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public JSSEServer(SSLContext context,
        boolean needClientAuth) throws Exception {
    SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
    server = (SSLServerSocket) serverFactory.createServerSocket(0);
    server.setSoTimeout(TLSRestrictions.TIMEOUT);
    server.setNeedClientAuth(needClientAuth); // for dual authentication
    System.out.println("Server: port=" + getPort());
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:9,代码来源:JSSEServer.java

示例5: createServer

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static TServerSocket createServer(SSLServerSocketFactory factory, int port, int timeout, boolean clientAuth,
                                  InetAddress ifAddress, TSSLTransportParameters params) throws TTransportException {
  try {
    SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(port, 100, ifAddress);
    serverSocket.setSoTimeout(timeout);
    serverSocket.setNeedClientAuth(clientAuth);
    if (params != null && params.cipherSuites != null) {
      serverSocket.setEnabledCipherSuites(params.cipherSuites);
    }
    return new TServerSocket(new TServerSocket.ServerSocketTransportArgs().
      serverSocket(serverSocket).clientTimeout(timeout));
  } catch (Exception e) {
    throw new TTransportException("Could not bind to port " + port, e);
  }
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:16,代码来源:TSSLTransportFactory.java

示例6: HTTPServer

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
 * Creates an HTTP Server based on the parameters
 * This class extends Thread
 * @param root
 * @param portNumber
 * @param ssl
 * @param sslFile
 * @param sslPass
 * @throws IOException 
 */
public HTTPServer(String root,int portNumber,boolean ssl,String sslFile,String sslPass) throws IOException{
    this.root = root;
    this.ssl = ssl;
    run = true;
    // create the server's socket
    if(ssl){
        /*
             SSL stuff
        */
        try{
            String password = sslPass;
            String keystore = sslFile;

            /* Create keystore */
            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            keyStore.load(new FileInputStream(keystore), password.toCharArray());

            /* Get factory for the given keystore */
            TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tmf.init(keyStore);
            SSLContext ctx = SSLContext.getInstance("SSL");
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(keyStore, password.toCharArray());
            // ...
            ctx.init(kmf.getKeyManagers(), null, null);
            SSLServerSocketFactory factory = ctx.getServerSocketFactory();

            serverSocket = (SSLServerSocket) factory.createServerSocket(portNumber);
        }catch(Exception e){e.printStackTrace();}
    }else{
        
        // create the server socket and a timeout
        serverSocket = new ServerSocket(portNumber);
        serverSocket.setSoTimeout(15000);
    }
}
 
开发者ID:StavrosSkourtis,项目名称:Mars-Http-Server,代码行数:47,代码来源:HTTPServer.java

示例7: createServer

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static TServerSocket createServer(SSLServerSocketFactory factory, int port, int timeout, boolean clientAuth,
                                  InetAddress ifAddress, TSSLTransportParameters params) throws TTransportException {
  try {
    SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(port, 100, ifAddress);
    serverSocket.setSoTimeout(timeout);
    serverSocket.setNeedClientAuth(clientAuth);
    if (params != null && params.cipherSuites != null) {
      serverSocket.setEnabledCipherSuites(params.cipherSuites);
    }
    return new TServerSocket(serverSocket, timeout);
  } catch (Exception e) {
    throw new TTransportException("Could not bind to port " + port, e);
  }
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:15,代码来源:TSSLTransportFactory.java


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