當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyPurposeId.id_kp_serverAuth方法代碼示例

本文整理匯總了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();
}
 
開發者ID:enioka,項目名稱:jqm,代碼行數:18,代碼來源:CertificateRequest.java

示例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);
}
 
開發者ID:cloudfoundry-incubator,項目名稱:credhub,代碼行數:30,代碼來源:CertificateGenerationParameters.java

示例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());
   }
 
開發者ID:Akdeniz,項目名稱:mitmsocks4j,代碼行數:38,代碼來源:CertificateManager.java

示例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();
}
 
開發者ID:enioka,項目名稱:jqm,代碼行數:19,代碼來源:CertificateRequest.java


注:本文中的org.bouncycastle.asn1.x509.KeyPurposeId.id_kp_serverAuth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。