001package org.apache.commons.ssl.org.bouncycastle.asn1.x509; 002 003import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1EncodableVector; 004import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object; 005import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive; 006import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Sequence; 007import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1TaggedObject; 008import org.apache.commons.ssl.org.bouncycastle.asn1.DERSequence; 009 010public class CRLDistPoint 011 extends ASN1Object 012{ 013 ASN1Sequence seq = null; 014 015 public static CRLDistPoint getInstance( 016 ASN1TaggedObject obj, 017 boolean explicit) 018 { 019 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 020 } 021 022 public static CRLDistPoint getInstance( 023 Object obj) 024 { 025 if (obj instanceof CRLDistPoint) 026 { 027 return (CRLDistPoint)obj; 028 } 029 else if (obj != null) 030 { 031 return new CRLDistPoint(ASN1Sequence.getInstance(obj)); 032 } 033 034 return null; 035 } 036 037 private CRLDistPoint( 038 ASN1Sequence seq) 039 { 040 this.seq = seq; 041 } 042 043 public CRLDistPoint( 044 DistributionPoint[] points) 045 { 046 ASN1EncodableVector v = new ASN1EncodableVector(); 047 048 for (int i = 0; i != points.length; i++) 049 { 050 v.add(points[i]); 051 } 052 053 seq = new DERSequence(v); 054 } 055 056 /** 057 * Return the distribution points making up the sequence. 058 * 059 * @return DistributionPoint[] 060 */ 061 public DistributionPoint[] getDistributionPoints() 062 { 063 DistributionPoint[] dp = new DistributionPoint[seq.size()]; 064 065 for (int i = 0; i != seq.size(); i++) 066 { 067 dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i)); 068 } 069 070 return dp; 071 } 072 073 /** 074 * Produce an object suitable for an ASN1OutputStream. 075 * <pre> 076 * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint 077 * </pre> 078 */ 079 public ASN1Primitive toASN1Primitive() 080 { 081 return seq; 082 } 083 084 public String toString() 085 { 086 StringBuffer buf = new StringBuffer(); 087 String sep = System.getProperty("line.separator"); 088 089 buf.append("CRLDistPoint:"); 090 buf.append(sep); 091 DistributionPoint dp[] = getDistributionPoints(); 092 for (int i = 0; i != dp.length; i++) 093 { 094 buf.append(" "); 095 buf.append(dp[i]); 096 buf.append(sep); 097 } 098 return buf.toString(); 099 } 100}