01: package org.bouncycastle.asn1.x509;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.ASN1TaggedObject;
07: import org.bouncycastle.asn1.DERObject;
08: import org.bouncycastle.asn1.DERSequence;
09:
10: public class CRLDistPoint extends ASN1Encodable {
11: ASN1Sequence seq = null;
12:
13: public static CRLDistPoint getInstance(ASN1TaggedObject obj,
14: boolean explicit) {
15: return getInstance(ASN1Sequence.getInstance(obj, explicit));
16: }
17:
18: public static CRLDistPoint getInstance(Object obj) {
19: if (obj instanceof CRLDistPoint || obj == null) {
20: return (CRLDistPoint) obj;
21: } else if (obj instanceof ASN1Sequence) {
22: return new CRLDistPoint((ASN1Sequence) obj);
23: }
24:
25: throw new IllegalArgumentException("unknown object in factory");
26: }
27:
28: public CRLDistPoint(ASN1Sequence seq) {
29: this .seq = seq;
30: }
31:
32: public CRLDistPoint(DistributionPoint[] points) {
33: ASN1EncodableVector v = new ASN1EncodableVector();
34:
35: for (int i = 0; i != points.length; i++) {
36: v.add(points[i]);
37: }
38:
39: seq = new DERSequence(v);
40: }
41:
42: /**
43: * Return the distribution points making up the sequence.
44: *
45: * @return DistributionPoint[]
46: */
47: public DistributionPoint[] getDistributionPoints() {
48: DistributionPoint[] dp = new DistributionPoint[seq.size()];
49:
50: for (int i = 0; i != seq.size(); i++) {
51: dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i));
52: }
53:
54: return dp;
55: }
56:
57: /**
58: * Produce an object suitable for an ASN1OutputStream.
59: * <pre>
60: * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint
61: * </pre>
62: */
63: public DERObject toASN1Object() {
64: return seq;
65: }
66:
67: public String toString() {
68: StringBuffer buf = new StringBuffer();
69: String sep = System.getProperty("line.separator");
70:
71: buf.append("CRLDistPoint:");
72: buf.append(sep);
73: DistributionPoint dp[] = getDistributionPoints();
74: for (int i = 0; i != dp.length; i++) {
75: buf.append(" ");
76: buf.append(dp[i]);
77: buf.append(sep);
78: }
79: return buf.toString();
80: }
81: }
|