當前位置: 首頁>>代碼示例>>Java>>正文


Java SSLServerSocket.bind方法代碼示例

本文整理匯總了Java中javax.net.ssl.SSLServerSocket.bind方法的典型用法代碼示例。如果您正苦於以下問題:Java SSLServerSocket.bind方法的具體用法?Java SSLServerSocket.bind怎麽用?Java SSLServerSocket.bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.net.ssl.SSLServerSocket的用法示例。


在下文中一共展示了SSLServerSocket.bind方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:13,代碼來源:SSLFactory.java

示例2: getServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.bind(new InetSocketAddress(address, port), 100);
    return serverSocket;
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:12,代碼來源:SSLFactory.java

示例3: getServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suites = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suites);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:13,代碼來源:SSLFactory.java

示例4: getServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
開發者ID:daidong,項目名稱:GraphTrek,代碼行數:12,代碼來源:SSLFactory.java

示例5: createServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
private ServerSocket createServerSocket(int nport, int backlog, InetAddress bindAddr,
    int socketBufferSize, boolean sslConnection) throws IOException {
  printConfig();
  if (sslConnection) {
    if (this.sslContext == null) {
      throw new GemFireConfigException(
          "SSL not configured correctly, Please look at previous error");
    }
    ServerSocketFactory ssf = this.sslContext.getServerSocketFactory();
    SSLServerSocket serverSocket = (SSLServerSocket) ssf.createServerSocket();
    serverSocket.setReuseAddress(true);
    // If necessary, set the receive buffer size before binding the socket so
    // that large buffers will be allocated on accepted sockets (see
    // java.net.ServerSocket.setReceiverBufferSize javadocs)
    if (socketBufferSize != -1) {
      serverSocket.setReceiveBufferSize(socketBufferSize);
    }
    serverSocket.bind(new InetSocketAddress(bindAddr, nport), backlog);
    finishServerSocket(serverSocket);
    return serverSocket;
  } else {
    // log.info("Opening server socket on " + nport, new Exception("SocketCreation"));
    ServerSocket result = new ServerSocket();
    result.setReuseAddress(true);
    // If necessary, set the receive buffer size before binding the socket so
    // that large buffers will be allocated on accepted sockets (see
    // java.net.ServerSocket.setReceiverBufferSize javadocs)
    if (socketBufferSize != -1) {
      result.setReceiveBufferSize(socketBufferSize);
    }
    try {
      result.bind(new InetSocketAddress(bindAddr, nport), backlog);
    } catch (BindException e) {
      BindException throwMe =
          new BindException(LocalizedStrings.SocketCreator_FAILED_TO_CREATE_SERVER_SOCKET_ON_0_1
              .toLocalizedString(new Object[] {bindAddr, Integer.valueOf(nport)}));
      throwMe.initCause(e);
      throw throwMe;
    }
    return result;
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:43,代碼來源:SocketCreator.java

示例6: run

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public void run() {
    try {
        store = provideKeys ? getKeyStore(keys) : null;
        KeyManager[] keyManagers = store != null ? getKeyManagers(store) : null;
        TrustManager[] trustManagers = new TrustManager[] { trustManager };

        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(keyManagers, trustManagers, null);

        SSLServerSocket serverSocket = (SSLServerSocket)sslContext
                .getServerSocketFactory().createServerSocket();

        if (clientAuth == CLIENT_AUTH_WANTED) {
            serverSocket.setWantClientAuth(true);
        } else if (clientAuth == CLIENT_AUTH_NEEDED) {
            serverSocket.setNeedClientAuth(true);
        } else {
            serverSocket.setWantClientAuth(false);
        }

        serverSocket.bind(new InetSocketAddress(port));

        SSLSocket clientSocket = (SSLSocket)serverSocket.accept();

        InputStream istream = clientSocket.getInputStream();
        byte[] buffer = new byte[1024];
        istream.read(buffer);

        OutputStream ostream = clientSocket.getOutputStream();
        ostream.write(testData.getBytes());
        ostream.flush();

        while (notFinished) {
            Thread.currentThread().sleep(500);
        }

        clientSocket.close();
        serverSocket.close();

    } catch (Exception ex) {
        exception = ex;
    }
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:44,代碼來源:SSLSessionTest.java

示例7: run

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public void run() {
    try {
        KeyManager[] keyManagers = provideKeys ? getKeyManagers(keys) : null;
        TrustManager[] trustManagers = new TrustManager[] { trustManager };

        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(keyManagers, trustManagers, null);

        SSLServerSocket serverSocket = (SSLServerSocket)sslContext.getServerSocketFactory().createServerSocket();

        if (clientAuth == CLIENT_AUTH_WANTED) {
            serverSocket.setWantClientAuth(true);
        } else if (clientAuth == CLIENT_AUTH_NEEDED) {
            serverSocket.setNeedClientAuth(true);
        } else {
            serverSocket.setWantClientAuth(false);
        }

        serverSocket.bind(new InetSocketAddress(port));

        SSLSocket clientSocket = (SSLSocket)serverSocket.accept();

        InputStream istream = clientSocket.getInputStream();

        for (int i = 0; i < 256; i++) {
            int j = istream.read();
            if (i != j) {
                throw new RuntimeException("Error reading socket, expected " + i + ", got " + j);
            }
        }

        istream.close();

        OutputStream ostream = clientSocket.getOutputStream();

        for (int i = 0; i < 256; i++) {
            ostream.write(i);
        }

        ostream.flush();
        ostream.close();

        clientSocket.close();
        serverSocket.close();

    } catch (Exception ex) {
        exception = ex;
    }
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:50,代碼來源:HandshakeCompletedEventTest.java


注:本文中的javax.net.ssl.SSLServerSocket.bind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。