// 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/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.createSelfSignedCertificate;
import static io.github.olivierlemasle.ca.CA.dn;
import io.dropwizard.cli.Command;
import io.dropwizard.setup.Bootstrap;
import io.github.olivierlemasle.ca.DistinguishedName;
import io.github.olivierlemasle.ca.RootCertificate;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
    parser.addArgument("-s", "--subject")
        .dest("subject")
        .type(String.class)
        .required(true)
        .help("The subject CN");
    parser.addArgument("-o", "--out")
        .dest("out")
        .type(String.class)
        .required(true)
        .help("The name of the keystore to be created");
    parser.addArgument("-p", "--password")
        .dest("password")
        .type(String.class)
        .required(true)
        .help("The password of the keystore to be created");
    parser.addArgument("-c", "--cert")
        .dest("cert")
        .type(String.class)
        .required(true)
        .help("The certificate file to be created");
  }

  @Override
  public void run(final Bootstrap<?> bootstrap, final Namespace namespace) throws Exception {
    final String subject = namespace.getString("subject");
    final String out = namespace.getString("out");
    final String password = namespace.getString("password");
    final String cert = namespace.getString("cert");

    final DistinguishedName dn = dn().setCn(subject).build();
// 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/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: ca-api/src/main/java/io/github/olivierlemasle/caweb/cli/CreateSelfSignedCertificate.java
import static io.github.olivierlemasle.ca.CA.createSelfSignedCertificate;
import static io.github.olivierlemasle.ca.CA.dn;
import io.dropwizard.cli.Command;
import io.dropwizard.setup.Bootstrap;
import io.github.olivierlemasle.ca.DistinguishedName;
import io.github.olivierlemasle.ca.RootCertificate;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;

    parser.addArgument("-s", "--subject")
        .dest("subject")
        .type(String.class)
        .required(true)
        .help("The subject CN");
    parser.addArgument("-o", "--out")
        .dest("out")
        .type(String.class)
        .required(true)
        .help("The name of the keystore to be created");
    parser.addArgument("-p", "--password")
        .dest("password")
        .type(String.class)
        .required(true)
        .help("The password of the keystore to be created");
    parser.addArgument("-c", "--cert")
        .dest("cert")
        .type(String.class)
        .required(true)
        .help("The certificate file to be created");
  }

  @Override
  public void run(final Bootstrap<?> bootstrap, final Namespace namespace) throws Exception {
    final String subject = namespace.getString("subject");
    final String out = namespace.getString("out");
    final String password = namespace.getString("password");
    final String cert = namespace.getString("cert");

    final DistinguishedName dn = dn().setCn(subject).build();
    final RootCertificate root = createSelfSignedCertificate(dn).build();