https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html
347669
private static void initJava8SunDefaultEnabledCipherSuites(Map<String, SslCipher> ciphers,
                                                 Map<String, SslCipher> ciphersByNickname) {
        SslCipher cipher;

        // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
                "ECDHE-ECDSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
                "ECDHE-RSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_256_CBC_SHA256
        cipher = new SslCipher("TLS_RSA_WITH_AES_256_CBC_SHA256",
                "AES256-SHA256", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
                "ECDH-ECDSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
                "ECDH-RSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
                "DHE-RSA-AES256-SHA256", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
                "DHE-DSS-AES256-SHA256", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES256,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
                "ECDHE-ECDSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
                "ECDHE-RSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_RSA_WITH_AES_256_CBC_SHA",
                "AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
                "ECDH-ECDSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
                "ECDH-RSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
                "DHE-RSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
                "DHE-DSS-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
                "ECDHE-ECDSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
                "ECDHE-RSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_RSA_WITH_AES_128_CBC_SHA256",
                "AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
                "ECDH-ECDSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
                "ECDH-RSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
                "DHE-RSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
                "DHE-DSS-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
                "ECDHE-ECDSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
                "ECDHE-RSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);


        // TLS_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_RSA_WITH_AES_128_CBC_SHA",
                "AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);


        // TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
                "ECDH-ECDSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
                "ECDH-RSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
                "DHE-RSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
                "DHE-DSS-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
                "ECDHE-ECDSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_RC4_128_SHA",
                "ECDHE-RSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_RSA_WITH_RC4_128_SHA
        cipher = new SslCipher("SSL_RSA_WITH_RC4_128_SHA",
                "RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
                "ECDH-ECDSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_RC4_128_SHA",
                "ECDH-RSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
                "ECDHE-ECDSA-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
                "ECDHE-ECDSA-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AESGCM128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
                "ECDHE-RSA-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_RSA_WITH_AES_256_GCM_SHA384",
                "AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
        // openssl doesn't have it

        // TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
        // openssl doesn't have it

        // TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
                "DHE-RSA-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
                "DHE-DSS-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
                "ECDHE-RSA-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_RSA_WITH_AES_128_GCM_SHA256",
                "AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
        // openssl doesn't have it

        // TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
        // openssl doesn't have it

        // TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
                "DHE-RSA-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
                "DHE-DSS-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
                "ECDHE-ECDSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
                "ECDHE-RSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("SSL_RSA_WITH_3DES_EDE_CBC_SHA",
                "DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",
                "ECDH-ECDSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA",
                "ECDH-RSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
                "EDH-RSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
                "EDH-DSS-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_RSA_WITH_RC4_128_MD5
        cipher = new SslCipher("SSL_RSA_WITH_RC4_128_MD5",
                "RC4-MD5", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.RC4,
                CipherMAC.MD5,
                CipherProtocolVersion.SSLV3,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_EMPTY_RENEGOTIATION_INFO_SCSV
        // openssl doesn't have it
    }
1198906
public KeyPair toRSA(boolean includePrivateParameters, Provider provider) {

        // Must be RSA
        checkRSACompatible();

        if (includePrivateParameters) {
            return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider));
        } else {
            return new KeyPair(getRSAPublicKey(provider), null);
        }
    }
1235346
def _get_asam_configuration(driver_url=''):
    '''
    
    '''
    asam_config = __opts__['asam'] if 'asam' in __opts__ else None

    if asam_config:
        try:
            for asam_server, service_config in six.iteritems(asam_config):
                username = service_config.get('username', None)
                password = service_config.get('password', None)
                protocol = service_config.get('protocol', 'https')
                port = service_config.get('port', 3451)

                if not username or not password:
                    log.error(
                        'Username or Password has not been specified in the '
                        'master configuration for %s', asam_server
                    )
                    return False

                ret = {
                    'platform_edit_url': "{0}://{1}:{2}/config/PlatformEdit.html".format(protocol, asam_server, port),
                    'platform_config_url': "{0}://{1}:{2}/config/PlatformConfig.html".format(protocol, asam_server, port),
                    'platformset_edit_url': "{0}://{1}:{2}/config/PlatformSetEdit.html".format(protocol, asam_server, port),
                    'platformset_config_url': "{0}://{1}:{2}/config/PlatformSetConfig.html".format(protocol, asam_server, port),
                    'username': username,
                    'password': password
                }

                if (not driver_url) or (driver_url == asam_server):
                    return ret
        except Exception as exc:
            log.error('Exception encountered: %s', exc)
            return False

        if driver_url:
            log.error(
                'Configuration for %s has not been specified in the master '
                'configuration', driver_url
            )
            return False

    return False
924914
public static Unsafe getUnsafe() {
    // Not on bootclasspath
    if( UtilUnsafe.class.getClassLoader() == null )
      return Unsafe.getUnsafe();
    try {
      final Field fld = Unsafe.class.getDeclaredField("theUnsafe");
      fld.setAccessible(true);
      return (Unsafe) fld.get(UtilUnsafe.class);
    } catch (Exception e) {
      throw new RuntimeException("Could not obtain access to sun.misc.Unsafe", e);
    }
  }
960791
public HashMap<String, String> ssoTokenGenerator() throws Exception {
        String protocol = "https://";
        HashMap<String, String> cookieToken = new HashMap<>();

        SSLContext sslContext = SSLContext.getInstance("SSL");
        // set up a TrustManager that trusts everything
        sslContext.init(null, ALL_TRUSTING_TRUST_MANAGER, new SecureRandom());
        HttpClientContext context = HttpClientContext.create();
        HttpGet httpGet = new HttpGet(protocol + ssoHost + "/login");
        HttpClient client = HttpClientBuilder.create()
                .setSslcontext(sslContext)
                .setRedirectStrategy(new LaxRedirectStrategy())
                .setDefaultRequestConfig(RequestConfig.custom()
                        .setCookieSpec(CookieSpecs.STANDARD).setCircularRedirectsAllowed(true).build()).build();
        try {
            HttpResponse firstResponse = client.execute(httpGet, context);

            logger.debug(firstResponse.getStatusLine().toString());
            Document doc = Jsoup.parse(getStringFromIS(firstResponse.getEntity().getContent()));
            Elements code = doc.select("[name=lt]");
            String loginCode = code.attr("value");
            String executionCode = doc.select("[name=execution]").attr("value");
            for (Header oneHeader : firstResponse.getAllHeaders()) {
                logger.debug(oneHeader.getName() + ":" + oneHeader.getValue());
            }

            URI redirect = context.getRedirectLocations().get(context.getRedirectLocations().size() - 1);

            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("_eventId", "submit"));
            params.add(new BasicNameValuePair("submit", "LOGIN"));
            params.add(new BasicNameValuePair("username", userName));
            params.add(new BasicNameValuePair("password", passWord));

            if (tenant != null) {
                params.add(new BasicNameValuePair("tenant", tenant));
            }

            params.add(new BasicNameValuePair("lt", loginCode));
            params.add(new BasicNameValuePair("execution", executionCode));
            HttpPost httpPost = new HttpPost(redirect);
            httpPost.setEntity(new UrlEncodedFormEntity(params));
            HttpResponse secondResponse = client.execute(httpPost, context);

            for (Header oneHeader : secondResponse.getAllHeaders()) {
                logger.debug(oneHeader.getName() + ":" + oneHeader.getValue());
            }

            HttpGet managementGet = new HttpGet(protocol + ssoHost + managementHost);
            client.execute(managementGet, context);

            for (Cookie oneCookie : context.getCookieStore().getCookies()) {
                logger.debug(oneCookie.getName() + ":" + oneCookie.getValue());
                cookieToken.put(oneCookie.getName(), oneCookie.getValue());
            }

        } catch (Exception e) {
            e.getStackTrace();
        }
        return cookieToken;
    }
246471
def ensure_security_header(envelope, queue):
    
    (header,) = HEADER_XPATH(envelope)
    security = SECURITY_XPATH(header)
    if security:
        for timestamp in TIMESTAMP_XPATH(security[0]):
            queue.push_and_mark(timestamp)
        return security[0]
    else:
        nsmap = {
            'wsu': ns.wsuns[1],
            'wsse': ns.wssens[1],
        }
        return _create_element(header, 'wsse:Security', nsmap)
887615
private static final int getSecurityFlags(final Map properties) {
		int securityType = 0;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_PRINTING)) ? (securityType | PdfWriter.ALLOW_PRINTING)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFY_CONTENTS)) ? (securityType | PdfWriter.ALLOW_MODIFY_CONTENTS)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_COPY)) ? (securityType | PdfWriter.ALLOW_COPY)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFT_ANNOTATIONS)) ? (securityType | PdfWriter.ALLOW_MODIFY_ANNOTATIONS)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_FILLIN)) ? (securityType | PdfWriter.ALLOW_FILL_IN)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_SCREEN_READERS)) ? (securityType | PdfWriter.ALLOW_SCREENREADERS)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_ASSEMBLY)) ? (securityType | PdfWriter.ALLOW_ASSEMBLY)
				: securityType;
		securityType = "true".equals(properties
				.get(IHtmlToPdfTransformer.PDF_ALLOW_DEGRADED_PRINTING)) ? (securityType | PdfWriter.ALLOW_DEGRADED_PRINTING)
				: securityType;

		return securityType;
	}
768157
static Class findProviderClass(String className, ClassLoader cl,
                                           boolean doFallback)
        throws ClassNotFoundException, ConfigurationError
    {   
        //throw security exception if the calling thread is not allowed to access the
        //class. Restrict the access to the package classes as specified in java.security policy.
        SecurityManager security = System.getSecurityManager();
        try{
                if (security != null){
                    final int lastDot = className.lastIndexOf(".");
                    String packageName = className;
                    if (lastDot != -1) packageName = className.substring(0, lastDot);
                    security.checkPackageAccess(packageName);
                 }   
        }catch(SecurityException e){
            throw e;
        }
        
        Class providerClass;
        if (cl == null) {
            // XXX Use the bootstrap ClassLoader.  There is no way to
            // load a class using the bootstrap ClassLoader that works
            // in both JDK 1.1 and Java 2.  However, this should still
            // work b/c the following should be true:
            //
            // (cl == null) iff current ClassLoader == null
            //
            // Thus Class.forName(String) will use the current
            // ClassLoader which will be the bootstrap ClassLoader.
            providerClass = Class.forName(className);
        } else {
            try {
                providerClass = cl.loadClass(className);
            } catch (ClassNotFoundException x) {
                if (doFallback) {
                    // Fall back to current classloader
                    ClassLoader current = ObjectFactory.class.getClassLoader();
                    if (current == null) {
                        providerClass = Class.forName(className);
                    } else if (cl != current) {
                        cl = current;
                        providerClass = cl.loadClass(className);
                    } else {
                        throw x;
                    }
                } else {
                    throw x;
                }
            }
        }

        return providerClass;
    }
314573
public KeyPair toEC(boolean includePrivateParameters, Provider provider) {

        if (provider == null) {
            // Our default provider for this class
            provider = Security.getProvider("SunEC");
        }

        if (!JsonWebKeyType.EC.equals(kty) && !JsonWebKeyType.EC_HSM.equals(kty)) {
            throw new IllegalArgumentException("Not an EC key.");
        }

        try {
            KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", provider);

            ECGenParameterSpec gps = new ECGenParameterSpec(CURVE_TO_SPEC_NAME.get(crv));
            kpg.initialize(gps);

            // Generate dummy keypair to get parameter spec.
            KeyPair apair = kpg.generateKeyPair();
            ECPublicKey apub = (ECPublicKey) apair.getPublic();
            ECParameterSpec aspec = apub.getParams();

            ECPoint ecPoint = new ECPoint(new BigInteger(1, x), new BigInteger(1, y));

            KeyPair realKeyPair;

            if (includePrivateParameters) {
                realKeyPair = new KeyPair(getECPublicKey(ecPoint, aspec, provider),
                        getECPrivateKey(d, aspec, provider));
            } else {
                realKeyPair = new KeyPair(getECPublicKey(ecPoint, aspec, provider), null);
            }

            return realKeyPair;
        } catch (GeneralSecurityException e) {
            throw new IllegalStateException(e);
        }
    }
466087
@Autowired
    @Bean
    public WebSecurityConfigurerAdapter casConfigurationServerWebSecurityConfigurerAdapter(final ServerProperties serverProperties) {
        return new WebSecurityConfigurerAdapter() {
            @Override
            protected void configure(final HttpSecurity http) throws Exception {
                super.configure(http);
                val path = serverProperties.getServlet().getContextPath();
                http.authorizeRequests().antMatchers(path + "/decrypt/**").authenticated().and().csrf().disable();
                http.authorizeRequests().antMatchers(path + "/encrypt/**").authenticated().and().csrf().disable();
            }
        };
    }
206788
@Override
	public List<ScopDomain> getScopDomainsBySunid(Integer sunid)
	{

		try {
			ensureClaInstalled();
		} catch (IOException e) {
			throw new ScopIOException(e);
		}

		List<ScopDomain> domains = new ArrayList<ScopDomain>();

		for (String pdbId: domainMap.keySet()){
			for (ScopDomain d : domainMap.get(pdbId)){
				try {
					if ( d.getPx() == sunid) {
						domains.add((ScopDomain)d.clone());
					} else if ( d.getSpeciesId() == sunid ){
						domains.add((ScopDomain)d.clone());
					}else if ( d.getDomainId() == sunid ){
						domains.add((ScopDomain)d.clone());
					}else if ( d.getFamilyId() == sunid ){
						domains.add((ScopDomain)d.clone());
					}else if ( d.getSuperfamilyId() == sunid ){
						domains.add((ScopDomain)d.clone());
					}else if ( d.getFoldId() == sunid ){
						domains.add((ScopDomain)d.clone());
					}else if ( d.getClassId() == sunid ){
						domains.add((ScopDomain)d.clone());
					} else {
						throw new RuntimeException("Type " + d + " not recognized"); // only possible if SCOP changes
					}
				} catch (CloneNotSupportedException e){
					throw new RuntimeException(ScopDomain.class + " subclass does not support clone()", e);
				}
			}
		}
		return domains;

	}
1033576
private boolean privilegedIsMasterSecretValid(final Socket socket) {
        if (socket instanceof SSLSocket) {
            SSLSession session = getSslSession(socket);
            if (session != null) {
                String className = session.getClass().getName();
                if ("sun.security.ssl.SSLSessionImpl".equals(className)) {
                    try {
                        Object masterSecret = getMasterSecret(session, className);
                        if (masterSecret == null) {
                            session.invalidate();
                            if (LOG.isDebugEnabled()) {
                                LOG.debug("Invalidated session " + session);
                            }
                            return false;
                        }
                    } catch (Exception e) {
                        failedToVerifyMasterSecret(e);
                    }
                }
            }
        }
        return true;

    }
382419
def get_session_data(ctx, username, password, salt, server_public, private, preset):
    """"""
    session = SRPClientSession(
        SRPContext(username, password, prime=preset[0], generator=preset[1]),
        private=private)

    session.process(server_public, salt, base64=True)

    click.secho('Client session key: %s' % session.key_b64)
    click.secho('Client session key proof: %s' % session.key_proof_b64)
    click.secho('Client session key hash: %s' % session.key_proof_hash_b64)
962546
public SessionProvider getSystemSessionProvider(Object key)
   {
      if (systemProviders.containsKey(key))
      {
         return systemProviders.get(key);
      }
      else
      {
         final SessionProvider ssp = SessionProvider.createSystemProvider();
         systemProviders.put(key, ssp);
         return ssp;
      }
   }
1329826
private void configureSecurity(ServletContextHandler context, String realmName, String authMethod,
								   String formLoginPage, String formErrorPage) {
		final SecurityHandler securityHandler = context.getSecurityHandler();

		Authenticator authenticator = null;
		if (authMethod == null) {
			LOG.warn("UNKNOWN AUTH METHOD: " + authMethod);
		} else {
			switch (authMethod) {
				case Constraint.__FORM_AUTH:
					authenticator = new FormAuthenticator();
					securityHandler.setInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE, formLoginPage);
					securityHandler.setInitParameter(FormAuthenticator.__FORM_ERROR_PAGE, formErrorPage);
					break;
				case Constraint.__BASIC_AUTH:
					authenticator = new BasicAuthenticator();
					break;
				case Constraint.__DIGEST_AUTH:
					authenticator = new DigestAuthenticator();
					break;
				case Constraint.__CERT_AUTH:
					authenticator = new ClientCertAuthenticator();
					break;
				case Constraint.__CERT_AUTH2:
					authenticator = new ClientCertAuthenticator();
					break;
				case Constraint.__SPNEGO_AUTH:
					authenticator = new SpnegoAuthenticator();
					break;
				default:
					authenticator = getAuthenticator(authMethod);
					break;
			}
		}

		securityHandler.setAuthenticator(authenticator);

		securityHandler.setRealmName(realmName);

	}
389669
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1784")
  @CanIgnoreReturnValue
  public static SslContextBuilder configure(SslContextBuilder builder, SslProvider provider) {
    switch (provider) {
      case JDK:
      {
        Provider jdkProvider = findJdkProvider();
        if (jdkProvider == null) {
          throw new IllegalArgumentException(
              "Could not find Jetty NPN/ALPN or Conscrypt as installed JDK providers");
        }
        return configure(builder, jdkProvider);
      }
      case OPENSSL:
      {
        ApplicationProtocolConfig apc;
        if (OpenSsl.isAlpnSupported()) {
          apc = NPN_AND_ALPN;
        } else {
          apc = NPN;
        }
        return builder
            .sslProvider(SslProvider.OPENSSL)
            .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
            .applicationProtocolConfig(apc);
      }
      default:
        throw new IllegalArgumentException("Unsupported provider: " + provider);
    }
  }
1065437
def get_private_and_public(ctx, username, password, private, preset):
    """"""
    session = SRPClientSession(
        SRPContext(username, password, prime=preset[0], generator=preset[1]),
        private=private)

    click.secho('Client private: %s' % session.private_b64)
    click.secho('Client public: %s' % session.public_b64)