本文整理汇总了Java中org.bouncycastle.asn1.x509.KeyPurposeId.id_kp_serverAuth方法的典型用法代码示例。如果您正苦于以下问题:Java KeyPurposeId.id_kp_serverAuth方法的具体用法?Java KeyPurposeId.id_kp_serverAuth怎么用?Java KeyPurposeId.id_kp_serverAuth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x509.KeyPurposeId
的用法示例。
在下文中一共展示了KeyPurposeId.id_kp_serverAuth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateCA
import org.bouncycastle.asn1.x509.KeyPurposeId; //导入方法依赖的package包/类
public void generateCA(String prettyName)
{
this.prettyName = prettyName;
Subject = "CN=JQM-CA,OU=ServerProducts,O=Oxymores,C=FR";
size = 4096;
EKU = new KeyPurposeId[4];
EKU[0] = KeyPurposeId.id_kp_codeSigning;
EKU[1] = KeyPurposeId.id_kp_serverAuth;
EKU[2] = KeyPurposeId.id_kp_clientAuth;
EKU[3] = KeyPurposeId.id_kp_emailProtection;
keyUsage = KeyUsage.cRLSign | KeyUsage.keyCertSign;
generateAll();
}
示例2: buildExtendedKeyUsage
import org.bouncycastle.asn1.x509.KeyPurposeId; //导入方法依赖的package包/类
private ExtendedKeyUsage buildExtendedKeyUsage(CertificateGenerationRequestParameters params) {
String[] extendedKeyUsageList = params.getExtendedKeyUsage();
if (extendedKeyUsageList == null){
return null;
}
KeyPurposeId[] keyPurposeIds = new KeyPurposeId[extendedKeyUsageList.length];
for (int i = 0; i < extendedKeyUsageList.length; i++) {
switch (extendedKeyUsageList[i]) {
case SERVER_AUTH:
keyPurposeIds[i] = KeyPurposeId.id_kp_serverAuth;
break;
case CLIENT_AUTH:
keyPurposeIds[i] = KeyPurposeId.id_kp_clientAuth;
break;
case CODE_SIGNING:
keyPurposeIds[i] = KeyPurposeId.id_kp_codeSigning;
break;
case EMAIL_PROTECTION:
keyPurposeIds[i] = KeyPurposeId.id_kp_emailProtection;
break;
case TIMESTAMPING:
keyPurposeIds[i] = KeyPurposeId.id_kp_timeStamping;
break;
default:
throw new ParameterizedValidationException("error.invalid_extended_key_usage", extendedKeyUsageList[i]);
}
}
return new ExtendedKeyUsage(keyPurposeIds);
}
示例3: imitatePeerCertificate
import org.bouncycastle.asn1.x509.KeyPurposeId; //导入方法依赖的package包/类
/**
* Forges a certificate with given certificate's attributes and signs it with CA of proxy.
*/
private static KeyCertPair imitatePeerCertificate(X509Certificate cert2Imitate) throws Exception {
// TODO imitate key algorithm also
// (cert2Imitate.getPublicKey().getAlgorithm())
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024);
KeyPair keyPair = keyPairGenerator.generateKeyPair();
X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
SecureRandom secureRandom = new SecureRandom();
byte[] serial = new byte[16];
secureRandom.nextBytes(serial);
BigInteger serialNumber = new BigInteger(serial);
if (serialNumber.signum() < 0) {
serialNumber = serialNumber.negate();
}
v3CertGen.setSerialNumber(serialNumber);
v3CertGen.setIssuerDN(((X509Certificate) issuerCA.getCertificate()).getIssuerX500Principal());
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365 * 10)));
v3CertGen.setSubjectDN(cert2Imitate.getSubjectX500Principal());
ExtendedKeyUsage extendedKeyUsage = new ExtendedKeyUsage(KeyPurposeId.id_kp_serverAuth);
v3CertGen.addExtension(X509Extensions.ExtendedKeyUsage, false, extendedKeyUsage);
v3CertGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(false));
v3CertGen.setPublicKey(keyPair.getPublic());
v3CertGen.setSignatureAlgorithm("SHA1WithRSA");
Certificate pkCertificate = v3CertGen.generateX509Certificate((PrivateKey) issuerCA.getKey());
return new KeyCertPair(pkCertificate, keyPair.getPrivate());
}
示例4: generateServerCert
import org.bouncycastle.asn1.x509.KeyPurposeId; //导入方法依赖的package包/类
public void generateServerCert(String prettyName, X509CertificateHolder authority, PrivateKey issuerPrivateKey, String subject)
{
this.prettyName = prettyName;
authorityCertificate = authority;
authorityKey = issuerPrivateKey;
this.Subject = subject;
size = 2048;
EKU = new KeyPurposeId[1];
EKU[0] = KeyPurposeId.id_kp_serverAuth;
keyUsage = KeyUsage.digitalSignature | KeyUsage.keyEncipherment;
generateAll();
}