1package org.bouncycastle.asn1.x509; 2 3import org.bouncycastle.asn1.ASN1EncodableVector; 4import org.bouncycastle.asn1.ASN1Object; 5import org.bouncycastle.asn1.ASN1Primitive; 6import org.bouncycastle.asn1.ASN1Sequence; 7import org.bouncycastle.asn1.ASN1TaggedObject; 8import org.bouncycastle.asn1.DERSequence; 9 10public class CRLDistPoint 11 extends ASN1Object 12{ 13 ASN1Sequence seq = null; 14 15 public static CRLDistPoint getInstance( 16 ASN1TaggedObject obj, 17 boolean explicit) 18 { 19 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 20 } 21 22 public static CRLDistPoint getInstance( 23 Object obj) 24 { 25 if (obj instanceof CRLDistPoint) 26 { 27 return (CRLDistPoint)obj; 28 } 29 else if (obj != null) 30 { 31 return new CRLDistPoint(ASN1Sequence.getInstance(obj)); 32 } 33 34 return null; 35 } 36 37 private CRLDistPoint( 38 ASN1Sequence seq) 39 { 40 this.seq = seq; 41 } 42 43 public CRLDistPoint( 44 DistributionPoint[] points) 45 { 46 ASN1EncodableVector v = new ASN1EncodableVector(); 47 48 for (int i = 0; i != points.length; i++) 49 { 50 v.add(points[i]); 51 } 52 53 seq = new DERSequence(v); 54 } 55 56 /** 57 * Return the distribution points making up the sequence. 58 * 59 * @return DistributionPoint[] 60 */ 61 public DistributionPoint[] getDistributionPoints() 62 { 63 DistributionPoint[] dp = new DistributionPoint[seq.size()]; 64 65 for (int i = 0; i != seq.size(); i++) 66 { 67 dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i)); 68 } 69 70 return dp; 71 } 72 73 /** 74 * Produce an object suitable for an ASN1OutputStream. 75 * <pre> 76 * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint 77 * </pre> 78 */ 79 public ASN1Primitive toASN1Primitive() 80 { 81 return seq; 82 } 83 84 public String toString() 85 { 86 StringBuffer buf = new StringBuffer(); 87 String sep = System.getProperty("line.separator"); 88 89 buf.append("CRLDistPoint:"); 90 buf.append(sep); 91 DistributionPoint dp[] = getDistributionPoints(); 92 for (int i = 0; i != dp.length; i++) 93 { 94 buf.append(" "); 95 buf.append(dp[i]); 96 buf.append(sep); 97 } 98 return buf.toString(); 99 } 100} 101