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

package org.bouncycastle.asn1.x509;

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

public class Validity extends ASN1Object
{
    private final Time notBefore;
    private final Time notAfter;
    
    public static Validity getInstance(final Object o) {
        if (o instanceof Validity) {
            return (Validity)o;
        }
        if (o != null) {
            return new Validity(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    public static Validity getInstance(final ASN1TaggedObject asn1TaggedObject, final boolean b) {
        return new Validity(ASN1Sequence.getInstance(asn1TaggedObject, b));
    }
    
    private Validity(final ASN1Sequence asn1Sequence) {
        final int size = asn1Sequence.size();
        if (size != 2) {
            throw new IllegalArgumentException("Bad sequence size: " + size);
        }
        this.notBefore = Time.getInstance(asn1Sequence.getObjectAt(0));
        this.notAfter = Time.getInstance(asn1Sequence.getObjectAt(1));
    }
    
    public Validity(final Time notBefore, final Time notAfter) {
        if (notBefore == null) {
            throw new NullPointerException("'notBefore' cannot be null");
        }
        if (notAfter == null) {
            throw new NullPointerException("'notAfter' cannot be null");
        }
        this.notBefore = notBefore;
        this.notAfter = notAfter;
    }
    
    public Time getNotBefore() {
        return this.notBefore;
    }
    
    public Time getNotAfter() {
        return this.notAfter;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(this.notBefore, this.notAfter);
    }
}
