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.DERBitString; 26 import org.bouncycastle.asn1.DEREncodable; 27 import org.bouncycastle.asn1.DERObject; 28 import org.bouncycastle.asn1.DERSequence; 29 import org.bouncycastle.asn1.x509.AlgorithmIdentifier; 30 31 41 public class PKMACValue implements DEREncodable 42 { 43 AlgorithmIdentifier algId; 44 DERBitString value; 45 46 public static PKMACValue getInstance( ASN1TaggedObject obj, boolean explicit ) 47 { 48 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 49 } 50 51 public static PKMACValue getInstance( Object obj ) 52 { 53 if (obj instanceof PKMACValue) 54 { 55 return (PKMACValue)obj; 56 } 57 else if (obj instanceof ASN1Sequence) 58 { 59 return new PKMACValue((ASN1Sequence)obj); 60 } 61 62 throw new IllegalArgumentException ("unknown object in factory"); 63 } 64 65 public PKMACValue( ASN1Sequence seq ) 66 { 67 this.algId = AlgorithmIdentifier.getInstance(seq.getObjectAt(0)); 68 this.value = DERBitString.getInstance(seq.getObjectAt(1)); 69 } 70 71 public PKMACValue( AlgorithmIdentifier algId, DERBitString value ) 72 { 73 this.algId = algId; 74 this.value = value; 75 } 76 77 public AlgorithmIdentifier getAlgId() 78 { 79 return algId; 80 } 81 82 public DERBitString getValue() 83 { 84 return value; 85 } 86 87 public DERObject getDERObject() 88 { 89 ASN1EncodableVector v = new ASN1EncodableVector(); 90 91 v.add( algId ); 92 v.add( value ); 93 94 return new DERSequence(v); 95 } 96 97 public String toString() 98 { 99 return "PKMACValue: (algId = " + this.getAlgId() + ", value = " + this.getValue() + ")"; 100 } 101 } 102 | Popular Tags |