Package org.bouncycastle.asn1.x500

Examples of org.bouncycastle.asn1.x500.RDN


    builder.addRDN(BCStyle.CN, value);
    return builder.build();
  }

  public static X500Principal toX500Principal(final String value) throws IOException {
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
    builder.addRDN(BCStyle.CN, value);
    X500Name name = builder.build();
    return BouncyCastleProviderHelper.toX500Principal(name);
  }
View Full Code Here


    ASN1Sequence sequence = (ASN1Sequence) BouncyCastleProviderHelper.toASN1Primitive(bytes);
    return sequence;
  }

  public static X500Name toX500Name(final String value) {
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
    builder.addRDN(BCStyle.CN, value);
    return builder.build();
  }
View Full Code Here

    X500Name x500Name = new X500Name(principal.getName());
    return x500Name;
  }

  public static X500Principal toX500Principal(final String value) throws IOException {
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
    builder.addRDN(BCStyle.CN, value);
    X500Name name = builder.build();
    return BouncyCastleProviderHelper.toX500Principal(name);
  }
View Full Code Here

    calendar.add(Calendar.YEAR, 20);
    Date expirationDate = calendar.getTime();
   
    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

   */
  public static X509Certificate generateSelfSignedCertificate(String commonName, KeyPair keyPair) throws OperatorCreationException, CertificateException,
      InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException {
   
    // Certificate CN, O and OU
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
   
    builder.addRDN(BCStyle.CN, commonName);
    builder.addRDN(BCStyle.O, CipherParams.CERTIFICATE_ORGANIZATION);
    builder.addRDN(BCStyle.OU, CipherParams.CERTIFICATE_ORGUNIT);

    // Dates and serial
    Date notBefore = new Date(System.currentTimeMillis() - 1*24*60*60*1000L);
    Date notAfter = new Date(System.currentTimeMillis() + 5*365*24*60*60*1000L);
    BigInteger serial = BigInteger.valueOf(System.currentTimeMillis());

    // Issuer and subject (identical, because self-signed)
    X500Name issuer = builder.build();
    X500Name subject = issuer;
   
    X509v3CertificateBuilder certificateGenerator =
      new JcaX509v3CertificateBuilder(issuer, serial, notBefore, notAfter, subject, keyPair.getPublic());
   
View Full Code Here

      KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC");
      kpGen.initialize(1024, new SecureRandom());
      KeyPair pair = kpGen.generateKeyPair();

      // Generate self-signed certificate
      X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
      builder.addRDN(BCStyle.OU, Constants.getName());
      builder.addRDN(BCStyle.O, Constants.getName());
      builder.addRDN(BCStyle.CN, hostname);

      Date notBefore = new Date(System.currentTimeMillis() - ONEDAY);
      Date notAfter = new Date(System.currentTimeMillis() + 10 * ONEYEAR);
      BigInteger serial = BigInteger.valueOf(System.currentTimeMillis());

      X509v3CertificateBuilder certGen = new JcaX509v3CertificateBuilder(builder.build(),
          serial, notBefore, notAfter, builder.build(), pair.getPublic());
      ContentSigner sigGen = new JcaContentSignerBuilder("SHA256WithRSAEncryption")
          .setProvider(BC).build(pair.getPrivate());
      X509Certificate cert = new JcaX509CertificateConverter().setProvider(BC)
          .getCertificate(certGen.build(sigGen));
      cert.checkValidity(new Date());
View Full Code Here

    inputStream.close();
    return obj;
  }

  public static X500Name toX500Name(final String value) {
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
    builder.addRDN(BCStyle.CN, value);
    return builder.build();
  }
View Full Code Here

    builder.addRDN(BCStyle.CN, value);
    return builder.build();
  }

  public static X500Principal toX500Principal(final String value) throws IOException {
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
    builder.addRDN(BCStyle.CN, value);
    X500Name name = builder.build();
    return BouncyCastleProviderHelper.toX500Principal(name);
  }
View Full Code Here

     *
     * @param restriction The describtion of the restriction.
     */
    public Restriction(String restriction)
    {
        this.restriction = new DirectoryString(restriction);
    }
View Full Code Here

     *
     * @param information The describtion of the information.
     */
    public AdditionalInformationSyntax(String information)
    {
        this(new DirectoryString(information));
    }
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.