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


Java SSLServerSocket.getSupportedCipherSuites方法代碼示例

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


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

示例1: testSetEnabledCipherSuitesAffectsGetter

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
@Test
public void testSetEnabledCipherSuitesAffectsGetter() throws Exception {
    SSLServerSocket socket =
            (SSLServerSocket) SSLServerSocketFactory.getDefault().createServerSocket();
    String[] cipherSuites = new String[] {socket.getSupportedCipherSuites()[0]};
    socket.setEnabledCipherSuites(cipherSuites);
    assertEquals(Arrays.asList(cipherSuites), Arrays.asList(socket.getEnabledCipherSuites()));
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:9,代碼來源:SSLServerSocketTest.java

示例2: test_getSupportedCipherSuites

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * @throws Exception
 * @tests javax.net.ssl.SSLServerSocket#getSupportedCipherSuites()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getSupportedCipherSuites",
    args = {}
)
public void test_getSupportedCipherSuites() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    String[] res = sss.getSupportedCipherSuites();
    assertNotNull("NULL result", res);
    assertTrue("no supported cipher suites available.", res.length > 0);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:17,代碼來源:SSLServerSocketTest.java

示例3: test_getSupportedProtocols

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * @throws IOException
 * @tests javax.net.ssl.SSLServerSocket#getSupportedProtocols()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getSupportedProtocols",
    args = {}
)
public void test_getSupportedProtocols() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    String[] res = sss.getSupportedCipherSuites();
    assertNotNull("NULL result", res);
    assertTrue("no supported protocols available.", res.length > 0);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:17,代碼來源:SSLServerSocketTest.java

示例4: testGetSupportedCipherSuites

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * getSupportedCipherSuites() method testing.
 */
public void testGetSupportedCipherSuites() throws Exception {
    SSLServerSocket ssocket = createSSLServerSocket();
    String[] supported = ssocket.getSupportedCipherSuites();
    assertNotNull(supported);
    supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
    supported = ssocket.getEnabledCipherSuites();
    for (int i=0; i<supported.length; i++) {
        if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
            fail("Modification of the returned result "
                    + "causes the modification of the internal state");
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:SSLServerSocketImplTest.java

示例5: create

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * Creates the SSL ServerSocket.
 */
public ServerSocketBar create(InetAddress host, int port)
  throws IOException, GeneralSecurityException
{
  SSLServerSocketFactory ssFactory = null;
  
  if (_keyStore != null) {
    SSLContext sslContext = SSLContext.getInstance(_sslContext);

    KeyManagerFactory kmf
      = KeyManagerFactory.getInstance(keyManagerFactory());
  
    kmf.init(_keyStore, keyStorePassword().toCharArray());
    
    sslContext.init(kmf.getKeyManagers(), null, null);

    /*
    if (_cipherSuites != null)
      sslContext.createSSLEngine().setEnabledCipherSuites(_cipherSuites);

    if (_protocols != null)
      sslContext.createSSLEngine().setEnabledProtocols(_protocols);
    */
    
    SSLEngine engine = sslContext.createSSLEngine();
    
    engine.setEnabledProtocols(enabledProtocols(engine.getSupportedProtocols()));

    ssFactory = sslContext.getServerSocketFactory();
  }
  else {
    ssFactory = createAnonymousServerFactory(host, port);
  }
  
  ServerSocket serverSocket;

  int listen = 100;

  if (host == null)
    serverSocket = ssFactory.createServerSocket(port, listen);
  else
    serverSocket = ssFactory.createServerSocket(port, listen, host);

  SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket;
  
  if (_cipherSuites != null) {
    sslServerSocket.setEnabledCipherSuites(_cipherSuites);
  }
  
  if (_cipherSuitesForbidden != null) {
    String []cipherSuites = sslServerSocket.getEnabledCipherSuites();
    
    if (cipherSuites == null)
      cipherSuites = sslServerSocket.getSupportedCipherSuites();
    
    ArrayList<String> cipherList = new ArrayList<String>();
    
    for (String cipher : cipherSuites) {
      if (! isCipherForbidden(cipher, _cipherSuitesForbidden)) {
        cipherList.add(cipher);
      }
    }
    
    cipherSuites = new String[cipherList.size()];
    cipherList.toArray(cipherSuites);
    
    sslServerSocket.setEnabledCipherSuites(cipherSuites);
  }

  sslServerSocket.setEnabledProtocols(enabledProtocols(sslServerSocket.getSupportedProtocols()));
  
  if ("required".equals(_verifyClient))
    sslServerSocket.setNeedClientAuth(true);
  else if ("optional".equals(_verifyClient))
    sslServerSocket.setWantClientAuth(true);

  return new ServerSocketWrapper(serverSocket);
}
 
開發者ID:baratine,項目名稱:baratine,代碼行數:81,代碼來源:SSLFactoryJsse.java

示例6: testGetEnabledCipherSuites

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * getEnabledCipherSuites() method testing.
 */
public void testGetEnabledCipherSuites() throws Exception {
    SSLServerSocket ssocket = createSSLServerSocket();
    String[] enabled = ssocket.getEnabledCipherSuites();
    assertNotNull(enabled);
    String[] supported = ssocket.getSupportedCipherSuites();
    for (int i=0; i<enabled.length; i++) {
        //System.out.println("Checking of "+enabled[i]);
        found: {
            for (int j=0; j<supported.length; j++) {
                if (enabled[i].equals(supported[j])) {
                    break found;
                }
            }
            fail("Enabled suite does not belong to the set "
                    + "of supported cipher suites: " + enabled[i]);
        }
    }
    ssocket.setEnabledCipherSuites(supported);
    for (int i=0; i<supported.length; i++) {
        enabled = new String[supported.length - i];
        System.arraycopy(supported, 0,
                enabled, 0, supported.length-i);
        ssocket.setEnabledCipherSuites(enabled);
        String[] result = ssocket.getEnabledCipherSuites();
        if (result.length != enabled.length) {
            fail("Returned result does not correspond to expected.");
        }
        for (int k=0; k<result.length; k++) {
            found: {
                for (int n=0; n<enabled.length; n++) {
                    if (result[k].equals(enabled[n])) {
                        break found;
                    }
                }
                if (result.length != enabled.length) {
                    fail("Returned result does not correspond "
                            + "to expected.");
                }
            }
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:46,代碼來源:SSLServerSocketImplTest.java

示例7: testSetEnabledCipherSuites

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * setEnabledCipherSuites(String[] suites) method testing.
 */
public void testSetEnabledCipherSuites() throws Exception {
    SSLServerSocket ssocket = createSSLServerSocket();
    String[] enabled = ssocket.getEnabledCipherSuites();
    assertNotNull(enabled);
    String[] supported = ssocket.getSupportedCipherSuites();
    for (int i=0; i<enabled.length; i++) {
        //System.out.println("Checking of "+enabled[i]);
        found: {
            for (int j=0; j<supported.length; j++) {
                if (enabled[i].equals(supported[j])) {
                    break found;
                }
            }
            fail("Enabled suite does not belong to the set "
                    + "of supported cipher suites: " + enabled[i]);
        }
    }
    ssocket.setEnabledCipherSuites(supported);
    ssocket.setEnabledCipherSuites(enabled);
    ssocket.setEnabledCipherSuites(supported);
    String[] more_than_supported = new String[supported.length+1];
    for (int i=0; i<supported.length+1; i++) {
        more_than_supported[i]
            = "NOT_SUPPORTED_CIPHER_SUITE";
        System.arraycopy(supported, 0,
                more_than_supported, 0, i);
        System.arraycopy(supported, i,
                more_than_supported, i+1, supported.length-i);
        try {
            ssocket.setEnabledCipherSuites(more_than_supported);
            fail("Expected IllegalArgumentException was not thrown");
        } catch (IllegalArgumentException e) { }
    }
    enabled = ssocket.getEnabledCipherSuites();
    enabled[0] = "NOT_SUPPORTED_CIPHER_SUITE";
    enabled = ssocket.getEnabledCipherSuites();
    for (int i=0; i<enabled.length; i++) {
        if ("NOT_SUPPORTED_CIPHER_SUITE".equals(enabled[i])) {
            fail("Modification of the returned result "
                    + "causes the modification of the internal state");
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:47,代碼來源:SSLServerSocketImplTest.java

示例8: initServerSocket

import javax.net.ssl.SSLServerSocket; //導入方法依賴的package包/類
/**
 * Set the requested properties for this server socket.
 *
 * @param ssocket The server socket to be configured
 */
private void initServerSocket(ServerSocket ssocket) {

    SSLServerSocket socket = (SSLServerSocket) ssocket;

    // Enable all available cipher suites when the socket is connected
    String cipherSuites[] = socket.getSupportedCipherSuites();
    socket.setEnabledCipherSuites(cipherSuites);

    // Set client authentication if necessary
    socket.setNeedClientAuth(clientAuth);

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:18,代碼來源:SSLServerSocketFactory.java


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