gpt4 book ai didi

org.wildfly.security.x500.cert.X509CertificateBuilder类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 21:40:40 25 4
gpt4 key购买 nike

本文整理了Java中org.wildfly.security.x500.cert.X509CertificateBuilder类的一些代码示例,展示了X509CertificateBuilder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509CertificateBuilder类的具体详情如下:
包路径:org.wildfly.security.x500.cert.X509CertificateBuilder
类名称:X509CertificateBuilder

X509CertificateBuilder介绍

[英]A builder for X.509 certificates.
[中]X.509证书的生成器。

代码示例

代码示例来源:origin: wildfly/wildfly

X509CertificateBuilder certificateBuilder = new X509CertificateBuilder();
  certificateBuilder.setIssuerDn(dn);
  certificateBuilder.setSubjectDn(dn);
  certificateBuilder.setPublicKey(keyPair.getPublic());
  certificateBuilder.setSigningKey(signingKey);
  certificateBuilder.setSignatureAlgorithmName(signatureAlgorithmName);
  certificateBuilder.setVersion(VERSION);
  BigInteger serialNumber = new BigInteger(64, new SecureRandom());
  certificateBuilder.setSerialNumber(serialNumber);
  for (X509CertificateExtension extension : extensionsByOid.values()) {
    certificateBuilder.addExtension(extension);
    certificateBuilder.setNotValidBefore(notValidBefore);
    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {

代码示例来源: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.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.jboss.eap/wildfly-client-all

X509CertificateBuilder certificateBuilder = new X509CertificateBuilder();
  certificateBuilder.setIssuerDn(dn);
  certificateBuilder.setSubjectDn(dn);
  certificateBuilder.setPublicKey(keyPair.getPublic());
  certificateBuilder.setSigningKey(signingKey);
  certificateBuilder.setSignatureAlgorithmName(signatureAlgorithmName);
  certificateBuilder.setVersion(VERSION);
  BigInteger serialNumber = new BigInteger(64, new SecureRandom());
  certificateBuilder.setSerialNumber(serialNumber);
  for (X509CertificateExtension extension : extensionsByOid.values()) {
    certificateBuilder.addExtension(extension);
    certificateBuilder.setNotValidBefore(notValidBefore);
    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {

代码示例来源:origin: org.wildfly.security/wildfly-elytron-x500-cert

X509CertificateBuilder certificateBuilder = new X509CertificateBuilder();
  certificateBuilder.setIssuerDn(dn);
  certificateBuilder.setSubjectDn(dn);
  certificateBuilder.setPublicKey(keyPair.getPublic());
  certificateBuilder.setSigningKey(signingKey);
  certificateBuilder.setSignatureAlgorithmName(signatureAlgorithmName);
  certificateBuilder.setVersion(VERSION);
  BigInteger serialNumber = new BigInteger(64, new SecureRandom());
  certificateBuilder.setSerialNumber(serialNumber);
  for (X509CertificateExtension extension : extensionsByOid.values()) {
    certificateBuilder.addExtension(extension);
    certificateBuilder.setNotValidBefore(notValidBefore);
    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {

代码示例来源:origin: org.wildfly.security/wildfly-elytron

X509CertificateBuilder certificateBuilder = new X509CertificateBuilder();
  certificateBuilder.setIssuerDn(dn);
  certificateBuilder.setSubjectDn(dn);
  certificateBuilder.setPublicKey(keyPair.getPublic());
  certificateBuilder.setSigningKey(signingKey);
  certificateBuilder.setSignatureAlgorithmName(signatureAlgorithmName);
  certificateBuilder.setVersion(VERSION);
  BigInteger serialNumber = new BigInteger(64, new SecureRandom());
  certificateBuilder.setSerialNumber(serialNumber);
  for (X509CertificateExtension extension : extensionsByOid.values()) {
    certificateBuilder.addExtension(extension);
    certificateBuilder.setNotValidBefore(notValidBefore);
    certificateBuilder.setNotValidAfter(notValidAfter);
  selfSignedCertificate = certificateBuilder.build();
  return new SelfSignedX509CertificateAndSigningKey(this);
} catch (Exception e) {

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com