1 package org.bouncycastle.asn1.x9; 2 3 import org.bouncycastle.asn1.ASN1Encodable; 4 import org.bouncycastle.asn1.ASN1TaggedObject; 5 import org.bouncycastle.asn1.DERInteger; 6 import org.bouncycastle.asn1.DERObject; 7 8 public class DHPublicKey 9 extends ASN1Encodable 10 { 11 private DERInteger y; 12 13 public static DHPublicKey getInstance(ASN1TaggedObject obj, boolean explicit) 14 { 15 return getInstance(DERInteger.getInstance(obj, explicit)); 16 } 17 18 public static DHPublicKey getInstance(Object obj) 19 { 20 if (obj == null || obj instanceof DHPublicKey) 21 { 22 return (DHPublicKey)obj; 23 } 24 25 if (obj instanceof DERInteger) 26 { 27 return new DHPublicKey((DERInteger)obj); 28 } 29 30 throw new IllegalArgumentException("Invalid DHPublicKey: " + obj.getClass().getName()); 31 } 32 33 public DHPublicKey(DERInteger y) 34 { 35 if (y == null) 36 { 37 throw new IllegalArgumentException("'y' cannot be null"); 38 } 39 40 this.y = y; 41 } 42 43 public DERInteger getY() 44 { 45 return this.y; 46 } 47 48 public DERObject toASN1Object() 49 { 50 return this.y; 51 } 52 } 53