Package org.bouncycastle.pkcs

Examples of org.bouncycastle.pkcs.PKCS10CertificationRequestBuilder


  }

  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);

    BcRSAContentSignerBuilder sigBuild = new BcRSAContentSignerBuilder(sigAlgId, digAlgId);
    ContentSigner signer;
    try {
      signer = sigBuild.build(BouncyCastleHelpers.toAsymmetricKeyParameter(keyPair.getPrivate()));
    } catch (OperatorCreationException e) {
      throw new IllegalArgumentException("Error building content signer", e);
    }

    PKCS10CertificationRequest csrHolder = csrBuilder.build(signer);

    return new Csr(csrHolder);
  }
View Full Code Here


      ioe.initCause(e);

      throw ioe;
  }

  PKCS10CertificationRequestBuilder builder = new PKCS10CertificationRequestBuilder(
    X500Name.getInstance(subject.getEncoded()), pkInfo);
  builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword,
    cpSet);

  return builder.build(signer);
    }
View Full Code Here

      ioe.initCause(e);

      throw ioe;
    }

    PKCS10CertificationRequestBuilder builder = new PKCS10CertificationRequestBuilder(
        subject, pkInfo);
    builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword,
        new DERPrintableString(new String(password)));

    return builder.build(signer);
  }
View Full Code Here

      X500Name entityName = new X500Name("CN=entity");
      KeyPair entityPair = KeyPairGenerator.getInstance("RSA").genKeyPair();
      SubjectPublicKeyInfo publicKeyInfo = SubjectPublicKeyInfo
          .getInstance(entityPair.getPublic().getEncoded());
      // Generate the certificate signing request
      PKCS10CertificationRequestBuilder csrBuilder = new PKCS10CertificationRequestBuilder(
          entityName, publicKeyInfo);
      // SCEP servers usually require a challenge password
      csrBuilder.addAttribute(
          PKCSObjectIdentifiers.pkcs_9_at_challengePassword,
          new DERPrintableString(new String("password".toCharArray())));
      ContentSigner signer = signerBuilder.build(entityPair.getPrivate());
      PKCS10CertificationRequest csr = csrBuilder.build(signer);
 
      // Send the enrollment request
      EnrollmentResponse response = client
          .enrol(id, idPair.getPrivate(), csr);
      if (response.isFailure()) {
View Full Code Here

      ioe.initCause(e);

      throw ioe;
    }

    PKCS10CertificationRequestBuilder builder = new PKCS10CertificationRequestBuilder(
        X500Name.getInstance(subject.getEncoded()), pkInfo);
    builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword,
        cpSet);

    return builder.build(signer);
  }
View Full Code Here

    }

    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);

        BcRSAContentSignerBuilder sigBuild = new BcRSAContentSignerBuilder(sigAlgId, digAlgId);
        ContentSigner signer;
        try {
            signer = sigBuild.build(BouncyCastleHelpers.toAsymmetricKeyParameter(keyPair.getPrivate()));
        } catch (OperatorCreationException e) {
            throw new IllegalArgumentException("Error building content signer", e);
        }

        PKCS10CertificationRequest csrHolder = csrBuilder.build(signer);

        return new Csr(csrHolder);
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle.pkcs.PKCS10CertificationRequestBuilder

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.