Package org.bouncycastle.asn1.x500

Examples of org.bouncycastle.asn1.x500.RDN


   */
  public String getUserCertificateOrg()
     throws CertificateEncodingException
  {
    X500Name x500name = new JcaX509CertificateHolder(userCertificate).getSubject();
    RDN org = x500name.getRDNs(BCStyle.O)[0];

    return IETFUtils.valueToString(org.getFirst().getValue());
  }
View Full Code Here


    return digestType;
  }

  protected String getValue(final X509Principal principal) {
    X500Name x500Name = new X500Name(principal.getName());
    RDN rdn = x500Name.getRDNs(BCStyle.CN)[0];
    return IETFUtils.valueToString(rdn.getFirst().getValue());
  }
View Full Code Here

    return IETFUtils.valueToString(rdn.getFirst().getValue());
  }

  protected String getValue(final X500Principal principal) {
    X500Name x500Name = new X500Name(principal.getName());
    RDN rdn = x500Name.getRDNs(BCStyle.CN)[0];
    return IETFUtils.valueToString(rdn.getFirst().getValue());
  }
View Full Code Here

      KeyStore userKeyStore = UserConfig.getUserKeyStore();
      X509Certificate currentCertificate = (X509Certificate) userKeyStore.getCertificate(CipherParams.CERTIFICATE_IDENTIFIER);
     
      if (currentCertificate != null) {
        X500Name currentCertificateSubject = new JcaX509CertificateHolder(currentCertificate).getSubject();
        RDN currentCertificateSubjectCN = currentCertificateSubject.getRDNs(BCStyle.CN)[0];

        String currentCertificateSubjectCnStr = IETFUtils.valueToString(currentCertificateSubjectCN.getFirst().getValue());
       
        if (!certificateCommonName.equals(currentCertificateSubjectCnStr)) {
          logger.log(Level.INFO, "- Certificate regeneration necessary: Cert common name in daemon config changed from " + currentCertificateSubjectCnStr + " to " + certificateCommonName + ".");
          return true;
        }       
View Full Code Here

    super();
    this.csr = csr;
  }

  public static Csr buildCsr(KeyPair keyPair, X500Principal subjectName) {
    X500Name subject = BouncyCastleHelpers.toX500Name(subjectName);
    SubjectPublicKeyInfo publicKeyInfo = BouncyCastleHelpers.toSubjectPublicKeyInfo(keyPair.getPublic());
    PKCS10CertificationRequestBuilder csrBuilder = new PKCS10CertificationRequestBuilder(subject, publicKeyInfo);

    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1withRSA");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
View Full Code Here

    return csrHolder;
  }

  public X509Certificate signCsr(PKCS10CertificationRequest csr) throws OpsException {
    SubjectPublicKeyInfo subjectPublicKeyInfo = csr.getSubjectPublicKeyInfo();
    X500Name subject = csr.getSubject();
    Certificate certificate = signCertificate(
        BouncyCastleHelpers.toX500Name(caCertificate[0].getSubjectX500Principal()), caPrivateKey, subject,
        subjectPublicKeyInfo);
    return toX509(certificate);
  }
View Full Code Here

  public static X509Certificate selfSign(String csr, KeyPair keyPair) throws OpsException {
    try {
      PKCS10CertificationRequest csrHolder = parseCsr(csr);

      SubjectPublicKeyInfo subjectPublicKeyInfo = csrHolder.getSubjectPublicKeyInfo();
      X500Name subject = csrHolder.getSubject();

      // Self sign
      X500Name issuer = subject;
      PrivateKey issuerPrivateKey = keyPair.getPrivate();

      Certificate certificate = signCertificate(issuer, issuerPrivateKey, subject, subjectPublicKeyInfo);
      return toX509(certificate);
    } catch (IOException e) {
View Full Code Here

        {
            this.obj = new ASN1ObjectIdentifier(name);
        }
        else if (tag == directoryName)
        {
            this.obj = new X500Name(name);
        }
        else if (tag == iPAddress)
        {
            byte[] enc = toGeneralNameEncoding(name);
            if (enc != null)
View Full Code Here

        certGen.addExtension("2.5.29.37", true,
            new DERSequence(KeyPurposeId.anyExtendedKeyUsage));
        certGen.addExtension(Extension.subjectAlternativeName.getId(), true,
            new GeneralNames(new GeneralName(GeneralName.rfc822Name, "test@test.test")));
        certGen.addExtension(Extension.issuerAlternativeName, false,
            new GeneralNames(new GeneralName(GeneralName.directoryName, new X500Name("O=Test, OU=Testing, C=AU"))));

        X509Certificate baseCert = certGen.generate(privKey, "BC");

        Collection names = baseCert.getSubjectAlternativeNames();
View Full Code Here

            Vector encDNs = new Vector(certificateAuthorities.size());
            int totalLength = 0;
            for (int i = 0; i < certificateAuthorities.size(); ++i)
            {
                X500Name authorityDN = (X500Name)certificateAuthorities.elementAt(i);
                byte[] encDN = authorityDN.getEncoded(ASN1Encoding.DER);
                encDNs.addElement(encDN);
                totalLength += encDN.length;
            }

            TlsUtils.writeUint16(totalLength, output);
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.