當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。