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