// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static CsrBuilder createCsr() {
//   return new CsrBuilderImpl();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static RootCertificateBuilder createSelfSignedCertificate(
//     final DistinguishedName subject) {
//   return new RootCertificateBuilderImpl(subject);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static DnBuilder dn() {
//   return new DnBuilderImpl();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static BigInteger generateRandomSerialNumber() {
//   return SerialNumberGenerator.instance.generateRandomSerialNumber();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static RootCertificate loadRootCertificate(final String keystorePath,
//     final char[] password, final String alias) {
//   return RootCertificateLoader.loadRootCertificate(keystorePath, password, alias);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CSR.java
// public interface CSR {
// 
//   public DistinguishedName getSubject();
// 
//   public PublicKey getPublicKey();
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CaException.java
// public class CaException extends RuntimeException {
//   private static final long serialVersionUID = -9188923051885159431L;
// 
//   public CaException(final String message, final Throwable cause) {
//     super(message, cause);
//   }
// 
//   public CaException(final String message) {
//     super(message);
//   }
// 
//   public CaException(final Throwable cause) {
//     super(cause);
//   }
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/DistinguishedName.java
// public interface DistinguishedName {
// 
//   public X500Name getX500Name();
// 
//   public X500Principal getX500Principal();
// 
//   public byte[] getEncoded();
// 
//   public String getName();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/RootCertificate.java
// public interface RootCertificate extends CertificateWithPrivateKey {
// 
//   public Signer signCsr(final CSR request);
// 
// }


import static io.github.olivierlemasle.ca.CA.createCsr;
import static io.github.olivierlemasle.ca.CA.createSelfSignedCertificate;
import static io.github.olivierlemasle.ca.CA.dn;
import static io.github.olivierlemasle.ca.CA.generateRandomSerialNumber;
import static io.github.olivierlemasle.ca.CA.loadRootCertificate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.cert.X509Certificate;
import java.time.ZonedDateTime;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import io.github.olivierlemasle.ca.CSR;
import io.github.olivierlemasle.ca.CaException;
import io.github.olivierlemasle.ca.DistinguishedName;
import io.github.olivierlemasle.ca.RootCertificate;
package io.github.olivierlemasle.tests;





public class KeystoreExportTest {
  private static RootCertificate ca;
  private static ZonedDateTime time = ZonedDateTime.now();
  private static CSR csr;
  private static BigInteger serialNumber;
  private static X509Certificate cert;

  @BeforeClass
  public static void setup() {
    final DistinguishedName caName = dn("CN=CA-Test");
    ca = createSelfSignedCertificate(caName).build();
    csr = createCsr().generateRequest(dn("CN=Test"));
    serialNumber = generateRandomSerialNumber();
    cert = ca.signCsr(csr)
        .setSerialNumber(serialNumber)
        .setNotBefore(time)
        .validDuringYears(1)
        .sign()
        .getX509Certificate();
  }

  @After
  public void clean() {
    try {
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static CsrBuilder createCsr() {
//   return new CsrBuilderImpl();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static RootCertificateBuilder createSelfSignedCertificate(
//     final DistinguishedName subject) {
//   return new RootCertificateBuilderImpl(subject);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static DnBuilder dn() {
//   return new DnBuilderImpl();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static BigInteger generateRandomSerialNumber() {
//   return SerialNumberGenerator.instance.generateRandomSerialNumber();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static RootCertificate loadRootCertificate(final String keystorePath,
//     final char[] password, final String alias) {
//   return RootCertificateLoader.loadRootCertificate(keystorePath, password, alias);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CSR.java
// public interface CSR {
// 
//   public DistinguishedName getSubject();
// 
//   public PublicKey getPublicKey();
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CaException.java
// public class CaException extends RuntimeException {
//   private static final long serialVersionUID = -9188923051885159431L;
// 
//   public CaException(final String message, final Throwable cause) {
//     super(message, cause);
//   }
// 
//   public CaException(final String message) {
//     super(message);
//   }
// 
//   public CaException(final Throwable cause) {
//     super(cause);
//   }
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/DistinguishedName.java
// public interface DistinguishedName {
// 
//   public X500Name getX500Name();
// 
//   public X500Principal getX500Principal();
// 
//   public byte[] getEncoded();
// 
//   public String getName();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/RootCertificate.java
// public interface RootCertificate extends CertificateWithPrivateKey {
// 
//   public Signer signCsr(final CSR request);
// 
// }


// Path: java-ca-lib/src/test/java/io/github/olivierlemasle/tests/KeystoreExportTest.java
import static io.github.olivierlemasle.ca.CA.createCsr;
import static io.github.olivierlemasle.ca.CA.createSelfSignedCertificate;
import static io.github.olivierlemasle.ca.CA.dn;
import static io.github.olivierlemasle.ca.CA.generateRandomSerialNumber;
import static io.github.olivierlemasle.ca.CA.loadRootCertificate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.cert.X509Certificate;
import java.time.ZonedDateTime;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import io.github.olivierlemasle.ca.CSR;
import io.github.olivierlemasle.ca.CaException;
import io.github.olivierlemasle.ca.DistinguishedName;
import io.github.olivierlemasle.ca.RootCertificate;

package io.github.olivierlemasle.tests;





public class KeystoreExportTest {
  private static RootCertificate ca;
  private static ZonedDateTime time = ZonedDateTime.now();
  private static CSR csr;
  private static BigInteger serialNumber;
  private static X509Certificate cert;

  @BeforeClass
  public static void setup() {
    final DistinguishedName caName = dn("CN=CA-Test");
    ca = createSelfSignedCertificate(caName).build();
    csr = createCsr().generateRequest(dn("CN=Test"));
    serialNumber = generateRandomSerialNumber();
    cert = ca.signCsr(csr)
        .setSerialNumber(serialNumber)
        .setNotBefore(time)
        .validDuringYears(1)
        .sign()
        .getX509Certificate();
  }

  @After
  public void clean() {
    try {
      Files.delete(Paths.get("test.p12"));