01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.crypto.asn1.x509;
17:
18: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
19: import org.apache.geronimo.crypto.asn1.ASN1EncodableVector;
20: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
21: import org.apache.geronimo.crypto.asn1.DERObject;
22: import org.apache.geronimo.crypto.asn1.DERObjectIdentifier;
23: import org.apache.geronimo.crypto.asn1.DERSequence;
24:
25: /**
26: * The AuthorityInformationAccess object.
27: * <pre>
28: * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
29: *
30: * AuthorityInfoAccessSyntax ::=
31: * SEQUENCE SIZE (1..MAX) OF AccessDescription
32: * AccessDescription ::= SEQUENCE {
33: * accessMethod OBJECT IDENTIFIER,
34: * accessLocation GeneralName }
35: *
36: * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
37: * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
38: * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
39: * </pre>
40: */
41: public class AuthorityInformationAccess extends ASN1Encodable {
42: private AccessDescription[] descriptions;
43:
44: public static AuthorityInformationAccess getInstance(Object obj) {
45: if (obj instanceof AuthorityInformationAccess) {
46: return (AuthorityInformationAccess) obj;
47: } else if (obj instanceof ASN1Sequence) {
48: return new AuthorityInformationAccess((ASN1Sequence) obj);
49: }
50:
51: throw new IllegalArgumentException("unknown object in factory");
52: }
53:
54: public AuthorityInformationAccess(ASN1Sequence seq) {
55: descriptions = new AccessDescription[seq.size()];
56:
57: for (int i = 0; i != seq.size(); i++) {
58: descriptions[i] = AccessDescription.getInstance(seq
59: .getObjectAt(i));
60: }
61: }
62:
63: /**
64: * create an AuthorityInformationAccess with the oid and location provided.
65: */
66: public AuthorityInformationAccess(DERObjectIdentifier oid,
67: GeneralName location) {
68: descriptions = new AccessDescription[1];
69:
70: descriptions[0] = new AccessDescription(oid, location);
71: }
72:
73: /**
74: *
75: * @return the access descriptions contained in this object.
76: */
77: public AccessDescription[] getAccessDescriptions() {
78: return descriptions;
79: }
80:
81: public DERObject toASN1Object() {
82: ASN1EncodableVector vec = new ASN1EncodableVector();
83:
84: for (int i = 0; i != descriptions.length; i++) {
85: vec.add(descriptions[i]);
86: }
87:
88: return new DERSequence(vec);
89: }
90:
91: public String toString() {
92: return ("AuthorityInformationAccess: Oid("
93: + this .descriptions[0].getAccessMethod().getId() + ")");
94: }
95: }
|