2015-03-02 66 views
0

我写的代码在JDK 1.6如何获得SSLParameters JDK 1.5

SSLContext context = SSLContext.getInstance("TLS"); 
     context.init(null, tmf.getTrustManagers(), null); 
     SSLParameters params = context.getSupportedSSLParameters(); 
     List<String> enabledCiphers = new ArrayList<String>(); 
     for (String cipher : params.getCipherSuites()) { 
      boolean exclude = false; 
      if (exludedCipherSuites != null) { 
       for (int i = 0; i < exludedCipherSuites.length && !exclude; i++) { 
        exclude = cipher.indexOf(exludedCipherSuites[i]) >= 0; 
       } 
      } 
      if (!exclude) { 
       enabledCiphers.add(cipher); 
      } 
     } 
     String[] cArray = new String[enabledCiphers.size()]; 



     SSLSocketFactory sf = context.getSocketFactory(); 
     sf = new DOSSLSocketFactory(sf, cArray); 
     urlConnection.setSSLSocketFactory(sf); 

的问题是,在JDK 1.5我没有SSLParameters。我该如何解决JDK 1.5中的问题?

+0

您必须在SSLSocketFactory而不是SSLContext上执行此操作。 – EJP 2015-03-02 10:17:36

回答