1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.geronimo.util.asn1.x509;
20
21 import org.apache.geronimo.util.asn1.ASN1Encodable;
22 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
23 import org.apache.geronimo.util.asn1.ASN1Sequence;
24 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
25 import org.apache.geronimo.util.asn1.DERObject;
26 import org.apache.geronimo.util.asn1.DERSequence;
27
28 public class CRLDistPoint
29 extends ASN1Encodable
30 {
31 ASN1Sequence seq = null;
32
33 public static CRLDistPoint getInstance(
34 ASN1TaggedObject obj,
35 boolean explicit)
36 {
37 return getInstance(ASN1Sequence.getInstance(obj, explicit));
38 }
39
40 public static CRLDistPoint getInstance(
41 Object obj)
42 {
43 if (obj instanceof CRLDistPoint)
44 {
45 return (CRLDistPoint)obj;
46 }
47 else if (obj instanceof ASN1Sequence)
48 {
49 return new CRLDistPoint((ASN1Sequence)obj);
50 }
51
52 throw new IllegalArgumentException("unknown object in factory");
53 }
54
55 public CRLDistPoint(
56 ASN1Sequence seq)
57 {
58 this.seq = seq;
59 }
60
61 public CRLDistPoint(
62 DistributionPoint[] points)
63 {
64 ASN1EncodableVector v = new ASN1EncodableVector();
65
66 for (int i = 0; i != points.length; i++)
67 {
68 v.add(points[i]);
69 }
70
71 seq = new DERSequence(v);
72 }
73
74 /**
75 * Return the distribution points making up the sequence.
76 *
77 * @return DistributionPoint[]
78 */
79 public DistributionPoint[] getDistributionPoints()
80 {
81 DistributionPoint[] dp = new DistributionPoint[seq.size()];
82
83 for (int i = 0; i != seq.size(); i++)
84 {
85 dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i));
86 }
87
88 return dp;
89 }
90
91 /**
92 * Produce an object suitable for an ASN1OutputStream.
93 * <pre>
94 * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint
95 * </pre>
96 */
97 public DERObject toASN1Object()
98 {
99 return seq;
100 }
101 }