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

package org.bouncycastle.jce.provider;

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.internal.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
import org.bouncycastle.internal.asn1.isara.IsaraObjectIdentifiers;
import org.bouncycastle.internal.asn1.eac.EACObjectIdentifiers;
import org.bouncycastle.internal.asn1.bsi.BSIObjectIdentifiers;
import org.bouncycastle.internal.asn1.rosstandart.RosstandartObjectIdentifiers;
import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import java.util.HashMap;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.security.cert.Certificate;
import java.util.Set;
import java.security.cert.CertPathValidatorException;
import java.util.List;
import org.bouncycastle.jcajce.PKIXCertRevocationCheckerParameters;
import org.bouncycastle.jcajce.util.JcaJceHelper;
import java.util.Map;
import org.bouncycastle.jcajce.PKIXCertRevocationChecker;
import java.security.cert.PKIXRevocationChecker;

class ProvRevocationChecker extends PKIXRevocationChecker implements PKIXCertRevocationChecker
{
    private static final int DEFAULT_OCSP_TIMEOUT = 15000;
    private static final int DEFAULT_OCSP_MAX_RESPONSE_SIZE = 32768;
    private static final Map oids;
    private final JcaJceHelper helper;
    private final ProvCrlRevocationChecker crlChecker;
    private final ProvOcspRevocationChecker ocspChecker;
    private PKIXCertRevocationCheckerParameters parameters;
    
    public ProvRevocationChecker(final JcaJceHelper helper) {
        this.helper = helper;
        this.crlChecker = new ProvCrlRevocationChecker(helper);
        this.ocspChecker = new ProvOcspRevocationChecker(this, helper);
    }
    
    @Override
    public void setParameter(final String s, final Object o) {
    }
    
    @Override
    public void initialize(final PKIXCertRevocationCheckerParameters parameters) {
        this.parameters = parameters;
        this.crlChecker.initialize(parameters);
        this.ocspChecker.initialize(parameters);
    }
    
    @Override
    public List<CertPathValidatorException> getSoftFailExceptions() {
        return this.ocspChecker.getSoftFailExceptions();
    }
    
    @Override
    public void init(final boolean b) throws CertPathValidatorException {
        this.parameters = null;
        this.crlChecker.init(b);
        this.ocspChecker.init(b);
    }
    
    @Override
    public boolean isForwardCheckingSupported() {
        return false;
    }
    
    @Override
    public Set<String> getSupportedExtensions() {
        return null;
    }
    
    @Override
    public void check(final Certificate certificate, final Collection<String> collection) throws CertPathValidatorException {
        final X509Certificate x509Certificate = (X509Certificate)certificate;
        if (this.hasOption(Option.ONLY_END_ENTITY) && x509Certificate.getBasicConstraints() != -1) {
            return;
        }
        if (this.hasOption(Option.PREFER_CRLS)) {
            try {
                this.crlChecker.check(certificate);
            }
            catch (final RecoverableCertPathValidatorException ex) {
                if (this.hasOption(Option.NO_FALLBACK)) {
                    throw ex;
                }
                this.ocspChecker.check(certificate);
            }
        }
        else {
            try {
                this.ocspChecker.check(certificate);
            }
            catch (final RecoverableCertPathValidatorException ex2) {
                if (this.hasOption(Option.NO_FALLBACK)) {
                    throw ex2;
                }
                this.crlChecker.check(certificate);
            }
        }
    }
    
    private boolean hasOption(final Option option) {
        return this.getOptions().contains(option);
    }
    
    static {
        (oids = new HashMap()).put(new ASN1ObjectIdentifier("1.2.840.113549.1.1.5"), "SHA1WITHRSA");
        ProvRevocationChecker.oids.put(PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WITHRSA");
        ProvRevocationChecker.oids.put(PKCSObjectIdentifiers.sha256WithRSAEncryption, "SHA256WITHRSA");
        ProvRevocationChecker.oids.put(PKCSObjectIdentifiers.sha384WithRSAEncryption, "SHA384WITHRSA");
        ProvRevocationChecker.oids.put(PKCSObjectIdentifiers.sha512WithRSAEncryption, "SHA512WITHRSA");
        ProvRevocationChecker.oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3411WITHGOST3410");
        ProvRevocationChecker.oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "GOST3411WITHECGOST3410");
        ProvRevocationChecker.oids.put(RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256, "GOST3411-2012-256WITHECGOST3410-2012-256");
        ProvRevocationChecker.oids.put(RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512, "GOST3411-2012-512WITHECGOST3410-2012-512");
        ProvRevocationChecker.oids.put(BSIObjectIdentifiers.ecdsa_plain_SHA1, "SHA1WITHPLAIN-ECDSA");
        ProvRevocationChecker.oids.put(BSIObjectIdentifiers.ecdsa_plain_SHA224, "SHA224WITHPLAIN-ECDSA");
        ProvRevocationChecker.oids.put(BSIObjectIdentifiers.ecdsa_plain_SHA256, "SHA256WITHPLAIN-ECDSA");
        ProvRevocationChecker.oids.put(BSIObjectIdentifiers.ecdsa_plain_SHA384, "SHA384WITHPLAIN-ECDSA");
        ProvRevocationChecker.oids.put(BSIObjectIdentifiers.ecdsa_plain_SHA512, "SHA512WITHPLAIN-ECDSA");
        ProvRevocationChecker.oids.put(BSIObjectIdentifiers.ecdsa_plain_RIPEMD160, "RIPEMD160WITHPLAIN-ECDSA");
        ProvRevocationChecker.oids.put(EACObjectIdentifiers.id_TA_ECDSA_SHA_1, "SHA1WITHCVC-ECDSA");
        ProvRevocationChecker.oids.put(EACObjectIdentifiers.id_TA_ECDSA_SHA_224, "SHA224WITHCVC-ECDSA");
        ProvRevocationChecker.oids.put(EACObjectIdentifiers.id_TA_ECDSA_SHA_256, "SHA256WITHCVC-ECDSA");
        ProvRevocationChecker.oids.put(EACObjectIdentifiers.id_TA_ECDSA_SHA_384, "SHA384WITHCVC-ECDSA");
        ProvRevocationChecker.oids.put(EACObjectIdentifiers.id_TA_ECDSA_SHA_512, "SHA512WITHCVC-ECDSA");
        ProvRevocationChecker.oids.put(IsaraObjectIdentifiers.id_alg_xmss, "XMSS");
        ProvRevocationChecker.oids.put(IsaraObjectIdentifiers.id_alg_xmssmt, "XMSSMT");
        ProvRevocationChecker.oids.put(new ASN1ObjectIdentifier("1.2.840.113549.1.1.4"), "MD5WITHRSA");
        ProvRevocationChecker.oids.put(new ASN1ObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA");
        ProvRevocationChecker.oids.put(new ASN1ObjectIdentifier("1.2.840.10040.4.3"), "SHA1WITHDSA");
        ProvRevocationChecker.oids.put(X9ObjectIdentifiers.ecdsa_with_SHA1, "SHA1WITHECDSA");
        ProvRevocationChecker.oids.put(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224WITHECDSA");
        ProvRevocationChecker.oids.put(X9ObjectIdentifiers.ecdsa_with_SHA256, "SHA256WITHECDSA");
        ProvRevocationChecker.oids.put(X9ObjectIdentifiers.ecdsa_with_SHA384, "SHA384WITHECDSA");
        ProvRevocationChecker.oids.put(X9ObjectIdentifiers.ecdsa_with_SHA512, "SHA512WITHECDSA");
        ProvRevocationChecker.oids.put(OIWObjectIdentifiers.sha1WithRSA, "SHA1WITHRSA");
        ProvRevocationChecker.oids.put(OIWObjectIdentifiers.dsaWithSHA1, "SHA1WITHDSA");
        ProvRevocationChecker.oids.put(NISTObjectIdentifiers.dsa_with_sha224, "SHA224WITHDSA");
        ProvRevocationChecker.oids.put(NISTObjectIdentifiers.dsa_with_sha256, "SHA256WITHDSA");
    }
}
