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


Java SSLServerSocket.close方法代码示例

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


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

示例1: assertSSLServerSocketFactoryConfigSameAsSSLContext

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
 * Asserts that {@link SSLServerSocketFactory}'s configuration matches {@code SSLContext}'s
 * configuration, and that {@link SSLServerSocket} instances obtained from the factory match
 * this
 * configuration as well.
 */
private static void assertSSLServerSocketFactoryConfigSameAsSSLContext(
        SSLServerSocketFactory sslServerSocketFactory, SSLContext sslContext)
        throws IOException {
    assertCipherSuitesEqual(sslContext.getDefaultSSLParameters().getCipherSuites(),
            sslServerSocketFactory.getDefaultCipherSuites());
    assertCipherSuitesEqual(sslContext.getSupportedSSLParameters().getCipherSuites(),
            sslServerSocketFactory.getSupportedCipherSuites());
    SSLServerSocket sslServerSocket =
        (SSLServerSocket) sslServerSocketFactory.createServerSocket();
    try {
        assertFalse(sslServerSocket.getUseClientMode());
        assertTrue(sslServerSocket.getEnableSessionCreation());
        assertSSLServerSocketConfigSameAsSSLContext(sslServerSocket, sslContext);
    } finally {
        sslServerSocket.close();
    }
}
 
开发者ID:google,项目名称:conscrypt,代码行数:24,代码来源:SSLConfigurationAsserts.java

示例2: open

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Override
public ServerChannel open(InetAddress address, int port, int timeout)
        throws IOException
{
    SSLServerSocket sock =
        (SSLServerSocket) _factory.createServerSocket(port,
                                                      _backlog, address);
    try {
        sock.setReuseAddress(_isReuseAddress);
        sock.setWantClientAuth(_isWantClientAuth);
        return new SSLServerChannel(sock, timeout);
    } catch (Throwable t) {
        if (!sock.isClosed()) {
            try {
                sock.close();
            } catch (Throwable tt) {
                t.addSuppressed(tt);
            }
        }
        throw t;
    }
}
 
开发者ID:perlundq,项目名称:yajsync,代码行数:23,代码来源:SSLServerChannelFactory.java

示例3: doServerSide

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
void doServerSide() throws Exception {
    SSLContext context = generateSSLContext(false);
    SSLServerSocketFactory sslssf = context.getServerSocketFactory();
    SSLServerSocket sslServerSocket =
        (SSLServerSocket)sslssf.createServerSocket(serverPort);
    serverPort = sslServerSocket.getLocalPort();

    /*
     * Signal Client, we're ready for his connect.
     */
    serverReady = true;

    SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept();
    try {
        sslSocket.setSoTimeout(5000);
        sslSocket.setSoLinger(true, 5);

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

        sslIS.read();
        sslOS.write('A');
        sslOS.flush();

        throw new Exception("EC curve secp224k1 should be disabled");
    } catch (SSLHandshakeException she) {
        // expected exception: no cipher suites in common
        System.out.println("Expected exception: " + she);
    } finally {
        sslSocket.close();
        sslServerSocket.close();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ECCurvesconstraints.java

示例4: doServerSide

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
void doServerSide() throws Exception {
    SSLServerSocketFactory sslssf =
        (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket sslServerSocket =
        (SSLServerSocket) sslssf.createServerSocket(serverPort);
    serverPort = sslServerSocket.getLocalPort();

    /*
     * Signal Client, we're ready for his connect.
     */
    serverReady = true;
    SSLSocket sslSocket = null;
    try {
        sslSocket = (SSLSocket) sslServerSocket.accept();
        sslSocket.setSoTimeout(TIMEOUT);
        readOneRequest(sslSocket.getInputStream());
        sslSocket.getOutputStream().write(replyString.getBytes());

        readOneRequest(sslSocket.getInputStream());
        sslSocket.getOutputStream().write(replyString.getBytes());
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (sslSocket != null) { sslSocket.close(); }
            sslServerSocket.close();
        } catch (IOException unused)  {  /* gulp!burp! */   }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:30,代码来源:CookieHttpsClientTest.java

示例5: 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

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