作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.wildfly.security.x500.cert.X509CertificateBuilder
类的一些代码示例,展示了X509CertificateBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509CertificateBuilder
类的具体详情如下:
包路径:org.wildfly.security.x500.cert.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) {
我是一名优秀的程序员,十分优秀!