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


Java SSLServerSocket.getEnabledProtocols方法代码示例

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


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

示例1: getSSLServerTransport

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private TServerTransport getSSLServerTransport() {
  try {
    TServerTransport transport;
    TSSLTransportFactory.TSSLTransportParameters params =
            new TSSLTransportFactory.TSSLTransportParameters();

    params.setKeyStore(keystore, keystorePassword, getkeyManagerAlgorithm(), keystoreType);
    transport = TSSLTransportFactory.getServerSocket(
            port, 120000, InetAddress.getByName(bindAddress), params);

    ServerSocket serverSock = ((TServerSocket) transport).getServerSocket();
    if (serverSock instanceof SSLServerSocket) {
      SSLServerSocket sslServerSock = (SSLServerSocket) serverSock;
      List<String> enabledProtocols = new ArrayList<String>();
      for (String protocol : sslServerSock.getEnabledProtocols()) {
        if (!excludeProtocols.contains(protocol)) {
          enabledProtocols.add(protocol);
        }
      }
      sslServerSock.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
    }
    return transport;
  } catch (Throwable throwable) {
    throw new FlumeException("Cannot start Thrift source.", throwable);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:ThriftSource.java

示例2: newServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
 * Create a new ServerSocket that will not accept SSLv3 connections,
 * but will accept TLSv1.x connections.
 */
protected ServerSocket newServerSocket(String host, int port,int backlog)
        throws IOException {
  SSLServerSocket socket = (SSLServerSocket)
          super.newServerSocket(host, port, backlog);
  ArrayList<String> nonSSLProtocols = new ArrayList<String>();
  for (String p : socket.getEnabledProtocols()) {
    if (!p.contains("SSLv3")) {
      nonSSLProtocols.add(p);
    }
  }
  socket.setEnabledProtocols(nonSSLProtocols.toArray(
          new String[nonSSLProtocols.size()]));
  return socket;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:SslSocketConnectorSecure.java

示例3: newServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Override
public ServerSocket newServerSocket(String host, int port, int backlog) throws IOException {
  SSLServerSocket socket = (SSLServerSocket)super.newServerSocket(host, port, backlog);
  String[] protocols = socket.getEnabledProtocols();
  List<String> newProtocols = new ArrayList<String>(protocols.length);
  for (String protocol: protocols) {
    if (!excludedProtocols.contains(protocol)) {
      newProtocols.add(protocol);
    }
  }
  socket.setEnabledProtocols(newProtocols.toArray(new String[newProtocols.size()]));
  return socket;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:HTTPSource.java

示例4: testSetEnabledProtocolsStoresCopy

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

示例5: testGetEnabledProtocols

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
 * getEnabledProtocols() method testing.
 */
public void testGetEnabledProtocols() throws Exception {
    SSLServerSocket ssocket = createSSLServerSocket();
    String[] enabled = ssocket.getEnabledProtocols();
    assertNotNull(enabled);
    String[] supported = ssocket.getSupportedProtocols();
    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 protocol does not belong to the set "
                    + "of supported protocols: " + enabled[i]);
        }
    }
    ssocket.setEnabledProtocols(supported);
    for (int i=0; i<supported.length; i++) {
        enabled = new String[supported.length - i];
        System.arraycopy(supported, i,
                enabled, 0, supported.length-i);
        //System.out.println("");
        //for (int k=0; k<supported.length - i; k++) {
        //    System.out.println("---- "+enabled[k]);
        //}
        ssocket.setEnabledProtocols(enabled);
        String[] result = ssocket.getEnabledProtocols();
        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,代码行数:50,代码来源:SSLServerSocketImplTest.java

示例6: testSetEnabledProtocols

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
 * setEnabledProtocols(String[] protocols) method testing.
 */
public void testSetEnabledProtocols() throws Exception {
    SSLServerSocket ssocket = createSSLServerSocket();
    String[] enabled = ssocket.getEnabledProtocols();
    assertNotNull(enabled);
    String[] supported = ssocket.getSupportedProtocols();
    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.setEnabledProtocols(supported);
    ssocket.setEnabledProtocols(enabled);
    ssocket.setEnabledProtocols(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_PROTOCOL";
        System.arraycopy(supported, 0,
                more_than_supported, 0, i);
        System.arraycopy(supported, i,
                more_than_supported, i+1, supported.length-i);
        try {
            ssocket.setEnabledProtocols(more_than_supported);
            fail("Expected IllegalArgumentException was not thrown");
        } catch (IllegalArgumentException e) { }
    }
    enabled = ssocket.getEnabledProtocols();
    enabled[0] = "NOT_SUPPORTED_PROTOCOL";
    enabled = ssocket.getEnabledProtocols();
    for (int i=0; i<enabled.length; i++) {
        if ("NOT_SUPPORTED_PROTOCOL".equals(enabled[i])) {
            fail("Modification of the returned result "
                    + "causes the modification of the internal state");
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:47,代码来源:SSLServerSocketImplTest.java

示例7: narrowServerSocketProtocols

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static void narrowServerSocketProtocols( ServerSocket serverSocket ) {
    
    logger.finest( "\n\nEntering SocketUitl:narrowServerSocketProtocols .. " );
    if( !( serverSocket instanceof SSLServerSocket ) )
        return;
    
    SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket;
    
    logger.fine( "Entering ProxiedClientListener:narrowProtocols ... " );
    
    String[] before = sslServerSocket.getEnabledProtocols();
    
    String[] filtered = filterSuites( before, excludeProtocol );
    
    logger.finest( "The protocols are filterd from " + before.length + " to " + filtered.length );
    sslServerSocket.setEnabledProtocols( filtered );
    
    logger.finest("Exiting SocketUtil:narrwoServerSocketProtocols ... \n\n" );
}
 
开发者ID:atulsm,项目名称:Test_Projects,代码行数:20,代码来源:TestSSLServer.java


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