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