KickJava   Java API By Example, From Geeks To Geeks.

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


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 AuthorityInformationAccess object.
29  * <pre>
30  * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
31  *
32  * AuthorityInfoAccessSyntax ::=
33  * SEQUENCE SIZE (1..MAX) OF AccessDescription
34  * AccessDescription ::= SEQUENCE {
35  * accessMethod OBJECT IDENTIFIER,
36  * accessLocation GeneralName }
37  *
38  * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
39  * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
40  * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
41  * </pre>
42  */

43 public class AuthorityInformationAccess
44     extends ASN1Encodable
45 {
46     private AccessDescription[] descriptions;
47
48     public static AuthorityInformationAccess getInstance(
49         Object JavaDoc obj)
50     {
51         if (obj instanceof AuthorityInformationAccess)
52         {
53             return (AuthorityInformationAccess)obj;
54         }
55         else if (obj instanceof ASN1Sequence)
56         {
57             return new AuthorityInformationAccess((ASN1Sequence)obj);
58         }
59
60         throw new IllegalArgumentException JavaDoc("unknown object in factory");
61     }
62
63     public AuthorityInformationAccess(
64         ASN1Sequence seq)
65     {
66         descriptions = new AccessDescription[seq.size()];
67
68         for (int i = 0; i != seq.size(); i++)
69         {
70             descriptions[i] = AccessDescription.getInstance(seq.getObjectAt(i));
71         }
72     }
73
74     /**
75      * create an AuthorityInformationAccess with the oid and location provided.
76      */

77     public AuthorityInformationAccess(
78         DERObjectIdentifier oid,
79         GeneralName location)
80     {
81         descriptions = new AccessDescription[1];
82
83         descriptions[0] = new AccessDescription(oid, location);
84     }
85
86
87     /**
88      *
89      * @return the access descriptions contained in this object.
90      */

91     public AccessDescription[] getAccessDescriptions()
92     {
93         return descriptions;
94     }
95
96     public DERObject toASN1Object()
97     {
98         ASN1EncodableVector vec = new ASN1EncodableVector();
99
100         for (int i = 0; i != descriptions.length; i++)
101         {
102             vec.add(descriptions[i]);
103         }
104
105         return new DERSequence(vec);
106     }
107
108     public String JavaDoc toString()
109     {
110         return ("AuthorityInformationAccess: Oid(" + this.descriptions[0].getAccessMethod().getId() + ")");
111     }
112 }
113
Popular Tags