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


Java SSLServerSocket.getEnabledCipherSuites方法代码示例

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


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

示例1: printInfo

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static void printInfo(SSLServerSocket socket) {
    System.out.println();
    System.out.println("--- SSL ServerSocket Info ---");
    System.out.print("SupportedProtocols    : ");
    printStringArray(socket.getSupportedProtocols());
    System.out.print("SupportedCipherSuites : ");
    printStringArray(socket.getSupportedCipherSuites());
    System.out.print("EnabledProtocols      : ");
    printStringArray(socket.getEnabledProtocols());
    System.out.print("EnabledCipherSuites   : ");
    String[] supportedCipherSuites = socket.getEnabledCipherSuites();
    Arrays.sort(supportedCipherSuites);
    printStringArray(supportedCipherSuites);
    System.out.println("NeedClientAuth        : "
            + socket.getNeedClientAuth());
    System.out.println("WantClientAuth        : "
            + socket.getWantClientAuth());
    System.out.println("-----------------------");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:CipherTestUtils.java

示例2: testSetEnabledCipherSuitesStoresCopy

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Test
public void testSetEnabledCipherSuitesStoresCopy() throws Exception {
    SSLServerSocket socket =
            (SSLServerSocket) SSLServerSocketFactory.getDefault().createServerSocket();
    String[] array = new String[] {socket.getEnabledCipherSuites()[0]};
    String originalFirstElement = array[0];
    socket.setEnabledCipherSuites(array);
    array[0] = "Modified after having been set";
    assertEquals(originalFirstElement, socket.getEnabledCipherSuites()[0]);
}
 
开发者ID:google,项目名称:conscrypt,代码行数:11,代码来源:SSLServerSocketTest.java

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

示例4: narrowServerSocketCipherSuites

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static void narrowServerSocketCipherSuites( ServerSocket serverSocket ) {
    
    
    if( !( serverSocket instanceof SSLServerSocket ) )
        return;
    
    logger.finest("Entering ProxiedClientListener:narrowCipherSuites ... ");
    
    SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket;
    String[] suites = sslServerSocket.getEnabledCipherSuites();
    logger.finest("Defaulty Support cipher suites are:");
    for (int i = 0; i < suites.length; i++) {
        logger.finest( suites[i] );
    }
    
    String[] filteredSuites = filterSuites(suites, excludeCipher );
    logger.finest("nerrowed from " + suites.length + " to " + filteredSuites.length );
    for( int i=0; i<filteredSuites.length; i++ )
        logger.finest( filteredSuites[i] );
    
    //after this line, the socket's enabledCipherSuites should be only 3
    sslServerSocket.setEnabledCipherSuites( filteredSuites );
    
    //if( logger.getLevel().equals( Level.finest ) )
    {
        String[] newSuites = sslServerSocket.getEnabledCipherSuites();
        logger.finest( "Supported cipher suites are: " );
        for(int i=0; i<newSuites.length; i++  ) {
            logger.finest( newSuites[i] );
        }
    }
}
 
开发者ID:atulsm,项目名称:Test_Projects,代码行数:33,代码来源:TestSSLServer.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


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