如何获得SSLParameters JDK 1.5

时间:2015-03-02 09:56:06

标签: java java-ee jdk1.6 jdk1.5

我在JDK 1.6中编写了代码

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中的问题?

1 个答案:

答案 0 :(得分:0)

假设您需要受支持的密码套件,则可以使用SSLSocketFactory.getSupportedCipherSuites()。请参阅that