diff options
author | Adam Vartanian <flooey@google.com> | 2019-02-14 14:42:19 +0000 |
---|---|---|
committer | Adam Vartanian <flooey@google.com> | 2019-02-18 10:18:52 +0000 |
commit | 27254450f01adef5f4bb25a648d42eeacc14c438 (patch) | |
tree | 90eb8fa6c24a44780cc4c4be2d50555f955d29f4 /bcprov/src/main/java/org/bouncycastle/asn1/x509/OtherName.java | |
parent | bdfb209e7c1139588c82722a809c46667775a314 (diff) | |
parent | 1b335c5efbcf241b55345622fe9978047c3fdf9e (diff) | |
download | bouncycastle-27254450f01adef5f4bb25a648d42eeacc14c438.tar.gz |
Update Bouncy Castle to 1.61
Test: cts -m CtsLibcoreTestCases
Test: cts -m CtsLibcoreWycheproofBCTestCases
Change-Id: Ifcd182a8537439b945aedf80741bd51cbce37e49
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/asn1/x509/OtherName.java')
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/asn1/x509/OtherName.java | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/asn1/x509/OtherName.java b/bcprov/src/main/java/org/bouncycastle/asn1/x509/OtherName.java new file mode 100644 index 00000000..eb652f7f --- /dev/null +++ b/bcprov/src/main/java/org/bouncycastle/asn1/x509/OtherName.java @@ -0,0 +1,92 @@ +package org.bouncycastle.asn1.x509; + +import org.bouncycastle.asn1.ASN1Encodable; +import org.bouncycastle.asn1.ASN1EncodableVector; +import org.bouncycastle.asn1.ASN1Object; +import org.bouncycastle.asn1.ASN1ObjectIdentifier; +import org.bouncycastle.asn1.ASN1Primitive; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.ASN1TaggedObject; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERTaggedObject; + +/** + * The OtherName object. + * <pre> + * OtherName ::= SEQUENCE { + * type-id OBJECT IDENTIFIER, + * value [0] EXPLICIT ANY DEFINED BY type-id } + * </pre> + */ +public class OtherName + extends ASN1Object +{ + private final ASN1ObjectIdentifier typeID; + private final ASN1Encodable value; + + /** + * OtherName factory method. + * @param obj the object used to construct an instance of <code> + * OtherName</code>. It must be an instance of <code>OtherName + * </code> or <code>ASN1Sequence</code>. + * @return the instance of <code>OtherName</code> built from the + * supplied object. + * @throws java.lang.IllegalArgumentException if the object passed + * to the factory is not an instance of <code>OtherName</code> or something that + * can be converted into an appropriate <code>ASN1Sequence</code>. + */ + public static OtherName getInstance( + Object obj) + { + + if (obj instanceof OtherName) + { + return (OtherName)obj; + } + else if (obj != null) + { + return new OtherName(ASN1Sequence.getInstance(obj)); + } + + return null; + } + + /** + * Base constructor. + * @param typeID the type of the other name. + * @param value the ANY object that represents the value. + */ + public OtherName( + ASN1ObjectIdentifier typeID, + ASN1Encodable value) + { + this.typeID = typeID; + this.value = value; + } + + private OtherName(ASN1Sequence seq) + { + this.typeID = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); + this.value = ASN1TaggedObject.getInstance(seq.getObjectAt(1)).getObject(); // explicitly tagged + } + + public ASN1ObjectIdentifier getTypeID() + { + return typeID; + } + + public ASN1Encodable getValue() + { + return value; + } + + public ASN1Primitive toASN1Primitive() + { + ASN1EncodableVector v = new ASN1EncodableVector(); + + v.add(typeID); + v.add(new DERTaggedObject(true, 0, value)); + + return new DERSequence(v); + } +} |