1 package org.bouncycastle.asn1.x509; 2 3 import org.bouncycastle.asn1.ASN1Object; 4 import org.bouncycastle.asn1.ASN1ObjectIdentifier; 5 import org.bouncycastle.asn1.ASN1Primitive; 6 7 /** 8 * The KeyPurposeId object. 9 * <pre> 10 * KeyPurposeId ::= OBJECT IDENTIFIER 11 * 12 * id-kp ::= OBJECT IDENTIFIER { iso(1) identified-organization(3) 13 * dod(6) internet(1) security(5) mechanisms(5) pkix(7) 3} 14 * 15 * </pre> 16 * To create a new KeyPurposeId where none of the below suit, use 17 * <pre> 18 * ASN1ObjectIdentifier newKeyPurposeIdOID = new ASN1ObjectIdentifier("1.3.6.1..."); 19 * 20 * KeyPurposeId newKeyPurposeId = KeyPurposeId.getInstance(newKeyPurposeIdOID); 21 * </pre> 22 */ 23 public class KeyPurposeId 24 extends ASN1Object 25 { 26 private static final ASN1ObjectIdentifier id_kp = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.3"); 27 28 /** 29 * { 2 5 29 37 0 } 30 */ 31 public static final KeyPurposeId anyExtendedKeyUsage = new KeyPurposeId(Extension.extendedKeyUsage.branch("0")); 32 33 /** 34 * { id-kp 1 } 35 */ 36 public static final KeyPurposeId id_kp_serverAuth = new KeyPurposeId(id_kp.branch("1")); 37 /** 38 * { id-kp 2 } 39 */ 40 public static final KeyPurposeId id_kp_clientAuth = new KeyPurposeId(id_kp.branch("2")); 41 /** 42 * { id-kp 3 } 43 */ 44 public static final KeyPurposeId id_kp_codeSigning = new KeyPurposeId(id_kp.branch("3")); 45 /** 46 * { id-kp 4 } 47 */ 48 public static final KeyPurposeId id_kp_emailProtection = new KeyPurposeId(id_kp.branch("4")); 49 /** 50 * Usage deprecated by RFC4945 - was { id-kp 5 } 51 */ 52 public static final KeyPurposeId id_kp_ipsecEndSystem = new KeyPurposeId(id_kp.branch("5")); 53 /** 54 * Usage deprecated by RFC4945 - was { id-kp 6 } 55 */ 56 public static final KeyPurposeId id_kp_ipsecTunnel = new KeyPurposeId(id_kp.branch("6")); 57 /** 58 * Usage deprecated by RFC4945 - was { idkp 7 } 59 */ 60 public static final KeyPurposeId id_kp_ipsecUser = new KeyPurposeId(id_kp.branch("7")); 61 /** 62 * { id-kp 8 } 63 */ 64 public static final KeyPurposeId id_kp_timeStamping = new KeyPurposeId(id_kp.branch("8")); 65 /** 66 * { id-kp 9 } 67 */ 68 public static final KeyPurposeId id_kp_OCSPSigning = new KeyPurposeId(id_kp.branch("9")); 69 /** 70 * { id-kp 10 } 71 */ 72 public static final KeyPurposeId id_kp_dvcs = new KeyPurposeId(id_kp.branch("10")); 73 /** 74 * { id-kp 11 } 75 */ 76 public static final KeyPurposeId id_kp_sbgpCertAAServerAuth = new KeyPurposeId(id_kp.branch("11")); 77 /** 78 * { id-kp 12 } 79 */ 80 public static final KeyPurposeId id_kp_scvp_responder = new KeyPurposeId(id_kp.branch("12")); 81 /** 82 * { id-kp 13 } 83 */ 84 public static final KeyPurposeId id_kp_eapOverPPP = new KeyPurposeId(id_kp.branch("13")); 85 /** 86 * { id-kp 14 } 87 */ 88 public static final KeyPurposeId id_kp_eapOverLAN = new KeyPurposeId(id_kp.branch("14")); 89 /** 90 * { id-kp 15 } 91 */ 92 public static final KeyPurposeId id_kp_scvpServer = new KeyPurposeId(id_kp.branch("15")); 93 /** 94 * { id-kp 16 } 95 */ 96 public static final KeyPurposeId id_kp_scvpClient = new KeyPurposeId(id_kp.branch("16")); 97 /** 98 * { id-kp 17 } 99 */ 100 public static final KeyPurposeId id_kp_ipsecIKE = new KeyPurposeId(id_kp.branch("17")); 101 /** 102 * { id-kp 18 } 103 */ 104 public static final KeyPurposeId id_kp_capwapAC = new KeyPurposeId(id_kp.branch("18")); 105 /** 106 * { id-kp 19 } 107 */ 108 public static final KeyPurposeId id_kp_capwapWTP = new KeyPurposeId(id_kp.branch("19")); 109 110 // 111 // microsoft key purpose ids 112 // 113 /** 114 * { 1 3 6 1 4 1 311 20 2 2 } 115 */ 116 public static final KeyPurposeId id_kp_smartcardlogon = new KeyPurposeId(new ASN1ObjectIdentifier("1.3.6.1.4.1.311.20.2.2")); 117 118 119 /** 120 * 121 */ 122 public static final KeyPurposeId id_kp_macAddress = new KeyPurposeId(new ASN1ObjectIdentifier("1.3.6.1.1.1.1.22")); 123 124 125 /** 126 * Microsoft Server Gated Crypto (msSGC) see http://www.alvestrand.no/objectid/1.3.6.1.4.1.311.10.3.3.html 127 */ 128 public static final KeyPurposeId id_kp_msSGC = new KeyPurposeId(new ASN1ObjectIdentifier("1.3.6.1.4.1.311.10.3.3")); 129 130 /** 131 * Netscape Server Gated Crypto (nsSGC) see http://www.alvestrand.no/objectid/2.16.840.1.113730.4.1.html 132 */ 133 public static final KeyPurposeId id_kp_nsSGC = new KeyPurposeId(new ASN1ObjectIdentifier("2.16.840.1.113730.4.1")); 134 135 136 private ASN1ObjectIdentifier id; 137 138 private KeyPurposeId(ASN1ObjectIdentifier id) 139 { 140 this.id = id; 141 } 142 143 /** 144 * @param id string representation of an OID. 145 * @deprecated use getInstance and an OID or one of the constants above. 146 */ 147 public KeyPurposeId(String id) 148 { 149 this(new ASN1ObjectIdentifier(id)); 150 } 151 152 public static KeyPurposeId getInstance(Object o) 153 { 154 if (o instanceof KeyPurposeId) 155 { 156 return (KeyPurposeId)o; 157 } 158 else if (o != null) 159 { 160 return new KeyPurposeId(ASN1ObjectIdentifier.getInstance(o)); 161 } 162 163 return null; 164 } 165 166 public ASN1ObjectIdentifier toOID() 167 { 168 return id; 169 } 170 171 public ASN1Primitive toASN1Primitive() 172 { 173 return id; 174 } 175 176 public String getId() 177 { 178 return id.getId(); 179 } 180 181 public String toString() 182 { 183 return id.toString(); 184 } 185 } 186