1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampackage org.bouncycastle.asn1.x509; 2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 3b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1EncodableVector; 44c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstromimport org.bouncycastle.asn1.ASN1Object; 54c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstromimport org.bouncycastle.asn1.ASN1Primitive; 6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Sequence; 7b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERBitString; 8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERSequence; 9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic class AttributeCertificate 114c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom extends ASN1Object 12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam{ 13b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam AttributeCertificateInfo acinfo; 14b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam AlgorithmIdentifier signatureAlgorithm; 15b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam DERBitString signatureValue; 16b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 17b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam /** 18b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * @param obj 19b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * @return an AttributeCertificate object 20b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */ 21b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public static AttributeCertificate getInstance(Object obj) 22b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 23b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam if (obj instanceof AttributeCertificate) 24b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 25b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return (AttributeCertificate)obj; 26b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 276e736056d64d0e33b26cf9f7c4e351b496241fdeBrian Carlstrom else if (obj != null) 28b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 296e736056d64d0e33b26cf9f7c4e351b496241fdeBrian Carlstrom return new AttributeCertificate(ASN1Sequence.getInstance(obj)); 30b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 31b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 326e736056d64d0e33b26cf9f7c4e351b496241fdeBrian Carlstrom return null; 33b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 34b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 35b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public AttributeCertificate( 36b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam AttributeCertificateInfo acinfo, 37b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam AlgorithmIdentifier signatureAlgorithm, 38b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam DERBitString signatureValue) 39b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 40b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam this.acinfo = acinfo; 41b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam this.signatureAlgorithm = signatureAlgorithm; 42b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam this.signatureValue = signatureValue; 43b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 445db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root 455db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root /** 465db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root * @deprecated use getInstance() method. 475db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root */ 48b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public AttributeCertificate( 49b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam ASN1Sequence seq) 50b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 51b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam if (seq.size() != 3) 52b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 53b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam throw new IllegalArgumentException("Bad sequence size: " 54b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam + seq.size()); 55b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 56b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 57b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam this.acinfo = AttributeCertificateInfo.getInstance(seq.getObjectAt(0)); 58b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam this.signatureAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); 59b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam this.signatureValue = DERBitString.getInstance(seq.getObjectAt(2)); 60b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 61b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 62b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public AttributeCertificateInfo getAcinfo() 63b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 64b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return acinfo; 65b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 66b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 67b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public AlgorithmIdentifier getSignatureAlgorithm() 68b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 69b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return signatureAlgorithm; 70b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 71b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 72b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam public DERBitString getSignatureValue() 73b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 74b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return signatureValue; 75b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 76b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 77b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam /** 78b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * Produce an object suitable for an ASN1OutputStream. 79b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * <pre> 80b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * AttributeCertificate ::= SEQUENCE { 81b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * acinfo AttributeCertificateInfo, 82b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * signatureAlgorithm AlgorithmIdentifier, 83b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * signatureValue BIT STRING 84b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * } 85b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * </pre> 86b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */ 874c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom public ASN1Primitive toASN1Primitive() 88b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam { 89b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam ASN1EncodableVector v = new ASN1EncodableVector(); 90b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 91b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam v.add(acinfo); 92b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam v.add(signatureAlgorithm); 93b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam v.add(signatureValue); 94b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam 95b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam return new DERSequence(v); 96b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam } 97b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam} 98