// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.asn1.pkcs;

import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Object;

public class CertBag extends ASN1Object
{
    private ASN1ObjectIdentifier certId;
    private ASN1Encodable certValue;
    
    private CertBag(final ASN1Sequence asn1Sequence) {
        this.certId = ASN1ObjectIdentifier.getInstance(asn1Sequence.getObjectAt(0));
        this.certValue = ASN1TaggedObject.getInstance(asn1Sequence.getObjectAt(1)).getExplicitBaseObject();
    }
    
    public static CertBag getInstance(final Object o) {
        if (o instanceof CertBag) {
            return (CertBag)o;
        }
        if (o != null) {
            return new CertBag(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    public CertBag(final ASN1ObjectIdentifier certId, final ASN1Encodable certValue) {
        this.certId = certId;
        this.certValue = certValue;
    }
    
    public ASN1ObjectIdentifier getCertId() {
        return this.certId;
    }
    
    public ASN1Encodable getCertValue() {
        return this.certValue;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(this.certId, new DERTaggedObject(0, this.certValue));
    }
}
