當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。