Tabnine Logo
X509CertificateBuilder.build
Code IndexAdd Tabnine to your IDE (free)

How to use
build
method
in
org.wildfly.security.x500.cert.X509CertificateBuilder

Best Java code snippets using org.wildfly.security.x500.cert.X509CertificateBuilder.build (Showing top 7 results out of 315)

origin: wildfly/wildfly

    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {
origin: org.wildfly.core/wildfly-domain-management

X509Certificate generateCertificate(KeyPair pair) throws Exception {
  PrivateKey privkey = pair.getPrivate();
  X509CertificateBuilder builder = new X509CertificateBuilder();
  Date from = new Date();
  Date to = new Date(from.getTime() + (1000L * 60L * 60L * 24L * 365L * 10L));
  BigInteger sn = new BigInteger(64, new SecureRandom());
  builder.setNotValidAfter(ZonedDateTime.ofInstant(Instant.ofEpochMilli(to.getTime()), TimeZone.getDefault().toZoneId()));
  builder.setNotValidBefore(ZonedDateTime.ofInstant(Instant.ofEpochMilli(from.getTime()), TimeZone.getDefault().toZoneId()));
  builder.setSerialNumber(sn);
  X500Principal owner = new X500Principal("CN=" + autoGenerateCertHostName);
  builder.setSubjectDn(owner);
  builder.setIssuerDn(owner);
  builder.setPublicKey(pair.getPublic());
  builder.setVersion(3);
  builder.setSignatureAlgorithmName(SHA_256_WITH_RSA);
  builder.setSigningKey(privkey);
  return builder.build();
}
origin: wildfly/wildfly-core

X509Certificate generateCertificate(KeyPair pair) throws Exception {
  PrivateKey privkey = pair.getPrivate();
  X509CertificateBuilder builder = new X509CertificateBuilder();
  Date from = new Date();
  Date to = new Date(from.getTime() + (1000L * 60L * 60L * 24L * 365L * 10L));
  BigInteger sn = new BigInteger(64, new SecureRandom());
  builder.setNotValidAfter(ZonedDateTime.ofInstant(Instant.ofEpochMilli(to.getTime()), TimeZone.getDefault().toZoneId()));
  builder.setNotValidBefore(ZonedDateTime.ofInstant(Instant.ofEpochMilli(from.getTime()), TimeZone.getDefault().toZoneId()));
  builder.setSerialNumber(sn);
  X500Principal owner = new X500Principal("CN=" + autoGenerateCertHostName);
  builder.setSubjectDn(owner);
  builder.setIssuerDn(owner);
  builder.setPublicKey(pair.getPublic());
  builder.setVersion(3);
  builder.setSignatureAlgorithmName(SHA_256_WITH_RSA);
  builder.setSigningKey(privkey);
  return builder.build();
}
origin: org.wildfly/wildfly-testsuite-shared

  /**
   * Generates self-signed certificate for provided key-pair with given validity time and signature algorithm.
   *
   * @param name               common name for the certificate
   * @param keyPair            public and private keys
   * @param certValidity       how long the certificate should be valid to the future (number of seconds)
   * @param signatureAlgorithm signature algorithm
   * @return generated certificate
   * @throws CertificateException
   */
  public static X509Certificate generateX509Certificate(String name, KeyPair keyPair, long certValidity, String
      signatureAlgorithm) throws CertificateException {
    ZonedDateTime from = ZonedDateTime.now();
    ZonedDateTime to = ZonedDateTime.now().plusSeconds(certValidity);
    BigInteger serialNumber = new BigInteger(64, new SecureRandom());
    X500Principal owner = new X500Principal("CN=" + name);

    X509CertificateBuilder certificateBuilder = new X509CertificateBuilder();
    return certificateBuilder.setIssuerDn(owner).setSubjectDn(owner).setNotValidBefore(from).setNotValidAfter(to)
        .setSerialNumber(serialNumber).setPublicKey(keyPair.getPublic()).setSignatureAlgorithmName
            (signatureAlgorithm).setSigningKey(keyPair.getPrivate()).build();
  }
}
origin: org.wildfly.security/wildfly-elytron

    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {
origin: org.wildfly.security/wildfly-elytron-x500-cert

    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {
origin: org.jboss.eap/wildfly-client-all

    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {
org.wildfly.security.x500.certX509CertificateBuilderbuild

Javadoc

Attempt to construct and sign an X.509 certificate according to the information in this builder.

Popular methods of X509CertificateBuilder

  • <init>
    Construct a new uninitialized instance.
  • setIssuerDn
    Set the issuer DN.
  • setNotValidAfter
    Set the not-valid-after date.
  • setNotValidBefore
    Set the not-valid-before date.
  • setPublicKey
    Set the public key.
  • setSerialNumber
    Set the serial number of the certificate being built. The serial number must be positive and no larg
  • setSignatureAlgorithmName
    Set the signature algorithm name.
  • setSigningKey
    Set the signing key.
  • setSubjectDn
    Set the subject DN.
  • setVersion
    Set the certificate version.
  • addExtension
    Add a certificate extension. If an extension with the same OID already exists, an exception is throw
  • getTBSBytes
  • addExtension,
  • getTBSBytes

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (Timer)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JCheckBox (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now