01: package org.bouncycastle.asn1.x509;
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.DERObjectIdentifier;
08: import org.bouncycastle.asn1.DERSequence;
09:
10: /**
11: * The AuthorityInformationAccess object.
12: * <pre>
13: * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
14: *
15: * AuthorityInfoAccessSyntax ::=
16: * SEQUENCE SIZE (1..MAX) OF AccessDescription
17: * AccessDescription ::= SEQUENCE {
18: * accessMethod OBJECT IDENTIFIER,
19: * accessLocation GeneralName }
20: *
21: * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
22: * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
23: * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
24: * </pre>
25: */
26: public class AuthorityInformationAccess extends ASN1Encodable {
27: private AccessDescription[] descriptions;
28:
29: public static AuthorityInformationAccess getInstance(Object obj) {
30: if (obj instanceof AuthorityInformationAccess) {
31: return (AuthorityInformationAccess) obj;
32: }
33:
34: if (obj instanceof ASN1Sequence) {
35: return new AuthorityInformationAccess((ASN1Sequence) obj);
36: }
37:
38: if (obj instanceof X509Extension) {
39: return getInstance(X509Extension
40: .convertValueToObject((X509Extension) obj));
41: }
42:
43: throw new IllegalArgumentException("unknown object in factory");
44: }
45:
46: public AuthorityInformationAccess(ASN1Sequence seq) {
47: descriptions = new AccessDescription[seq.size()];
48:
49: for (int i = 0; i != seq.size(); i++) {
50: descriptions[i] = AccessDescription.getInstance(seq
51: .getObjectAt(i));
52: }
53: }
54:
55: /**
56: * create an AuthorityInformationAccess with the oid and location provided.
57: */
58: public AuthorityInformationAccess(DERObjectIdentifier oid,
59: GeneralName location) {
60: descriptions = new AccessDescription[1];
61:
62: descriptions[0] = new AccessDescription(oid, location);
63: }
64:
65: /**
66: *
67: * @return the access descriptions contained in this object.
68: */
69: public AccessDescription[] getAccessDescriptions() {
70: return descriptions;
71: }
72:
73: public DERObject toASN1Object() {
74: ASN1EncodableVector vec = new ASN1EncodableVector();
75:
76: for (int i = 0; i != descriptions.length; i++) {
77: vec.add(descriptions[i]);
78: }
79:
80: return new DERSequence(vec);
81: }
82:
83: public String toString() {
84: return ("AuthorityInformationAccess: Oid("
85: + this .descriptions[0].getAccessMethod().getId() + ")");
86: }
87: }
|