1 23 package com.sun.enterprise.security; 24 25 import java.util.HashMap ; 26 27 32 public class CipherInfo { 33 private static final short SSL2 = 0x1; 34 private static final short SSL3 = 0x2; 35 private static final short TLS = 0x4; 36 37 private static final String [][] OLD_HTTP_CIPHER_MAPPING = { 39 {"rsa_rc4_128_md5", "SSL_RSA_WITH_RC4_128_MD5"}, 40 {"rsa_3des_sha" , "SSL_RSA_WITH_3DES_EDE_CBC_SHA"}, 41 {"rsa_des_sha" , "SSL_RSA_WITH_DES_CBC_SHA"}, 42 {"rsa_rc4_40_md5" , "SSL_RSA_EXPORT_WITH_RC4_40_MD5"}, 43 {"rsa_null_md5" , "SSL_RSA_WITH_NULL_MD5"}, 44 {"rsa_des_56_sha" , "SSL_RSA_WITH_DES_CBC_SHA"}, 45 {"rsa_rc4_56_sha" , "SSL_RSA_WITH_RC4_128_SHA"} 46 }; 47 48 private static final String [][] OLD_CIPHER_MAPPING = { 51 {"rsa_rc4_128_sha", "SSL_RSA_WITH_RC4_128_SHA"}, 56 {"fips_des_sha" , "SSL_RSA_WITH_DES_CBC_SHA"}, 57 {"rsa_null_sha" , "SSL_RSA_WITH_NULL_SHA"} 58 }; 59 60 private static final String [] USER_CONFIGURABLE_CIPHERS = { 71 "SSL_RSA_WITH_RC4_128_MD5", 72 "SSL_RSA_WITH_3DES_EDE_CBC_SHA", 73 "SSL_RSA_WITH_DES_CBC_SHA", 74 "SSL_RSA_EXPORT_WITH_RC4_40_MD5", 75 "SSL_RSA_WITH_NULL_MD5", 76 "SSL_RSA_WITH_RC4_128_SHA", 77 "SSL_RSA_WITH_NULL_SHA" }; 78 79 private static HashMap ciphers = new HashMap (); 80 81 private String configName; 82 private String cipherName; 83 private short protocolVersion; 84 85 86 static { 87 90 int len = USER_CONFIGURABLE_CIPHERS.length; 91 for(int i=0; i<len; i++) { 92 String s = USER_CONFIGURABLE_CIPHERS[i]; 93 ciphers.put(s, new CipherInfo(s, s, (short)(SSL3|TLS)) ); 94 } 95 96 len = OLD_HTTP_CIPHER_MAPPING.length; 97 for(int i=0; i<len; i++) { 98 String nonStdName = OLD_HTTP_CIPHER_MAPPING[i][0]; 99 String stdName = OLD_HTTP_CIPHER_MAPPING[i][1]; 100 ciphers.put(nonStdName, 101 new CipherInfo(nonStdName, stdName, (short)(SSL3|TLS)) ); 102 } 103 104 len = OLD_CIPHER_MAPPING.length; 105 for(int i=0; i<len; i++) { 106 String nonStdName = OLD_CIPHER_MAPPING[i][0]; 107 String stdName = OLD_CIPHER_MAPPING[i][1]; 108 ciphers.put(nonStdName, 109 new CipherInfo(nonStdName, stdName, (short)(SSL3|TLS)) ); 110 } 111 } 112 113 118 private CipherInfo(String configName, String cipherName, 119 short protocolVersion) { 120 this.configName = configName; 121 this.cipherName = cipherName; 122 this.protocolVersion = protocolVersion; 123 } 124 125 public static CipherInfo getCipherInfo(String configName) { 126 return (CipherInfo)ciphers.get(configName); 127 } 128 129 public String getConfigName() { 130 return configName; 131 } 132 133 public String getCipherName() { 134 return cipherName; 135 } 136 137 public boolean isSSL2() { 138 return (protocolVersion & SSL2) == SSL2; 139 } 140 141 public boolean isSSL3() { 142 return (protocolVersion & SSL3) == SSL3; 143 } 144 145 public boolean isTLS() { 146 return (protocolVersion & TLS) == TLS; 147 } 148 } 149 | Popular Tags |