Package org.bouncycastle.asn1.x500

Examples of org.bouncycastle.asn1.x500.RDN


  public static X509Certificate newClientCertificate(X509Metadata clientMetadata,
      PrivateKey caPrivateKey, X509Certificate caCert, File targetFolder) {
    try {
      KeyPair pair = newKeyPair();

      X500Name userDN = buildDistinguishedName(clientMetadata);
      X500Name issuerDN = new X500Name(PrincipalUtil.getIssuerX509Principal(caCert).getName());

      // create a new certificate signed by the Gitblit CA certificate
      X509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(
          issuerDN,
          BigInteger.valueOf(System.currentTimeMillis()),
View Full Code Here


   * @return true if the certificate has been revoked
   */
  public static boolean revoke(X509Certificate cert, RevocationReason reason,
       File caRevocationList, PrivateKey caPrivateKey, X509Log x509log) {
    try {
      X500Name issuerDN = new X500Name(PrincipalUtil.getIssuerX509Principal(cert).getName());
      X509v2CRLBuilder crlBuilder = new X509v2CRLBuilder(issuerDN, new Date());
      if (caRevocationList.exists()) {
        byte [] data = FileUtils.readContent(caRevocationList);
        X509CRLHolder crl = new X509CRLHolder(data);
        crlBuilder.addCRL(crl);
View Full Code Here

            KeyPairGenerator keyPairGenerator = KeyPairGenerator
                    .getInstance("RSA");
            keyPairGenerator.initialize(1024);
            KeyPair kp = keyPairGenerator.generateKeyPair();
            X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
                    new X500Name("CN=0.0.0.0, OU=None, O=None, L=None, C=None"),
                    BigInteger.valueOf(new SecureRandom().nextInt()), new Date(
                            System.currentTimeMillis() - 1000L * 60 * 60 * 24
                                    * 30), new Date(System.currentTimeMillis()
                            + (1000L * 60 * 60 * 24 * 365 * 10)), new X500Name(
                            "CN=0.0.0.0, OU=None, O=None, L=None, C=None"),
                    SubjectPublicKeyInfo.getInstance(kp.getPublic()
                            .getEncoded()));
            ContentSigner signer = new JcaContentSignerBuilder(
                    "SHA256WithRSAEncryption").build(kp.getPrivate());
View Full Code Here

   
    BigInteger serial = new BigInteger(snBytes).abs();
   
    X500NameBuilder nameBuilder = new X500NameBuilder(BCStyle.INSTANCE);
    nameBuilder.addRDN(BCStyle.CN, "NVIDIA GameStream Client");
    X500Name name = nameBuilder.build();
   
    X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(name, serial, now, expirationDate, Locale.ENGLISH, name,
        SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded()));

    try {
View Full Code Here

            boolean caFlag, int pathLength, String crlUri, String ocspUri,
            KeyUsage keyUsage)
    throws IOException, OperatorCreationException, CertificateException
    {
        String signatureAlgorithm = "SHA1withRSA";
        X500Name issuerName;
        if (issuerCertificate != null) {
            issuerName = new X509CertificateHolder(issuerCertificate.getEncoded()).getIssuer();
        } else {
            issuerName = new X500Name(subjectDn);
        }
       
        RSAPublicKey rsaPubKey = (RSAPublicKey)subjectPublicKey;
        RSAKeyParameters rsaSpec = new RSAKeyParameters(false, rsaPubKey.getModulus(), rsaPubKey.getPublicExponent());

        SubjectPublicKeyInfo subjectPublicKeyInfo =
            SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(rsaSpec);

        DigestCalculator digestCalc = new JcaDigestCalculatorProviderBuilder()
            .setProvider("BC").build().get(CertificateID.HASH_SHA1);
       
        X509v3CertificateBuilder certificateGenerator = new X509v3CertificateBuilder(
              issuerName
            , new BigInteger(128, new SecureRandom())
            , notBefore
            , notAfter
            , new X500Name(subjectDn)
            , subjectPublicKeyInfo
        );

        X509ExtensionUtils exUtils = new X509ExtensionUtils(digestCalc);
        SubjectKeyIdentifier subKeyId = exUtils.createSubjectKeyIdentifier(subjectPublicKeyInfo);
View Full Code Here

                    if (2 == derTaggedObject.getTagNo()) {
                        ASN1OctetString keyHashOctetString = (ASN1OctetString)derTaggedObject.getObject();
                        byte key[] = keyHashOctetString.getOctets();
                        responderId.setByKey(key);
                    } else {
                        X500Name name = X500Name.getInstance(derTaggedObject.getObject());
                        String nameStr = name.toString();
                        responderId.setByName(nameStr);
                    }
                } catch (Exception e) {
                    throw new RuntimeException("OCSP decoding error: " + e.getMessage(), e);
                }
View Full Code Here

                    + timeStampResponse.getStatus());
        }
        TimeStampToken timeStampToken = timeStampResponse.getTimeStampToken();
        SignerId signerId = timeStampToken.getSID();
        BigInteger signerCertSerialNumber = signerId.getSerialNumber();
        X500Name signerCertIssuer = signerId.getIssuer();
        LOG.log(POILogger.DEBUG, "signer cert serial number: " + signerCertSerialNumber);
        LOG.log(POILogger.DEBUG, "signer cert issuer: " + signerCertIssuer);

        // TSP signer certificates retrieval
        Collection<X509CertificateHolder> certificates = timeStampToken.getCertificates().getMatches(null);
       
        X509CertificateHolder signerCert = null;
        Map<X500Name, X509CertificateHolder> certificateMap = new HashMap<X500Name, X509CertificateHolder>();
        for (X509CertificateHolder certificate : certificates) {
            if (signerCertIssuer.equals(certificate.getIssuer())
                && signerCertSerialNumber.equals(certificate.getSerialNumber())) {
                signerCert = certificate;
            }
            certificateMap.put(certificate.getSubject(), certificate);
        }
View Full Code Here

        } catch (IOException e) {
            throw new InvalidKeyException("Can not parse the public key"
                    + "being included in the short lived certificate", e);
        }

        X500Name issuerX500Name = CertificateHelpers.toX500Name(caCred.getCertificate().getSubjectX500Principal());

        X500Name subjectX500Name = CertificateHelpers.toX500Name(subjectDN);

        X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(issuerX500Name, new BigInteger(20, rand),
                new Date(startTime), new Date(endTime), subjectX500Name, publicKeyInfo);

        AlgorithmIdentifier sigAlgId = X509v3CertificateBuilder.extractAlgorithmId(caCred.getCertificate());
View Full Code Here

    Calendar startDate = Calendar.getInstance();
    Calendar endDate = Calendar.getInstance();
    endDate.add(Calendar.YEAR, 100);

    BigInteger serialNumber = BigInteger.valueOf((startDate.getTimeInMillis()));
    X500Name issuer = new X500Name(IETFUtils.rDNsFromString(issuerDirString, RFC4519Style.INSTANCE));
    JcaX509v3CertificateBuilder certGen = new JcaX509v3CertificateBuilder(issuer, serialNumber, startDate.getTime(), endDate.getTime(), issuer, kp.getPublic());
    JcaX509ExtensionUtils extensionUtils = new JcaX509ExtensionUtils();
    certGen.addExtension(Extension.subjectKeyIdentifier, false, extensionUtils.createSubjectKeyIdentifier(kp.getPublic()));
    certGen.addExtension(Extension.basicConstraints, false, new BasicConstraints(isCertAuthority));
    certGen.addExtension(Extension.authorityKeyIdentifier, false, extensionUtils.createAuthorityKeyIdentifier(signerPublicKey));
View Full Code Here

    converter.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
    return converter.getCertificate(holder);
  }

  public static String getName(final X500Principal principal) {
    X500Name x500Name = new X500Name(principal.getName());
    return BouncyCastleProviderHelper.getName(x500Name);
  }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.x500.RDN

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.