// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static DnBuilder dn() {
//   return new DnBuilderImpl();
// }


import static io.github.olivierlemasle.ca.CA.dn;
import java.io.IOException;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import org.bouncycastle.cert.X509CertificateHolder;
package io.github.olivierlemasle.ca;




class RootCertificateImpl extends CertificateWithPrivateKeyImpl implements RootCertificate {
  static final String KEYSTORE_TYPE = "PKCS12";

  private final X509CertificateHolder caCertificateHolder;

  RootCertificateImpl(final X509Certificate caCertificate, final PrivateKey caPrivateKey) {
    super(caCertificate, caPrivateKey);
    try {
      this.caCertificateHolder = new X509CertificateHolder(caCertificate.getEncoded());
    } catch (CertificateEncodingException | IOException e) {
      throw new CaException(e);
    }
  }

  @Override
  public Signer signCsr(final CSR request) {
    final KeyPair pair = new KeyPair(getX509Certificate().getPublicKey(), getPrivateKey());
// 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/RootCertificateImpl.java
import static io.github.olivierlemasle.ca.CA.dn;
import java.io.IOException;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import org.bouncycastle.cert.X509CertificateHolder;

package io.github.olivierlemasle.ca;




class RootCertificateImpl extends CertificateWithPrivateKeyImpl implements RootCertificate {
  static final String KEYSTORE_TYPE = "PKCS12";

  private final X509CertificateHolder caCertificateHolder;

  RootCertificateImpl(final X509Certificate caCertificate, final PrivateKey caPrivateKey) {
    super(caCertificate, caPrivateKey);
    try {
      this.caCertificateHolder = new X509CertificateHolder(caCertificate.getEncoded());
    } catch (CertificateEncodingException | IOException e) {
      throw new CaException(e);
    }
  }

  @Override
  public Signer signCsr(final CSR request) {
    final KeyPair pair = new KeyPair(getX509Certificate().getPublicKey(), getPrivateKey());
    final DistinguishedName signerSubject = dn(caCertificateHolder.getSubject());