@Test void generateSelfSignedCertificateVersion1() throws Exception { CertifiedPublicKey certificate = factory.getInstance(signerFactory.getInstance(true, rsaPrivateKey), new X509CertificateGenerationParameters()) .generate(new DistinguishedName("CN=Test"), rsaPublicKey, new X509CertificateParameters()); checkSelfSigned(certificate, 1); }
@Override public CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters) { if (!(parameters instanceof X509CertificateGenerationParameters)) { throw new IllegalArgumentException("Invalid parameters for X.509 certificate: " + parameters.getClass().getName()); } if (!signer.isForSigning()) { throw new IllegalArgumentException("Verifying signer used for signing certificates."); } X509CertificateGenerationParameters params = (X509CertificateGenerationParameters) parameters; switch (params.getX509Version()) { case V1: return new BcX509v1CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); case V3: return new BcX509v3CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); default: throw new IllegalArgumentException("Unknown X.509 certificate version: " + params.getX509Version()); } }
BcX509CertificateGeneratorFactory implements CertificateGeneratorFactory { @Override public CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters) { if (!(parameters instanceof X509CertificateGenerationParameters)) { throw new IllegalArgumentException("Invalid parameters for X.509 certificate: " + parameters.getClass().getName()); } if (!signer.isForSigning()) { throw new IllegalArgumentException("Verifying signer used for signing certificates."); } X509CertificateGenerationParameters params = (X509CertificateGenerationParameters) parameters; switch (params.getX509Version()) { case V1: return new BcX509v1CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); case V3: return new BcX509v3CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); default: throw new IllegalArgumentException("Unknown X.509 certificate version: " + params.getX509Version()); } } }
BcX509CertificateGeneratorFactory implements CertificateGeneratorFactory { @Override public CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters) { if (!(parameters instanceof X509CertificateGenerationParameters)) { throw new IllegalArgumentException("Invalid parameters for X.509 certificate: " + parameters.getClass().getName()); } if (!signer.isForSigning()) { throw new IllegalArgumentException("Verifying signer used for signing certificates."); } X509CertificateGenerationParameters params = (X509CertificateGenerationParameters) parameters; switch (params.getX509Version()) { case V1: return new BcX509v1CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); case V3: return new BcX509v3CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); default: throw new IllegalArgumentException("Unknown X.509 certificate version: " + params.getX509Version()); } }  }
BcX509CertificateGeneratorFactory implements CertificateGeneratorFactory { @Override public CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters) { if (!(parameters instanceof X509CertificateGenerationParameters)) { throw new IllegalArgumentException("Invalid parameters for X.509 certificate: " + parameters.getClass().getName()); } if (!signer.isForSigning()) { throw new IllegalArgumentException("Verifying signer used for signing certificates."); } X509CertificateGenerationParameters params = (X509CertificateGenerationParameters) parameters; switch (params.getX509Version()) { case V1: return new BcX509v1CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); case V3: return new BcX509v3CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); default: throw new IllegalArgumentException("Unknown X.509 certificate version: " + params.getX509Version()); } }  @Override CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters); }
BcX509CertificateGeneratorFactory implements CertificateGeneratorFactory { @Override public CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters) { if (!(parameters instanceof X509CertificateGenerationParameters)) { throw new IllegalArgumentException("Invalid parameters for X.509 certificate: " + parameters.getClass().getName()); } if (!signer.isForSigning()) { throw new IllegalArgumentException("Verifying signer used for signing certificates."); } X509CertificateGenerationParameters params = (X509CertificateGenerationParameters) parameters; switch (params.getX509Version()) { case V1: return new BcX509v1CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); case V3: return new BcX509v3CertificateGenerator(signer, params, this.signerFactory, this.randomProvider.get()); default: throw new IllegalArgumentException("Unknown X.509 certificate version: " + params.getX509Version()); } }  @Override CertificateGenerator getInstance(Signer signer, CertificateGenerationParameters parameters);  }