001package org.apache.commons.ssl.org.bouncycastle.asn1.esf;
002
003import java.io.IOException;
004
005import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Encodable;
006import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1EncodableVector;
007import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Encoding;
008import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object;
009import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1ObjectIdentifier;
010import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive;
011import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Sequence;
012import org.apache.commons.ssl.org.bouncycastle.asn1.DERSequence;
013
014/**
015 * <pre>
016 * OtherRevVals ::= SEQUENCE {
017 *    otherRevValType OtherRevValType,
018 *    otherRevVals ANY DEFINED BY OtherRevValType
019 * }
020 *
021 * OtherRevValType ::= OBJECT IDENTIFIER
022 * </pre>
023 */
024public class OtherRevVals
025    extends ASN1Object
026{
027
028    private ASN1ObjectIdentifier otherRevValType;
029
030    private ASN1Encodable otherRevVals;
031
032    public static OtherRevVals getInstance(Object obj)
033    {
034        if (obj instanceof OtherRevVals)
035        {
036            return (OtherRevVals)obj;
037        }
038        if (obj != null)
039        {
040            return new OtherRevVals(ASN1Sequence.getInstance(obj));
041        }
042
043        return null;
044    }
045
046    private OtherRevVals(ASN1Sequence seq)
047    {
048        if (seq.size() != 2)
049        {
050            throw new IllegalArgumentException("Bad sequence size: "
051                + seq.size());
052        }
053        this.otherRevValType = (ASN1ObjectIdentifier)seq.getObjectAt(0);
054        try
055        {
056            this.otherRevVals = ASN1Primitive.fromByteArray(seq.getObjectAt(1)
057                .toASN1Primitive().getEncoded(ASN1Encoding.DER));
058        }
059        catch (IOException e)
060        {
061            throw new IllegalStateException();
062        }
063    }
064
065    public OtherRevVals(ASN1ObjectIdentifier otherRevValType,
066                        ASN1Encodable otherRevVals)
067    {
068        this.otherRevValType = otherRevValType;
069        this.otherRevVals = otherRevVals;
070    }
071
072    public ASN1ObjectIdentifier getOtherRevValType()
073    {
074        return this.otherRevValType;
075    }
076
077    public ASN1Encodable getOtherRevVals()
078    {
079        return this.otherRevVals;
080    }
081
082    public ASN1Primitive toASN1Primitive()
083    {
084        ASN1EncodableVector v = new ASN1EncodableVector();
085        v.add(this.otherRevValType);
086        v.add(this.otherRevVals);
087        return new DERSequence(v);
088    }
089}