01: package org.bouncycastle.asn1.ess;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.DERObject;
07: import org.bouncycastle.asn1.DERSequence;
08: import org.bouncycastle.asn1.x509.PolicyInformation;
09:
10: public class OtherSigningCertificate extends ASN1Encodable {
11: ASN1Sequence certs;
12: ASN1Sequence policies;
13:
14: public static OtherSigningCertificate getInstance(Object o) {
15: if (o == null || o instanceof OtherSigningCertificate) {
16: return (OtherSigningCertificate) o;
17: } else if (o instanceof ASN1Sequence) {
18: return new OtherSigningCertificate((ASN1Sequence) o);
19: }
20:
21: throw new IllegalArgumentException(
22: "unknown object in 'OtherSigningCertificate' factory : "
23: + o.getClass().getName() + ".");
24: }
25:
26: /**
27: * constructeurs
28: */
29: public OtherSigningCertificate(ASN1Sequence seq) {
30: if (seq.size() < 1 || seq.size() > 2) {
31: throw new IllegalArgumentException("Bad sequence size: "
32: + seq.size());
33: }
34:
35: this .certs = ASN1Sequence.getInstance(seq.getObjectAt(0));
36:
37: if (seq.size() > 1) {
38: this .policies = ASN1Sequence
39: .getInstance(seq.getObjectAt(1));
40: }
41: }
42:
43: public OtherSigningCertificate(OtherCertID otherCertID) {
44: certs = new DERSequence(otherCertID);
45: }
46:
47: public OtherCertID[] getCerts() {
48: OtherCertID[] cs = new OtherCertID[certs.size()];
49:
50: for (int i = 0; i != certs.size(); i++) {
51: cs[i] = OtherCertID.getInstance(certs.getObjectAt(i));
52: }
53:
54: return cs;
55: }
56:
57: public PolicyInformation[] getPolicies() {
58: if (policies == null) {
59: return null;
60: }
61:
62: PolicyInformation[] ps = new PolicyInformation[policies.size()];
63:
64: for (int i = 0; i != policies.size(); i++) {
65: ps[i] = PolicyInformation.getInstance(policies
66: .getObjectAt(i));
67: }
68:
69: return ps;
70: }
71:
72: /**
73: * The definition of OtherSigningCertificate is
74: * <pre>
75: * OtherSigningCertificate ::= SEQUENCE {
76: * certs SEQUENCE OF OtherCertID,
77: * policies SEQUENCE OF PolicyInformation OPTIONAL
78: * }
79: * </pre>
80: * id-aa-ets-otherSigCert OBJECT IDENTIFIER ::= { iso(1)
81: * member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs9(9)
82: * smime(16) id-aa(2) 19 }
83: */
84: public DERObject toASN1Object() {
85: ASN1EncodableVector v = new ASN1EncodableVector();
86:
87: v.add(certs);
88:
89: if (policies != null) {
90: v.add(policies);
91: }
92:
93: return new DERSequence(v);
94: }
95: }
|