CRLDistPoint.java revision bdb7b3d37025690a0434040b4e0d0623d9fa74af
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; 9import org.bouncycastle.util.Strings; 10 11public class CRLDistPoint 12 extends ASN1Object 13{ 14 ASN1Sequence seq = null; 15 16 public static CRLDistPoint getInstance( 17 ASN1TaggedObject obj, 18 boolean explicit) 19 { 20 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 21 } 22 23 public static CRLDistPoint getInstance( 24 Object obj) 25 { 26 if (obj instanceof CRLDistPoint) 27 { 28 return (CRLDistPoint)obj; 29 } 30 else if (obj != null) 31 { 32 return new CRLDistPoint(ASN1Sequence.getInstance(obj)); 33 } 34 35 return null; 36 } 37 38 private CRLDistPoint( 39 ASN1Sequence seq) 40 { 41 this.seq = seq; 42 } 43 44 public CRLDistPoint( 45 DistributionPoint[] points) 46 { 47 ASN1EncodableVector v = new ASN1EncodableVector(); 48 49 for (int i = 0; i != points.length; i++) 50 { 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 { 64 DistributionPoint[] dp = new DistributionPoint[seq.size()]; 65 66 for (int i = 0; i != seq.size(); i++) 67 { 68 dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i)); 69 } 70 71 return dp; 72 } 73 74 /** 75 * Produce an object suitable for an ASN1OutputStream. 76 * <pre> 77 * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint 78 * </pre> 79 */ 80 public ASN1Primitive toASN1Primitive() 81 { 82 return seq; 83 } 84 85 public String toString() 86 { 87 StringBuffer buf = new StringBuffer(); 88 String sep = Strings.lineSeparator(); 89 90 buf.append("CRLDistPoint:"); 91 buf.append(sep); 92 DistributionPoint dp[] = getDistributionPoints(); 93 for (int i = 0; i != dp.length; i++) 94 { 95 buf.append(" "); 96 buf.append(dp[i]); 97 buf.append(sep); 98 } 99 return buf.toString(); 100 } 101} 102