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 AccessDescription object.
12: * <pre>
13: * AccessDescription ::= SEQUENCE {
14: * accessMethod OBJECT IDENTIFIER,
15: * accessLocation GeneralName }
16: * </pre>
17: */
18: public class AccessDescription extends ASN1Encodable {
19: public final static DERObjectIdentifier id_ad_caIssuers = new DERObjectIdentifier(
20: "1.3.6.1.5.5.7.48.2");
21:
22: public final static DERObjectIdentifier id_ad_ocsp = new DERObjectIdentifier(
23: "1.3.6.1.5.5.7.48.1");
24:
25: DERObjectIdentifier accessMethod = null;
26: GeneralName accessLocation = null;
27:
28: public static AccessDescription getInstance(Object obj) {
29: if (obj instanceof AccessDescription) {
30: return (AccessDescription) obj;
31: } else if (obj instanceof ASN1Sequence) {
32: return new AccessDescription((ASN1Sequence) obj);
33: }
34:
35: throw new IllegalArgumentException("unknown object in factory");
36: }
37:
38: public AccessDescription(ASN1Sequence seq) {
39: if (seq.size() != 2) {
40: throw new IllegalArgumentException(
41: "wrong number of elements in inner sequence");
42: }
43:
44: accessMethod = DERObjectIdentifier.getInstance(seq
45: .getObjectAt(0));
46: accessLocation = GeneralName.getInstance(seq.getObjectAt(1));
47: }
48:
49: /**
50: * create an AccessDescription with the oid and location provided.
51: */
52: public AccessDescription(DERObjectIdentifier oid,
53: GeneralName location) {
54: accessMethod = oid;
55: accessLocation = location;
56: }
57:
58: /**
59: *
60: * @return the access method.
61: */
62: public DERObjectIdentifier getAccessMethod() {
63: return accessMethod;
64: }
65:
66: /**
67: *
68: * @return the access location
69: */
70: public GeneralName getAccessLocation() {
71: return accessLocation;
72: }
73:
74: public DERObject toASN1Object() {
75: ASN1EncodableVector accessDescription = new ASN1EncodableVector();
76:
77: accessDescription.add(accessMethod);
78: accessDescription.add(accessLocation);
79:
80: return new DERSequence(accessDescription);
81: }
82:
83: public String toString() {
84: return ("AccessDescription: Oid(" + this .accessMethod.getId() + ")");
85: }
86: }
|