KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > x509 > AccessDescription


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17
18 package org.apache.geronimo.util.asn1.x509;
19
20 import org.apache.geronimo.util.asn1.ASN1Encodable;
21 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
22 import org.apache.geronimo.util.asn1.ASN1Sequence;
23 import org.apache.geronimo.util.asn1.DERObject;
24 import org.apache.geronimo.util.asn1.DERObjectIdentifier;
25 import org.apache.geronimo.util.asn1.DERSequence;
26
27 /**
28  * The AccessDescription object.
29  * <pre>
30  * AccessDescription ::= SEQUENCE {
31  * accessMethod OBJECT IDENTIFIER,
32  * accessLocation GeneralName }
33  * </pre>
34  */

35 public class AccessDescription
36     extends ASN1Encodable
37 {
38     DERObjectIdentifier accessMethod = null;
39     GeneralName accessLocation = null;
40
41     public static AccessDescription getInstance(
42         Object JavaDoc obj)
43     {
44         if (obj instanceof AccessDescription)
45         {
46             return (AccessDescription)obj;
47         }
48         else if (obj instanceof ASN1Sequence)
49         {
50             return new AccessDescription((ASN1Sequence)obj);
51         }
52
53         throw new IllegalArgumentException JavaDoc("unknown object in factory");
54     }
55
56     public AccessDescription(
57         ASN1Sequence seq)
58     {
59         if (seq.size() != 2)
60         {
61             throw new IllegalArgumentException JavaDoc("wrong number of elements in inner sequence");
62         }
63
64         accessMethod = (DERObjectIdentifier)seq.getObjectAt(0);
65         accessLocation = GeneralName.getInstance(seq.getObjectAt(1));
66     }
67
68     /**
69      * create an AccessDescription with the oid and location provided.
70      */

71     public AccessDescription(
72         DERObjectIdentifier oid,
73         GeneralName location)
74     {
75         accessMethod = oid;
76         accessLocation = location;
77     }
78
79     /**
80      *
81      * @return the access method.
82      */

83     public DERObjectIdentifier getAccessMethod()
84     {
85         return accessMethod;
86     }
87
88     /**
89      *
90      * @return the access location
91      */

92     public GeneralName getAccessLocation()
93     {
94         return accessLocation;
95     }
96
97     public DERObject toASN1Object()
98     {
99         ASN1EncodableVector accessDescription = new ASN1EncodableVector();
100
101         accessDescription.add(accessMethod);
102         accessDescription.add(accessLocation);
103
104         return new DERSequence(accessDescription);
105     }
106
107     public String JavaDoc toString()
108     {
109         return ("AccessDescription: Oid(" + this.accessMethod.getId() + ")");
110     }
111 }
112
Popular Tags