jdk/src/share/classes/sun/security/ssl/CipherSuiteList.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7990 57019dc81b66
child 9275 1df1f7dfab7f
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7990
diff changeset
     2
 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package sun.security.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.net.ssl.SSLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A list of CipherSuites. Also maintains the lists of supported and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * default ciphersuites and supports I/O from handshake streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Instances of this class are immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
final class CipherSuiteList {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    // lists of supported and default enabled ciphersuites
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    // created on demand
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static CipherSuiteList supportedSuites, defaultSuites;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private final Collection<CipherSuite> cipherSuites;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private String[] suiteNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    // flag indicating whether this list contains any ECC ciphersuites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    // null if not yet checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private volatile Boolean containsEC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
6856
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
    54
    // for use by buildAvailableCache() and
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
    55
    // Handshaker.getKickstartMessage() only
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
    56
    CipherSuiteList(Collection<CipherSuite> cipherSuites) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        this.cipherSuites = cipherSuites;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Create a CipherSuiteList with a single element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    CipherSuiteList(CipherSuite suite) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        cipherSuites = new ArrayList<CipherSuite>(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        cipherSuites.add(suite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Construct a CipherSuiteList from a array of names. We don't bother
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * to eliminate duplicates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @exception IllegalArgumentException if the array or any of its elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * is null or if the ciphersuite name is unrecognized or unsupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * using currently installed providers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    CipherSuiteList(String[] names) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        if (names == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            throw new IllegalArgumentException("CipherSuites may not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        cipherSuites = new ArrayList<CipherSuite>(names.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        // refresh available cache once if a CipherSuite is not available
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        // (maybe new JCE providers have been installed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        boolean refreshed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        for (int i = 0; i < names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            String suiteName = names[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            CipherSuite suite = CipherSuite.valueOf(suiteName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            if (suite.isAvailable() == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                if (refreshed == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                    // clear the cache so that the isAvailable() call below
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                    // does a full check
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                    clearAvailableCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                    refreshed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                // still missing?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                if (suite.isAvailable() == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                    throw new IllegalArgumentException("Cannot support "
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                        + suiteName + " with currently installed providers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            cipherSuites.add(suite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Read a CipherSuiteList from a HandshakeInStream in V3 ClientHello
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * format. Does not check if the listed ciphersuites are known or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    CipherSuiteList(HandshakeInStream in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        byte[] bytes = in.getBytes16();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if ((bytes.length & 1) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            throw new SSLException("Invalid ClientHello message");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        cipherSuites = new ArrayList<CipherSuite>(bytes.length >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        for (int i = 0; i < bytes.length; i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            cipherSuites.add(CipherSuite.valueOf(bytes[i], bytes[i+1]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Return whether this list contains the given CipherSuite.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    boolean contains(CipherSuite suite) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return cipherSuites.contains(suite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    // Return whether this list contains any ECC ciphersuites
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    boolean containsEC() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (containsEC == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            for (CipherSuite c : cipherSuites) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                switch (c.keyExchange) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                case K_ECDH_ECDSA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                case K_ECDH_RSA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                case K_ECDHE_ECDSA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                case K_ECDHE_RSA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                case K_ECDH_ANON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    containsEC = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            containsEC = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return containsEC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Return an Iterator for the CipherSuites in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    Iterator<CipherSuite> iterator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return cipherSuites.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Return a reference to the internal Collection of CipherSuites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * The Collection MUST NOT be modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    Collection<CipherSuite> collection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return cipherSuites;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Return the number of CipherSuites in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        return cipherSuites.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Return an array with the names of the CipherSuites in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    synchronized String[] toStringArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (suiteNames == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            suiteNames = new String[cipherSuites.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            for (CipherSuite c : cipherSuites) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                suiteNames[i++] = c.name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        return suiteNames.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        return cipherSuites.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Write this list to an HandshakeOutStream in V3 ClientHello format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    void send(HandshakeOutStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        byte[] suiteBytes = new byte[cipherSuites.size() * 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        for (CipherSuite c : cipherSuites) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            suiteBytes[i] = (byte)(c.id >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            suiteBytes[i+1] = (byte)c.id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            i += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        s.putBytes16(suiteBytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Clear cache of available ciphersuites. If we support all ciphers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * internally, there is no need to clear the cache and calling this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    static synchronized void clearAvailableCache() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        if (CipherSuite.DYNAMIC_AVAILABILITY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            supportedSuites = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            defaultSuites = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            CipherSuite.BulkCipher.clearAvailableCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            JsseJce.clearEcAvailable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * Return the list of all available CipherSuites with a priority of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * minPriority or above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Should be called with the Class lock held.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    private static CipherSuiteList buildAvailableCache(int minPriority) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        // SortedSet automatically arranges ciphersuites in default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        // preference order
7990
57019dc81b66 7012003: diamond conversion for ssl
smarks
parents: 6856
diff changeset
   224
        Set<CipherSuite> cipherSuites = new TreeSet<>();
6856
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
   225
        Collection<CipherSuite> allowedCipherSuites =
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
   226
                                    CipherSuite.allowedCipherSuites();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        for (CipherSuite c : allowedCipherSuites) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            if ((c.allowed == false) || (c.priority < minPriority)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            }
6856
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
   231
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            if (c.isAvailable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                cipherSuites.add(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
6856
533f4ad71f88 6914943: Implement final TLS renegotiation fix
xuelei
parents: 5506
diff changeset
   236
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return new CipherSuiteList(cipherSuites);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Return supported CipherSuites in preference order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    static synchronized CipherSuiteList getSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (supportedSuites == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            supportedSuites =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                buildAvailableCache(CipherSuite.SUPPORTED_SUITES_PRIORITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return supportedSuites;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * Return default enabled CipherSuites in preference order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    static synchronized CipherSuiteList getDefault() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (defaultSuites == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            defaultSuites =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                buildAvailableCache(CipherSuite.DEFAULT_SUITES_PRIORITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return defaultSuites;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
}