KickJava   Java API By Example, From Geeks To Geeks.

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


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.ASN1TaggedObject;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERSequence;
26
27 public class CRLDistPoint
28     extends ASN1Encodable
29 {
30     ASN1Sequence seq = null;
31
32     public static CRLDistPoint getInstance(
33         ASN1TaggedObject obj,
34         boolean explicit)
35     {
36         return getInstance(ASN1Sequence.getInstance(obj, explicit));
37     }
38
39     public static CRLDistPoint getInstance(
40         Object JavaDoc obj)
41     {
42         if (obj instanceof CRLDistPoint)
43         {
44             return (CRLDistPoint)obj;
45         }
46         else if (obj instanceof ASN1Sequence)
47         {
48             return new CRLDistPoint((ASN1Sequence)obj);
49         }
50
51         throw new IllegalArgumentException JavaDoc("unknown object in factory");
52     }
53
54     public CRLDistPoint(
55         ASN1Sequence seq)
56     {
57         this.seq = seq;
58     }
59
60     public CRLDistPoint(
61         DistributionPoint[] points)
62     {
63         ASN1EncodableVector v = new ASN1EncodableVector();
64
65         for (int i = 0; i != points.length; i++)
66         {
67             v.add(points[i]);
68         }
69
70         seq = new DERSequence(v);
71     }
72
73     /**
74      * Return the distribution points making up the sequence.
75      *
76      * @return DistributionPoint[]
77      */

78     public DistributionPoint[] getDistributionPoints()
79     {
80         DistributionPoint[] dp = new DistributionPoint[seq.size()];
81
82         for (int i = 0; i != seq.size(); i++)
83         {
84             dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i));
85         }
86
87         return dp;
88     }
89
90     /**
91      * Produce an object suitable for an ASN1OutputStream.
92      * <pre>
93      * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint
94      * </pre>
95      */

96     public DERObject toASN1Object()
97     {
98         return seq;
99     }
100 }
101
Popular Tags