Code example for Map

Methods: keySet, put, size

0
    public static final Map<String, String> STANDARD_TO_OPENSSL_CIPHER_SUITES
            = new LinkedHashMap<String, String>();
 
    private static void add(String standard, String openssl) {
        OPENSSL_TO_STANDARD_CIPHER_SUITES.put(openssl, standard);
        STANDARD_TO_OPENSSL_CIPHER_SUITES.put(standard, openssl);
    } 
 
    /** 
     * TLS_EMPTY_RENEGOTIATION_INFO_SCSV is RFC 5746's renegotiation 
     * indication signaling cipher suite value. It is not a real 
     * cipher suite. It is just an indication in the default and 
     * supported cipher suite lists indicates that the implementation 
     * supports secure renegotiation. 
     * 
     * In the RI, its presence means that the SCSV is sent in the 
     * cipher suite list to indicate secure renegotiation support and 
     * its absense means to send an empty TLS renegotiation info 
     * extension instead. 
     * 
     * However, OpenSSL doesn't provide an API to give this level of 
     * control, instead always sending the SCSV and always including 
     * the empty renegotiation info if TLS is used (as opposed to 
     * SSL). So we simply allow TLS_EMPTY_RENEGOTIATION_INFO_SCSV to 
     * be passed for compatibility as to provide the hint that we 
     * support secure renegotiation. 
     */ 
    public static final String TLS_EMPTY_RENEGOTIATION_INFO_SCSV
            = "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"; 
 
    static { 
        // Note these are added in priority order 
        add("SSL_RSA_WITH_RC4_128_MD5",              "RC4-MD5"); 
        add("SSL_RSA_WITH_RC4_128_SHA",              "RC4-SHA"); 
        add("TLS_RSA_WITH_AES_128_CBC_SHA",          "AES128-SHA"); 
        add("TLS_RSA_WITH_AES_256_CBC_SHA",          "AES256-SHA"); 
        add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA",       "ECDH-ECDSA-RC4-SHA"); 
        add("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",   "ECDH-ECDSA-AES128-SHA"); 
        add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",   "ECDH-ECDSA-AES256-SHA"); 
        add("TLS_ECDH_RSA_WITH_RC4_128_SHA",         "ECDH-RSA-RC4-SHA"); 
        add("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",     "ECDH-RSA-AES128-SHA"); 
        add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",     "ECDH-RSA-AES256-SHA"); 
        add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",      "ECDHE-ECDSA-RC4-SHA"); 
        add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",  "ECDHE-ECDSA-AES128-SHA"); 
        add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",  "ECDHE-ECDSA-AES256-SHA"); 
        add("TLS_ECDHE_RSA_WITH_RC4_128_SHA",        "ECDHE-RSA-RC4-SHA"); 
        add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",    "ECDHE-RSA-AES128-SHA"); 
        add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",    "ECDHE-RSA-AES256-SHA"); 
        add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA",      "DHE-RSA-AES128-SHA"); 
        add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA",      "DHE-RSA-AES256-SHA"); 
        add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA",      "DHE-DSS-AES128-SHA"); 
        add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA",      "DHE-DSS-AES256-SHA"); 
        add("SSL_RSA_WITH_3DES_EDE_CBC_SHA",         "DES-CBC3-SHA"); 
        add("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",  "ECDH-ECDSA-DES-CBC3-SHA"); 
        add("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA",    "ECDH-RSA-DES-CBC3-SHA"); 
        add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "ECDHE-ECDSA-DES-CBC3-SHA"); 
        add("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",   "ECDHE-RSA-DES-CBC3-SHA"); 
        add("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",     "EDH-RSA-DES-CBC3-SHA"); 
        add("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",     "EDH-DSS-DES-CBC3-SHA"); 
        add("SSL_RSA_WITH_DES_CBC_SHA",              "DES-CBC-SHA"); 
        add("SSL_DHE_RSA_WITH_DES_CBC_SHA",          "EDH-RSA-DES-CBC-SHA"); 
        add("SSL_DHE_DSS_WITH_DES_CBC_SHA",          "EDH-DSS-DES-CBC-SHA"); 
        add("SSL_RSA_EXPORT_WITH_RC4_40_MD5",        "EXP-RC4-MD5"); 
        add("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",     "EXP-DES-CBC-SHA"); 
        add("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "EXP-EDH-RSA-DES-CBC-SHA"); 
        add("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", "EXP-EDH-DSS-DES-CBC-SHA"); 
        add("SSL_RSA_WITH_NULL_MD5",                 "NULL-MD5"); 
        add("SSL_RSA_WITH_NULL_SHA",                 "NULL-SHA"); 
        add("TLS_ECDH_ECDSA_WITH_NULL_SHA",          "ECDH-ECDSA-NULL-SHA"); 
        add("TLS_ECDH_RSA_WITH_NULL_SHA",            "ECDH-RSA-NULL-SHA"); 
        add("TLS_ECDHE_ECDSA_WITH_NULL_SHA",         "ECDHE-ECDSA-NULL-SHA"); 
        add("TLS_ECDHE_RSA_WITH_NULL_SHA",           "ECDHE-RSA-NULL-SHA"); 
        add("SSL_DH_anon_WITH_RC4_128_MD5",          "ADH-RC4-MD5"); 
        add("TLS_DH_anon_WITH_AES_128_CBC_SHA",      "ADH-AES128-SHA"); 
        add("TLS_DH_anon_WITH_AES_256_CBC_SHA",      "ADH-AES256-SHA"); 
        add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",     "ADH-DES-CBC3-SHA"); 
        add("SSL_DH_anon_WITH_DES_CBC_SHA",          "ADH-DES-CBC-SHA"); 
        add("TLS_ECDH_anon_WITH_RC4_128_SHA",        "AECDH-RC4-SHA"); 
        add("TLS_ECDH_anon_WITH_AES_128_CBC_SHA",    "AECDH-AES128-SHA"); 
        add("TLS_ECDH_anon_WITH_AES_256_CBC_SHA",    "AECDH-AES256-SHA"); 
        add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA",   "AECDH-DES-CBC3-SHA"); 
        add("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",    "EXP-ADH-RC4-MD5"); 
        add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", "EXP-ADH-DES-CBC-SHA"); 
        add("TLS_ECDH_anon_WITH_NULL_SHA",           "AECDH-NULL-SHA"); 
 
        // No Kerberos in Android 
        // add("TLS_KRB5_WITH_RC4_128_SHA",           "KRB5-RC4-SHA"); 
        // add("TLS_KRB5_WITH_RC4_128_MD5",           "KRB5-RC4-MD5"); 
        // add("TLS_KRB5_WITH_3DES_EDE_CBC_SHA",      "KRB5-DES-CBC3-SHA"); 
        // add("TLS_KRB5_WITH_3DES_EDE_CBC_MD5",      "KRB5-DES-CBC3-MD5"); 
        // add("TLS_KRB5_WITH_DES_CBC_SHA",           "KRB5-DES-CBC-SHA"); 
        // add("TLS_KRB5_WITH_DES_CBC_MD5",           "KRB5-DES-CBC-MD5"); 
        // add("TLS_KRB5_EXPORT_WITH_RC4_40_SHA",     "EXP-KRB5-RC4-SHA"); 
        // add("TLS_KRB5_EXPORT_WITH_RC4_40_MD5",     "EXP-KRB5-RC4-MD5"); 
        // add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", "EXP-KRB5-DES-CBC-SHA"); 
        // add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", "EXP-KRB5-DES-CBC-MD5"); 
 
        // not implemented by either RI or OpenSSL 
        // add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", null); 
        // add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", null); 
 
        // EXPORT1024 suites were never standardized but were widely implemented. 
        // OpenSSL 0.9.8c and later have disabled TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 
        // add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA", "EXP1024-DES-CBC-SHA"); 
        // add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA",  "EXP1024-RC4-SHA"); 
 
        // No RC2 
        // add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5",  "EXP-RC2-CBC-MD5"); 
        // add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", "EXP-KRB5-RC2-CBC-SHA"); 
        // add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", "EXP-KRB5-RC2-CBC-MD5"); 
 
        // PSK is Private Shared Key - didn't exist in Froyo's openssl - no JSSE equivalent 
        // add(null, "PSK-3DES-EDE-CBC-SHA"); 
        // add(null, "PSK-AES128-CBC-SHA"); 
        // add(null, "PSK-AES256-CBC-SHA"); 
        // add(null, "PSK-RC4-SHA"); 
 
        // Signaling Cipher Suite Value for secure renegotiation handled as special case. 
        // add("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", null); 
    } 
 
    private static final String[] SUPPORTED_CIPHER_SUITES;
    static { 
        int size = STANDARD_TO_OPENSSL_CIPHER_SUITES.size();
        SUPPORTED_CIPHER_SUITES = new String[size + 1];
        STANDARD_TO_OPENSSL_CIPHER_SUITES.keySet().toArray(SUPPORTED_CIPHER_SUITES);
        SUPPORTED_CIPHER_SUITES[size] = TLS_EMPTY_RENEGOTIATION_INFO_SCSV;
    } 
 
    // SSL mode from ssl.h 
    public static final long SSL_MODE_HANDSHAKE_CUTTHROUGH = 0x00000040L;