1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampackage org.bouncycastle.asn1.x509; 2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 3b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Choice; 4b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Encodable; 5b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Sequence; 6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1TaggedObject; 7b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERObject; 8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERTaggedObject; 9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic class AttCertIssuer 11b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam extends ASN1Encodable 12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam implements ASN1Choice 13b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam{ 14b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam ASN1Encodable obj; 15b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam DERObject choiceObj; 16c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom 17b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public static AttCertIssuer getInstance( 18b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam Object obj) 19b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 20b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam if (obj instanceof AttCertIssuer) 21b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 22b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return (AttCertIssuer)obj; 23b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 24b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam else if (obj instanceof V2Form) 25b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 26b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return new AttCertIssuer(V2Form.getInstance(obj)); 27b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 28b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam else if (obj instanceof GeneralNames) 29b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 30b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return new AttCertIssuer((GeneralNames)obj); 31b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 32b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam else if (obj instanceof ASN1TaggedObject) 33b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 34b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return new AttCertIssuer(V2Form.getInstance((ASN1TaggedObject)obj, false)); 35b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 36b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam else if (obj instanceof ASN1Sequence) 37b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 38b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return new AttCertIssuer(GeneralNames.getInstance(obj)); 39b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 40b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 41c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName()); 42b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 43b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 44b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public static AttCertIssuer getInstance( 45b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam ASN1TaggedObject obj, 46b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam boolean explicit) 47b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 48b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return getInstance(obj.getObject()); // must be explicitly tagged 49b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 50b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 51b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam /** 52c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * Don't use this one if you are trying to be RFC 3281 compliant. 53c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * Use it for v1 attribute certificates only. 54b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * 55b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * @param names our GeneralNames structure 56b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */ 57b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public AttCertIssuer( 58b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam GeneralNames names) 59b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 60b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam obj = names; 61b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam choiceObj = obj.getDERObject(); 62b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 63b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 64b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public AttCertIssuer( 65b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam V2Form v2Form) 66b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 67b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam obj = v2Form; 68b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam choiceObj = new DERTaggedObject(false, 0, obj); 69b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 70b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 71b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public ASN1Encodable getIssuer() 72b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 73b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return obj; 74b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 75b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 76b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam /** 77b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * Produce an object suitable for an ASN1OutputStream. 78b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * <pre> 79b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * AttCertIssuer ::= CHOICE { 80b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * v1Form GeneralNames, -- MUST NOT be used in this 81b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * -- profile 82b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * v2Form [0] V2Form -- v2 only 83b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * } 84b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * </pre> 85b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */ 86b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public DERObject toASN1Object() 87b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 88b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return choiceObj; 89b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 90b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam} 91