1 package com.ca.commons.security.asn1; 2 3 import java.util.Hashtable ; 4 5 10 public class ASN1OID implements java.io.Serializable  11 { 12 13 private static Hashtable id2name = new Hashtable (50); 14 private static Hashtable name2id = new Hashtable (50); 15 16 17 public static String rsadsi = "1 2 840 113549"; 18 public static String x9_57 = "1 2 840 10040"; 19 public static String ansi_x942 = "1 2 840 10046"; 20 21 public static String digestAlgorithm = rsadsi + " 2"; 22 public static String md2 = digestAlgorithm + " 2"; 23 public static String md4 = digestAlgorithm + " 4"; 24 public static String md5 = digestAlgorithm + " 5"; 25 26 public static String encryptionAlgorithm = rsadsi + " 3"; 27 public static String rc2_cbc = encryptionAlgorithm + " 2"; 28 public static String des_ede3_cbc = encryptionAlgorithm + " 7"; 29 30 31 public static String pkcs = rsadsi + " 1"; 32 33 34 public static String pkcs_1 = pkcs + " 1"; 35 public static String rsaEncryption = pkcs_1 + " 1"; 36 public static String md2WithRSAEncryption = pkcs_1 + " 2"; 37 public static String md4WithRSAEncryption = pkcs_1 + " 3"; 38 public static String md5WithRSAEncryption = pkcs_1 + " 4"; 39 public static String sha1WithRSAEncryption = pkcs_1 + " 5"; 40 41 42 public static String pkcs_5 = pkcs + " 5"; 43 public static String pbeWithMD2AndDES_CBC = pkcs_5 + " 1"; 44 public static String pbeWithMD5AndDES_CBC = pkcs_5 + " 3"; 45 public static String pbeWithSHA1AndDES_CBC = pkcs_5 + " 10"; 46 public static String pbeWithSHA1AndRC2_CBC = pkcs_5 + " 11"; 47 public static String pbeWithSHA1AndRC4 = pkcs_5 + " 12"; 48 49 50 51 52 public static String pkcs_9 = pkcs + " 9"; 53 public static String emailAddress = pkcs_9 + " 1"; 54 public static String unstructuredName = pkcs_9 + " 2"; 55 public static String contentType = pkcs_9 + " 3"; 56 public static String messageDigest = pkcs_9 + " 4"; 57 public static String signingTime = pkcs_9 + " 5"; 58 public static String countersignature = pkcs_9 + " 6"; 59 public static String challengePassword = pkcs_9 + " 7"; 60 public static String unstructuredAddress = pkcs_9 + " 8"; 61 public static String extendedCertificateAttributes = pkcs_9 + " 9"; 62 public static String friendlyName = pkcs_9 + " 20"; 63 public static String localKeyID = pkcs_9 + " 21"; 64 public static String certTypes = pkcs_9 + " 22"; 65 public static String x509Certificate = certTypes + " 1"; 66 public static String sdsiCertificate = certTypes + " 2"; 67 public static String crlTypes = pkcs_9 + " 23"; 68 public static String x509Crl = crlTypes + " 1"; 69 70 71 public static String pkcs_7 = pkcs + " 7"; 72 public static String data = pkcs_7 + " 1"; 73 public static String signedData = pkcs_7 + " 2"; 74 public static String envelopedData = pkcs_7 + " 3"; 75 public static String signedAndEnvelopedData = pkcs_7 + " 4"; 76 public static String digestedData = pkcs_7 + " 5"; 77 public static String encryptedData = pkcs_7 + " 6"; 78 79 public static String ct_authData = pkcs_9 + " 16 1 2"; 80 public static String macValue = pkcs_9 + " 16 2 8"; 81 82 83 public static String pkcs_12 = pkcs + " 12"; 84 public static String pkcs_12PbeIds = pkcs_12 + " 1"; 85 public static String pbeWithSHA1And128BitRC4 = pkcs_12PbeIds + " 1"; 86 public static String pbeWithSHA1And40BitRC4 = pkcs_12PbeIds + " 2"; 87 public static String pbeWithSHA1And3DES = pkcs_12PbeIds + " 3"; 88 public static String pbeWithSHA1And2DES = pkcs_12PbeIds + " 4"; 89 public static String pbeWithSHA1And128BitRC2 = pkcs_12PbeIds + " 5"; 90 public static String pbeWithSHA1And40BitRC2 = pkcs_12PbeIds + " 6"; 91 92 public static String pkcs_12Version1 = pkcs_12 + " 10"; 93 public static String pkcs_12BagIds = pkcs_12Version1 + " 1"; 94 public static String keyBag = pkcs_12BagIds + " 1"; 95 public static String pkcs_8ShroudedKeyBag = pkcs_12BagIds + " 2"; 96 public static String certBag = pkcs_12BagIds + " 3"; 97 public static String crlBag = pkcs_12BagIds + " 4"; 98 public static String secretBag = pkcs_12BagIds + " 5"; 99 public static String safeContentsBag = pkcs_12BagIds + " 6"; 100 101 public static String pkcs_12CertBagIds = pkcs_12 + " 4"; 102 public static String x509CertCRLBagId = pkcs_12CertBagIds + " 1"; 103 public static String SDSICertBagId = pkcs_12CertBagIds + " 2"; 104 105 106 107 public static String X500 = "2 5"; 108 public static String X509 = X500 + " 4"; 109 public static String commonName = X509 + " 3"; 110 public static String country = X509 + " 6"; 111 public static String locality = X509 + " 7"; 112 public static String stateOrProvince = X509 + " 8"; 113 public static String organization = X509 + " 10"; 114 public static String organizationalUnit = X509 + " 11"; 115 public static String surname = X509 + " 4"; 116 public static String serialNumber = X509 + " 5"; 117 public static String title = X509 + " 12"; 118 public static String description = X509 + " 13"; 119 public static String givenName = X509 + " 42"; 120 public static String initials = X509 + " 43"; 121 public static String uniqueIdentifier = X509 + " 45"; 122 123 124 public static String ld_ce = "2.5.29"; 125 public static String subjectKeyIdentifier = ld_ce + ".14"; 126 public static String keyUsage = ld_ce + ".15"; 127 public static String privateKeyUsagePeriod = ld_ce + ".16"; 128 public static String subjectAltName = ld_ce + ".17"; 129 public static String issuerAltName = ld_ce + ".18"; 130 public static String basicConstraints = ld_ce + ".19"; 131 public static String crlNumber = ld_ce + ".20"; 132 133 public static String nameConstraints = ld_ce + ".30"; 134 public static String crlDistributionPoints = ld_ce + ".31"; 135 public static String certificatePolicies = ld_ce + ".32"; 136 public static String policyMappings = ld_ce + ".33"; 137 public static String authorityKeyIdentifier = ld_ce + ".35"; 138 public static String policyConstraints = ld_ce + ".36"; 139 public static String extendedKeyUsage = ld_ce + ".37"; 140 141 public static String id_pkix_dot = "1.3.6.1.5.5.7"; 143 public static String id_pe_dot = id_pkix_dot + ".1"; 144 public static String id_pe_authorityInfoAccess = id_pe_dot + ".1"; 145 146 public static String CRLReason = ld_ce + " 21"; 148 public static String CRLNumber = ld_ce + " 20"; 149 public static String invalidityDate = ld_ce + " 24"; 150 public static String deltaCRLIndicator = ld_ce + " 27"; 151 public static String certIssuer = ld_ce + " 29"; 152 public static String issuingDPoint = ld_ce + " 28"; 153 154 public static String id_pkix = "1 3 6 1 5 5 7"; 155 156 public static String id_pe = id_pkix + " 1"; 158 public static String id_ad = id_pkix + " 48"; 159 public static String authInfoAccessOCSP = id_ad + " 1"; 160 public static String authInfoAccesscaIssuers = id_ad + " 2"; 161 162 public static String cpsOID = id_pkix + " 2 1"; 164 public static String userNoticeOID = id_pkix + " 2 2"; 165 166 public static String id_kp = id_pkix + " 3"; 168 public static String id_kp_serverAuth = id_kp + " 1"; 169 public static String id_kp_clientAuth = id_kp + " 2"; 170 public static String id_kp_codeSigning = id_kp + " 3"; 171 public static String id_kp_emailProtection = id_kp + " 4"; 172 public static String id_kp_ipsecEndSystem = id_kp + " 5"; 173 public static String id_kp_ipsecTunnel = id_kp + " 6"; 174 public static String id_kp_ipsecUser = id_kp + " 7"; 175 public static String id_kp_timeStamping = id_kp + " 8"; 176 public static String id_kp_OCSPSigning = id_kp + " 9"; 177 178 179 180 public static String id_dsa = x9_57 + "4 1"; 181 public static String dhpublicnumber = ansi_x942 + "2 1"; 182 183 184 public static String algorithm = "1 3 14 3 2"; 185 public static String sha = algorithm + " 18"; 186 public static String sha1 = algorithm + " 26"; 187 public static String shaWithRSAEncryption = algorithm + " 15"; 188 189 190 public static String netscape = "2 16 840 1 113730"; 191 public static String netscapeCertExt = netscape + " 1"; 192 public static String netscapeCertType = netscapeCertExt + " 1"; 193 public static String netscapeComment = netscapeCertExt + " 13"; 194 195 static { 196 197 198 register(md2, "md2"); 199 register(md4, "md4"); 200 register(md5, "md5"); 201 register(sha1, "sha1"); 202 203 204 register(rsaEncryption, "rsaEncryption"); 205 register(des_ede3_cbc, "des_ede3_cbc"); 206 register(rc2_cbc, "rc2_cbc"); 207 208 209 register(md2WithRSAEncryption, "md2WithRSAEncryption"); 210 register(md4WithRSAEncryption, "md4WithRSAEncryption"); 211 register(md5WithRSAEncryption, "md5WithRSAEncryption"); 212 register(sha1WithRSAEncryption, "sha1WithRSAEncryption"); 213 214 215 register(country, "country"); 216 register(stateOrProvince, "stateOrProvince"); 217 register(locality, "locality"); 218 register(organization, "organization"); 219 register(organizationalUnit, "organizationalUnit"); 220 register(commonName, "commonName"); 221 register(surname, "surname"); 222 register(serialNumber, "serialNumber"); 223 register(title, "title"); 224 register(description, "description"); 225 register(givenName, "givenName"); 226 register(initials, "initials"); 227 register(uniqueIdentifier, "uniqueIdentifier"); 228 229 230 register(emailAddress, "emailAddress"); 231 register(unstructuredName, "unstructuredName"); 232 register(contentType, "contentType"); 233 register(messageDigest, "messageDigest"); 234 register(signingTime, "signingTime"); 235 register(countersignature, "countersignature"); 236 register(challengePassword, "challengePassword"); 237 register(unstructuredAddress, "unstructuredAddress"); 238 239 240 register(data, "data"); 241 register(signedData, "signedData"); 242 register(envelopedData, "envelopedData"); 243 register(signedAndEnvelopedData, "signedAndEnvelopedData"); 244 register(digestedData, "digestedData"); 245 register(encryptedData, "encryptedData"); 246 247 248 register(ct_authData, "ct_authData"); 249 register(macValue, "macValue"); 250 251 252 register(subjectKeyIdentifier, "Subject Key Identifier"); 253 register(keyUsage, "Key Usage"); 254 register(privateKeyUsagePeriod, "Private Key Usage Period"); 255 register(subjectAltName, "Subject Alternative Name"); 256 register(issuerAltName, "Issuer Alternative Name"); 257 register(basicConstraints, "Basic Constraints"); 258 register(crlNumber, "CRL Number"); 259 260 register(nameConstraints, "Name Constraints"); 261 register(crlDistributionPoints, "CRL Distribution Points"); 262 register(certificatePolicies, "Certificate Policies"); 263 register(policyMappings, "Policy Mappings"); 264 register(authorityKeyIdentifier, "Authority Key Identifier"); 265 register(policyConstraints, "Policy Constraints"); 266 register(extendedKeyUsage, "Extended Key Usage"); 267 268 register(id_pe_authorityInfoAccess, "Authority Information Access"); 269 270 271 register(netscapeCertType, "Netscape Cert Type"); 272 register(netscapeComment, "Netscape Comment"); 273 register(netscapeCertExt, "Netscape Certificate Extension"); 274 275 register(id_kp_serverAuth, "TLS Web server authentication"); 276 register(id_kp_clientAuth, "TLS Web client authentication"); 277 register(id_kp_codeSigning, "Code signing"); 278 register(id_kp_emailProtection, "E-mail protection"); 279 register(id_kp_ipsecEndSystem, "IP security end system"); 280 register(id_kp_ipsecTunnel, "IP security tunnel termination"); 281 register(id_kp_ipsecUser, "IP security user"); 282 register(id_kp_timeStamping, "Timestamping"); 283 register(id_kp_OCSPSigning, "OCSP Signing"); 284 register("1 3 6 1 4 1 311 20 2 2", "Smart Card Logon"); 285 286 287 register(id_dsa, "id-dsa"); 288 register(dhpublicnumber, "dhpublicnumber"); 289 } 290 291 294 public static String getName(String id) 295 { 296 String name = (String ) id2name.get(id); 297 if (name == null) 298 { 299 return id; 300 } 301 else 302 { 303 return name; 304 } 305 } 306 307 310 public static String getID(String name) 311 { 312 String id = (String ) name2id.get(name); 313 if (id == null) 314 { 315 return name; 316 } 317 else 318 { 319 return id; 320 } 321 } 322 323 326 private static void register(String id, String name) 327 { 328 id2name.put(id, name); 329 name2id.put(name, id); 330 } 331 } 332 | Popular Tags |