1 20 package com.novosec.pkix.asn1.crmf; 21 22 import org.bouncycastle.asn1.ASN1TaggedObject; 23 import org.bouncycastle.asn1.DERBitString; 24 import org.bouncycastle.asn1.DEREncodable; 25 import org.bouncycastle.asn1.DERInteger; 26 import org.bouncycastle.asn1.DERObject; 27 import org.bouncycastle.asn1.DERTaggedObject; 28 29 47 public class POPOPrivKey implements DEREncodable 48 { 49 DEREncodable obj; 50 int tag; 51 52 public POPOPrivKey( DERObject obj, int tag ) 53 { 54 this.obj = obj; 55 this.tag = tag; 56 } 57 58 public DERBitString getThisMessage() 59 { 60 if( this.tag != 0 ) 61 return null; 62 return (DERBitString)this.obj; 63 } 64 65 public DERInteger getSubsequentMessage() 66 { 67 if( this.tag != 1 ) 68 return null; 69 return (DERInteger)this.obj; 70 } 71 72 public DERBitString getDhMAC() 73 { 74 if( this.tag != 2 ) 75 return null; 76 return (DERBitString)this.obj; 77 } 78 79 public static POPOPrivKey getInstance( DERObject obj ) 80 { 81 return getInstance( (ASN1TaggedObject)obj, true ); 82 } 83 84 public static POPOPrivKey getInstance( ASN1TaggedObject tagObj, boolean explicit ) 85 { 86 int tag = tagObj.getTagNo(); 87 88 switch (tag) 89 { 90 case 0: return new POPOPrivKey(DERBitString.getInstance(tagObj.getObject()), 0); 91 case 1: return new POPOPrivKey(DERInteger.getInstance(tagObj.getObject()), 1); 92 case 2: return new POPOPrivKey(DERBitString.getInstance(tagObj.getObject()), 2); 93 } 94 95 throw new IllegalArgumentException ("unknown tag: " + tag); 96 } 97 98 public DERObject getDERObject() 99 { 100 return new DERTaggedObject(true, tag, obj); 101 } 102 103 public String toString() 104 { 105 return "POPOPrivKey: (" + obj + ")"; 106 } 107 } 108 | Popular Tags |