1 17 18 package org.apache.geronimo.util.asn1.x509; 19 20 import org.apache.geronimo.util.asn1.ASN1Encodable; 21 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 22 import org.apache.geronimo.util.asn1.ASN1Sequence; 23 import org.apache.geronimo.util.asn1.ASN1TaggedObject; 24 import org.apache.geronimo.util.asn1.DERBitString; 25 import org.apache.geronimo.util.asn1.DERObject; 26 import org.apache.geronimo.util.asn1.DERSequence; 27 import org.apache.geronimo.util.asn1.DERTaggedObject; 28 29 39 public class DistributionPoint 40 extends ASN1Encodable 41 { 42 DistributionPointName distributionPoint; 43 ReasonFlags reasons; 44 GeneralNames cRLIssuer; 45 46 public static DistributionPoint getInstance( 47 ASN1TaggedObject obj, 48 boolean explicit) 49 { 50 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 51 } 52 53 public static DistributionPoint getInstance( 54 Object obj) 55 { 56 if(obj == null || obj instanceof DistributionPoint) 57 { 58 return (DistributionPoint)obj; 59 } 60 61 if(obj instanceof ASN1Sequence) 62 { 63 return new DistributionPoint((ASN1Sequence)obj); 64 } 65 66 throw new IllegalArgumentException ("Invalid DistributionPoint: " + obj.getClass().getName()); 67 } 68 69 public DistributionPoint( 70 ASN1Sequence seq) 71 { 72 for (int i = 0; i != seq.size(); i++) 73 { 74 ASN1TaggedObject t = (ASN1TaggedObject)seq.getObjectAt(i); 75 switch (t.getTagNo()) 76 { 77 case 0: 78 distributionPoint = DistributionPointName.getInstance(t, true); 79 break; 80 case 1: 81 reasons = new ReasonFlags(DERBitString.getInstance(t, false)); 82 break; 83 case 2: 84 cRLIssuer = GeneralNames.getInstance(t, false); 85 } 86 } 87 } 88 89 public DistributionPoint( 90 DistributionPointName distributionPoint, 91 ReasonFlags reasons, 92 GeneralNames cRLIssuer) 93 { 94 this.distributionPoint = distributionPoint; 95 this.reasons = reasons; 96 this.cRLIssuer = cRLIssuer; 97 } 98 99 public DistributionPointName getDistributionPoint() 100 { 101 return distributionPoint; 102 } 103 104 public ReasonFlags getReasons() 105 { 106 return reasons; 107 } 108 109 public GeneralNames getCRLIssuer() 110 { 111 return cRLIssuer; 112 } 113 114 public DERObject toASN1Object() 115 { 116 ASN1EncodableVector v = new ASN1EncodableVector(); 117 118 if (distributionPoint != null) 119 { 120 v.add(new DERTaggedObject(0, distributionPoint)); 124 } 125 126 if (reasons != null) 127 { 128 v.add(new DERTaggedObject(false, 1, reasons)); 129 } 130 131 if (cRLIssuer != null) 132 { 133 v.add(new DERTaggedObject(false, 2, cRLIssuer)); 134 } 135 136 return new DERSequence(v); 137 } 138 } 139 | Popular Tags |