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


Java SSLServerSocket.setUseClientMode方法代碼示例

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


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

示例1: finishServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * Configure the SSLServerSocket based on this SocketCreator's settings.
 */
private void finishServerSocket(SSLServerSocket serverSocket) throws IOException {
  serverSocket.setUseClientMode(false);
  if (this.sslConfig.isRequireAuth()) {
    // serverSocket.setWantClientAuth( true );
    serverSocket.setNeedClientAuth(true);
  }
  serverSocket.setEnableSessionCreation(true);

  // restrict protocols
  String[] protocols = this.sslConfig.getProtocolsAsStringArray();
  if (!"any".equalsIgnoreCase(protocols[0])) {
    serverSocket.setEnabledProtocols(protocols);
  }
  // restrict ciphers
  String[] ciphers = this.sslConfig.getCiphersAsStringArray();
  if (!"any".equalsIgnoreCase(ciphers[0])) {
    serverSocket.setEnabledCipherSuites(ciphers);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:23,代碼來源:SocketCreator.java

示例2: test_UseClientMode

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * @throws IOException
 * @tests javax.net.ssl.SSLServerSocket#getUseClientMode()
 * @tests javax.net.ssl.SSLServerSocket#setUseClientMode(boolean mode)
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "getUseClientMode",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "setUseClientMode",
        args = {boolean.class}
    )
})
public void test_UseClientMode() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    sss.setUseClientMode(false);
    assertFalse(sss.getUseClientMode());
    sss.setUseClientMode(true);
    assertTrue(sss.getUseClientMode());
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:27,代碼來源:SSLServerSocketTest.java

示例3: testSetGetUseClientMode

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * setUseClientMode(boolean mode) method testing.
 * getUseClientMode() method testing.
 */
public void testSetGetUseClientMode() throws Exception {
    SSLServerSocket ssocket = createSSLServerSocket();

    ssocket.setUseClientMode(false);
    assertFalse("Result does not correspond to expected",
            ssocket.getUseClientMode());
    ssocket.setUseClientMode(true);
    assertTrue("Result does not correspond to expected",
            ssocket.getUseClientMode());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:15,代碼來源:SSLServerSocketImplTest.java

示例4: doTestInteraction

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public void doTestInteraction(SSLContext context, SSLContext ctx_other)
        throws Throwable {
    SSLContext ctx1, ctx2;

    ctx1 = context;
    ctx2 = ctx_other;

    int k=1;

    SSLServerSocket ssocket = (SSLServerSocket) ctx1
        .getServerSocketFactory().createServerSocket(0);
    ssocket.setUseClientMode(false);
    ssocket.setEnabledCipherSuites(
            ((k & 1) > 0)
                ? new String[] {"TLS_"+cipher_suites[0]}
                : new String[] {"SSL_"+cipher_suites[0]});

    SSLSocket csocket = (SSLSocket) ctx2
        .getSocketFactory().createSocket("localhost",
                ssocket.getLocalPort());
    csocket.setEnabledProtocols(new String[] {"TLSv1"});
    csocket.setUseClientMode(true);
    csocket.setEnabledCipherSuites(
            (((k & 2) >> 1) > 0)
                ? new String[] {"TLS_"+cipher_suites[0]}
                : new String[] {"SSL_"+cipher_suites[0]});
    doTest(ssocket, csocket);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:29,代碼來源:SSLSocketFunctionalTest.java

示例5: _doTestInteraction

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
public void _doTestInteraction(SSLContext context, SSLContext ctx_other)
        throws Throwable {
    for (int i=0; i<cipher_suites.length; i++) {
        if (doLog) {
            System.out.println("======== Checking the work on cipher: "
                + cipher_suites[i]);
        }
        SSLContext ctx1, ctx2;
        // k: 00, 01, 10, 11;
        // where 1 means implementation under the test,
        // 0 - another implementation to interract with
        for (int k=0; k<4; k++) {
            if (doLog) {
                System.out.println("======== "+(k & 1)+" "+((k & 2) >> 1));
            }
            ctx1 = ((k & 1) > 0) ? context : ctx_other;
            ctx2 = (((k & 2) >> 1) > 0) ? context : ctx_other;

            SSLServerSocket ssocket = (SSLServerSocket) ctx1
                .getServerSocketFactory().createServerSocket(0);
            ssocket.setUseClientMode(false);
            ssocket.setEnabledCipherSuites(
                    ((k & 1) > 0)
                        ? new String[] {"TLS_"+cipher_suites[i]}
                        : new String[] {"SSL_"+cipher_suites[i]});

            SSLSocket csocket = (SSLSocket) ctx2
                .getSocketFactory().createSocket("localhost",
                        ssocket.getLocalPort());
            csocket.setEnabledProtocols(new String[] {"TLSv1"});
            csocket.setUseClientMode(true);
            csocket.setEnabledCipherSuites(
                    (((k & 2) >> 1) > 0)
                        ? new String[] {"TLS_"+cipher_suites[i]}
                        : new String[] {"SSL_"+cipher_suites[i]});
            doTest(ssocket, csocket);
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:40,代碼來源:SSLSocketFunctionalTest.java

示例6: doTestSelfInteraction

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * Tests the interaction with other implementation.
 */
public void doTestSelfInteraction(SSLContext context)
        throws Throwable {
    String[] protocols = {"SSLv3", "TLSv1"};
    for (int i=0; i<cipher_suites.length; i++) {
        for (int j=0; j<2; j++) {
            if (doLog) {
                System.out.println("======= " + cipher_suites[i]);
            }
            SSLServerSocket ssocket = (SSLServerSocket) context
                .getServerSocketFactory().createServerSocket(0);
            ssocket.setUseClientMode(false);
            ssocket.setEnabledProtocols(new String[] {protocols[j]});
            ssocket.setEnabledCipherSuites(
                    new String[] {"TLS_"+cipher_suites[i]});

            SSLSocket csocket = (SSLSocket) context
                .getSocketFactory().createSocket("localhost",
                        ssocket.getLocalPort());
            csocket.setEnabledProtocols(new String[] {protocols[j]});
            csocket.setUseClientMode(true);
            csocket.setEnabledCipherSuites(
                    new String[] {"TLS_"+cipher_suites[i]});

            doTest(ssocket, csocket);
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:31,代碼來源:SSLSocketFunctionalTest.java

示例7: initServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
private void initServerSocket(SSLServerSocket socket) throws IOException {
    socket.setUseClientMode(true);
}
 
開發者ID:chfoo,項目名稱:areca-backup-release-mirror,代碼行數:4,代碼來源:SecuredSocketFactory.java


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