1 20 package com.novosec.pkix.asn1.crmf; 21 22 import org.bouncycastle.asn1.ASN1EncodableVector; 23 import org.bouncycastle.asn1.ASN1Sequence; 24 import org.bouncycastle.asn1.ASN1TaggedObject; 25 import org.bouncycastle.asn1.DEREncodable; 26 import org.bouncycastle.asn1.DERInteger; 27 import org.bouncycastle.asn1.DERObject; 28 import org.bouncycastle.asn1.DERSequence; 29 import org.bouncycastle.asn1.x509.GeneralName; 30 31 45 public class SinglePubInfo implements DEREncodable 46 { 47 DERInteger pubMethod; 48 GeneralName pubLocation; 49 50 public static SinglePubInfo getInstance( ASN1TaggedObject obj, boolean explicit ) 51 { 52 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 53 } 54 55 public static SinglePubInfo getInstance( Object obj ) 56 { 57 if (obj instanceof SinglePubInfo) 58 { 59 return (SinglePubInfo)obj; 60 } 61 else if (obj instanceof ASN1Sequence) 62 { 63 return new SinglePubInfo((ASN1Sequence)obj); 64 } 65 66 throw new IllegalArgumentException ("unknown object in factory"); 67 } 68 69 public SinglePubInfo( ASN1Sequence seq ) 70 { 71 this.pubMethod = DERInteger.getInstance(seq.getObjectAt(0)); 72 73 if( seq.size()>1 ) 74 this.pubLocation = GeneralName.getInstance((ASN1TaggedObject)seq.getObjectAt(1),true); } 76 77 public SinglePubInfo( DERInteger pubMethod ) 78 { 79 this.pubMethod = pubMethod; 80 } 81 82 public DERInteger getPubMethod() 83 { 84 return pubMethod; 85 } 86 87 public GeneralName getPubLocation() 88 { 89 return pubLocation; 90 } 91 92 public void setPubLocation(GeneralName pubLocation) 93 { 94 this.pubLocation = pubLocation; 95 } 96 97 public DERObject getDERObject() 98 { 99 ASN1EncodableVector v = new ASN1EncodableVector(); 100 101 v.add( pubMethod ); 102 103 if( pubLocation != null ) 104 v.add( pubLocation ); 105 106 return new DERSequence(v); 107 } 108 109 public String toString() 110 { 111 String s = "SinglePubInfo: (pubMethod = " + this.getPubMethod() + ", "; 112 113 if( this.getPubLocation() != null ) 114 s += "pubLocation = " + this.getPubLocation(); 115 116 s += ")"; 117 118 return s; 119 } 120 } 121 | Popular Tags |