66import org .bouncycastle .asn1 .ASN1Primitive ;
77import org .bouncycastle .asn1 .ASN1Set ;
88import org .bouncycastle .asn1 .ASN1TaggedObject ;
9+ import org .bouncycastle .asn1 .ASN1Util ;
910import org .bouncycastle .asn1 .DERTaggedObject ;
1011import org .bouncycastle .util .Strings ;
1112
@@ -22,21 +23,10 @@ public class DistributionPointName
2223 extends ASN1Object
2324 implements ASN1Choice
2425{
25- ASN1Encodable name ;
26- int type ;
27-
2826 public static final int FULL_NAME = 0 ;
2927 public static final int NAME_RELATIVE_TO_CRL_ISSUER = 1 ;
3028
31- public static DistributionPointName getInstance (
32- ASN1TaggedObject obj ,
33- boolean explicit )
34- {
35- return getInstance (ASN1TaggedObject .getInstance (obj , true ));
36- }
37-
38- public static DistributionPointName getInstance (
39- Object obj )
29+ public static DistributionPointName getInstance (Object obj )
4030 {
4131 if (obj == null || obj instanceof DistributionPointName )
4232 {
@@ -50,6 +40,19 @@ else if (obj instanceof ASN1TaggedObject)
5040 throw new IllegalArgumentException ("unknown object in factory: " + obj .getClass ().getName ());
5141 }
5242
43+ public static DistributionPointName getInstance (ASN1TaggedObject taggedObject , boolean declaredExplicit )
44+ {
45+ return getInstance (ASN1Util .getInstanceChoiceBaseObject (taggedObject , declaredExplicit , "DistributionPointName" ));
46+ }
47+
48+ public static DistributionPointName getTagged (ASN1TaggedObject taggedObject , boolean declaredExplicit )
49+ {
50+ return getInstance (ASN1Util .getTaggedChoiceBaseObject (taggedObject , declaredExplicit , "DistributionPointName" ));
51+ }
52+
53+ private final ASN1Encodable name ;
54+ private final int type ;
55+
5356 public DistributionPointName (
5457 int type ,
5558 ASN1Encodable name )
@@ -83,22 +86,25 @@ public ASN1Encodable getName()
8386 {
8487 return (ASN1Encodable )name ;
8588 }
86-
87- public DistributionPointName (
88- ASN1TaggedObject obj )
89+
90+ public DistributionPointName (ASN1TaggedObject obj )
8991 {
9092 this .type = obj .getTagNo ();
91-
92- if (type == 0 )
93+
94+ if (obj . hasContextTag ( FULL_NAME ) )
9395 {
9496 this .name = GeneralNames .getInstance (obj , false );
9597 }
96- else
98+ else if ( obj . hasContextTag ( NAME_RELATIVE_TO_CRL_ISSUER ))
9799 {
98100 this .name = ASN1Set .getInstance (obj , false );
99101 }
102+ else
103+ {
104+ throw new IllegalArgumentException ("unknown tag: " + ASN1Util .getTagText (obj ));
105+ }
100106 }
101-
107+
102108 public ASN1Primitive toASN1Primitive ()
103109 {
104110 return new DERTaggedObject (false , type , name );
0 commit comments