// Path: src/main/java/net/klakegg/pkix/ocsp/CertificateStatus.java
// public enum CertificateStatus {
// 
//     /**
//      * The certificate is valid.
//      */
//     GOOD,
// 
//     /**
//      * The certificate is temporarily or permanently revoked.
//      */
//     REVOKED,
// 
//     /**
//      * Status of certificate is unknown.
//      */
//     UNKNOWN
// 
// }
// 
// Path: src/main/java/net/klakegg/pkix/ocsp/OcspException.java
// public class OcspException extends Exception {
// 
//     protected static void trigger(Boolean trigger, String message, Object... objects) throws OcspException {
//         if (trigger)
//             throw new OcspException(message, objects);
//     }
// 
//     public OcspException(String message, Object... objects) {
//         super(String.format(message, objects));
//     }
// 
//     public OcspException(String message, Throwable cause, Object... objects) {
//         super(String.format(message, objects), cause);
//     }
// }
// 
// Path: src/main/java/net/klakegg/pkix/ocsp/OcspMultiClient.java
// public class OcspMultiClient extends AbstractOcspClient {
// 
//     /**
//      * Builder to create an instance of the client.
//      *
//      * @return Prepared client.
//      */
//     public static Builder<OcspMultiClient> builder() {
//         return new Builder<>(new BuildHandler<OcspMultiClient>() {
//             @Override
//             public OcspMultiClient build(Properties properties) {
//                 return new OcspMultiClient(properties);
//             }
//         });
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     private OcspMultiClient(Properties properties) {
//         super(properties);
//     }
// 
//     public OcspResult verify(X509Certificate... certificates) throws OcspException {
//         if (certificates.length == 0)
//             return OcspResult.EMPTY;
// 
//         X509Certificate issuer = findIntermediate(certificates[0]);
// 
//         return verify(CertificateIssuer.generate(issuer), certificates);
//     }
// 
//     public OcspResult verify(CertificateIssuer issuer, X509Certificate... certificates) throws OcspException {
//         if (certificates.length == 0)
//             return OcspResult.EMPTY;
// 
//         URI uri = properties.get(OVERRIDE_URL);
// 
//         if (uri == null) {
//             uri = detectOcspUri(certificates[0]);
// 
//             // In case no URI was detected.
//             if (uri == null)
//                 return OcspResult.EMPTY;
//         }
// 
//         BigInteger[] serialNumbers = new BigInteger[certificates.length];
//         for (int i = 0; i < certificates.length; i++)
//             serialNumbers[i] = certificates[i].getSerialNumber();
// 
//         return verify(uri, issuer, serialNumbers);
//     }
// 
//     public OcspResult verify(URI uri, CertificateIssuer issuer, BigInteger... serialNumbers) throws OcspException {
//         OcspRequest request = new OcspRequest();
//         request.setIssuer(issuer);
//         request.addCertificates(serialNumbers);
//         if (properties.get(NONCE))
//             request.addNonce();
// 
//         OcspResponse response = fetch(request, uri);
//         response.verifyResponse();
// 
//         return response.getResult();
//     }
// }
// 
// Path: src/main/java/net/klakegg/pkix/ocsp/OcspResult.java
// public class OcspResult {
// 
//     protected static final OcspResult EMPTY = new OcspResult(Collections.<BigInteger, CertificateResult>emptyMap());
// 
//     private final Map<BigInteger, CertificateResult> map;
// 
//     protected OcspResult(Map<BigInteger, CertificateResult> map) {
//         this.map = Collections.unmodifiableMap(map);
//     }
// 
//     public CertificateResult get(BigInteger serialNumber) {
//         return map.get(serialNumber);
//     }
// 
//     public CertificateResult get(X509Certificate certificate) {
//         return get(certificate.getSerialNumber());
//     }
// }
// 
// Path: src/test/java/net/klakegg/pkix/ocsp/util/CertificateHelper.java
// public class CertificateHelper {
// 
//     private static final CertificateFactory certFactory;
// 
//     static {
//         try {
//             certFactory = CertificateFactory.getInstance("X.509");
//         } catch (CertificateException e) {
//             throw new IllegalStateException(e.getMessage(), e);
//         }
//     }
// 
//     public static X509Certificate parse(InputStream inputStream) {
//         try {
//             return (X509Certificate) certFactory.generateCertificate(inputStream);
//         } catch (CertificateException e) {
//             throw new IllegalStateException(e.getMessage(), e);
//         }
//     }
// 
// }


import net.klakegg.pkix.ocsp.CertificateStatus;
import net.klakegg.pkix.ocsp.OcspException;
import net.klakegg.pkix.ocsp.OcspMultiClient;
import net.klakegg.pkix.ocsp.OcspResult;
import net.klakegg.pkix.ocsp.util.CertificateHelper;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.security.cert.X509Certificate;
import java.util.Collections;
package net.klakegg.pkix.ocsp.issuer;



/**
 * @author erlend
 */
public class PeppolProdMultiOcspTest {

    private X509Certificate subjectValid01 =
            CertificateHelper.parse(getClass().getResourceAsStream("/peppol-ap-prod/certificate-valid-01.cer"));

    private X509Certificate subjectValid02 =
            CertificateHelper.parse(getClass().getResourceAsStream("/peppol-ap-prod/certificate-valid-02.cer"));

    private X509Certificate issuer =
            CertificateHelper.parse(getClass().getResourceAsStream("/peppol-ap-prod/issuer.cer"));

    @Test(enabled = false)
    public void simple() throws OcspException {
        OcspMultiClient ocspMultiClient = OcspMultiClient.builder()
// Path: src/main/java/net/klakegg/pkix/ocsp/CertificateStatus.java
// public enum CertificateStatus {
// 
//     /**
//      * The certificate is valid.
//      */
//     GOOD,
// 
//     /**
//      * The certificate is temporarily or permanently revoked.
//      */
//     REVOKED,
// 
//     /**
//      * Status of certificate is unknown.
//      */
//     UNKNOWN
// 
// }
// 
// Path: src/main/java/net/klakegg/pkix/ocsp/OcspException.java
// public class OcspException extends Exception {
// 
//     protected static void trigger(Boolean trigger, String message, Object... objects) throws OcspException {
//         if (trigger)
//             throw new OcspException(message, objects);
//     }
// 
//     public OcspException(String message, Object... objects) {
//         super(String.format(message, objects));
//     }
// 
//     public OcspException(String message, Throwable cause, Object... objects) {
//         super(String.format(message, objects), cause);
//     }
// }
// 
// Path: src/main/java/net/klakegg/pkix/ocsp/OcspMultiClient.java
// public class OcspMultiClient extends AbstractOcspClient {
// 
//     /**
//      * Builder to create an instance of the client.
//      *
//      * @return Prepared client.
//      */
//     public static Builder<OcspMultiClient> builder() {
//         return new Builder<>(new BuildHandler<OcspMultiClient>() {
//             @Override
//             public OcspMultiClient build(Properties properties) {
//                 return new OcspMultiClient(properties);
//             }
//         });
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     private OcspMultiClient(Properties properties) {
//         super(properties);
//     }
// 
//     public OcspResult verify(X509Certificate... certificates) throws OcspException {
//         if (certificates.length == 0)
//             return OcspResult.EMPTY;
// 
//         X509Certificate issuer = findIntermediate(certificates[0]);
// 
//         return verify(CertificateIssuer.generate(issuer), certificates);
//     }
// 
//     public OcspResult verify(CertificateIssuer issuer, X509Certificate... certificates) throws OcspException {
//         if (certificates.length == 0)
//             return OcspResult.EMPTY;
// 
//         URI uri = properties.get(OVERRIDE_URL);
// 
//         if (uri == null) {
//             uri = detectOcspUri(certificates[0]);
// 
//             // In case no URI was detected.
//             if (uri == null)
//                 return OcspResult.EMPTY;
//         }
// 
//         BigInteger[] serialNumbers = new BigInteger[certificates.length];
//         for (int i = 0; i < certificates.length; i++)
//             serialNumbers[i] = certificates[i].getSerialNumber();
// 
//         return verify(uri, issuer, serialNumbers);
//     }
// 
//     public OcspResult verify(URI uri, CertificateIssuer issuer, BigInteger... serialNumbers) throws OcspException {
//         OcspRequest request = new OcspRequest();
//         request.setIssuer(issuer);
//         request.addCertificates(serialNumbers);
//         if (properties.get(NONCE))
//             request.addNonce();
// 
//         OcspResponse response = fetch(request, uri);
//         response.verifyResponse();
// 
//         return response.getResult();
//     }
// }
// 
// Path: src/main/java/net/klakegg/pkix/ocsp/OcspResult.java
// public class OcspResult {
// 
//     protected static final OcspResult EMPTY = new OcspResult(Collections.<BigInteger, CertificateResult>emptyMap());
// 
//     private final Map<BigInteger, CertificateResult> map;
// 
//     protected OcspResult(Map<BigInteger, CertificateResult> map) {
//         this.map = Collections.unmodifiableMap(map);
//     }
// 
//     public CertificateResult get(BigInteger serialNumber) {
//         return map.get(serialNumber);
//     }
// 
//     public CertificateResult get(X509Certificate certificate) {
//         return get(certificate.getSerialNumber());
//     }
// }
// 
// Path: src/test/java/net/klakegg/pkix/ocsp/util/CertificateHelper.java
// public class CertificateHelper {
// 
//     private static final CertificateFactory certFactory;
// 
//     static {
//         try {
//             certFactory = CertificateFactory.getInstance("X.509");
//         } catch (CertificateException e) {
//             throw new IllegalStateException(e.getMessage(), e);
//         }
//     }
// 
//     public static X509Certificate parse(InputStream inputStream) {
//         try {
//             return (X509Certificate) certFactory.generateCertificate(inputStream);
//         } catch (CertificateException e) {
//             throw new IllegalStateException(e.getMessage(), e);
//         }
//     }
// 
// }


// Path: src/test/java/net/klakegg/pkix/ocsp/issuer/PeppolProdMultiOcspTest.java
import net.klakegg.pkix.ocsp.CertificateStatus;
import net.klakegg.pkix.ocsp.OcspException;
import net.klakegg.pkix.ocsp.OcspMultiClient;
import net.klakegg.pkix.ocsp.OcspResult;
import net.klakegg.pkix.ocsp.util.CertificateHelper;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.security.cert.X509Certificate;
import java.util.Collections;

package net.klakegg.pkix.ocsp.issuer;



/**
 * @author erlend
 */
public class PeppolProdMultiOcspTest {

    private X509Certificate subjectValid01 =
            CertificateHelper.parse(getClass().getResourceAsStream("/peppol-ap-prod/certificate-valid-01.cer"));

    private X509Certificate subjectValid02 =
            CertificateHelper.parse(getClass().getResourceAsStream("/peppol-ap-prod/certificate-valid-02.cer"));

    private X509Certificate issuer =
            CertificateHelper.parse(getClass().getResourceAsStream("/peppol-ap-prod/issuer.cer"));

    @Test(enabled = false)
    public void simple() throws OcspException {
        OcspMultiClient ocspMultiClient = OcspMultiClient.builder()
                .set(OcspMultiClient.INTERMEDIATES, Collections.singletonList(issuer))