Package org.bouncycastle.pkcs

Examples of org.bouncycastle.pkcs.PKCS10CertificationRequest


    return null;
  }

  public PKCS10CertificationRequest parse(String s) {
    PKCS10CertificationRequest key = null;

    if (key == null) {
      try {
        key = parsePemFormat(s);
      } catch (Exception e) {
View Full Code Here


  private PKCS10CertificationRequest parsePemFormat(String data) throws IOException {
    PemReader reader = new PemReader(new StringReader(data));
    PemObject pemObject = reader.readPemObject();
    reader.close();

    PKCS10CertificationRequest csr = new PKCS10CertificationRequest(pemObject.getContent());
    return csr;
  }
View Full Code Here

      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

    return new Csr(csrHolder);
  }

  public static Csr parse(String encoded) {
    CsrParser parser = new CsrParser();
    PKCS10CertificationRequest csr = parser.parse(encoded);
    if (csr == null) {
      throw new IllegalArgumentException("Cannot parse CSR");
    }

    return new Csr(csr);
View Full Code Here

  // }
  // }

  public X509Certificate signCsr(String csr) throws OpsException {
    try {
      PKCS10CertificationRequest csrHolder = parseCsr(csr);
      return signCsr(csrHolder);
    } catch (IOException e) {
      throw new OpsException("Error reading CSR", e);
    }
  }
View Full Code Here

  private static PKCS10CertificationRequest parseCsr(String csr) throws IOException {
    PemReader reader = new PemReader(new StringReader(csr));
    PemObject pemObject = reader.readPemObject();
    reader.close();

    PKCS10CertificationRequest csrHolder = new PKCS10CertificationRequest(pemObject.getContent());
    return csrHolder;
  }
View Full Code Here

    return toX509(certificate);
  }

  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();
View Full Code Here

  X500Name issuer = new X500Name("CN=CA");
  X500Name subject = new X500Name("CN=Client");
  IssuerAndSubject ias = new IssuerAndSubject(issuer, subject);
  BigInteger serial = BigInteger.ONE;
  IssuerAndSerialNumber iasn = new IssuerAndSerialNumber(issuer, serial);
  PKCS10CertificationRequest csr = getCsr(new X500Principal("CN=Client"),
    pair.getPublic(), pair.getPrivate(), "password".toCharArray());
  CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
  ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA")
    .build(pair.getPrivate());
  X509Certificate cert = X509Certificates.createEphemeral(
View Full Code Here

    assertThat(s, is(State.CERT_NON_EXISTANT));
  }

  @Test
  public void testEnrollmentGet() throws Exception {
    PKCS10CertificationRequest csr = getCsr(name, pubKey, priKey,
        "password".toCharArray());

    PkcsPkiEnvelopeEncoder envEncoder = new PkcsPkiEnvelopeEncoder(
        getRecipient(), "DESede");
    PkiMessageEncoder encoder = new PkiMessageEncoder(priKey, sender,
View Full Code Here

    assertThat(s, is(State.CERT_ISSUED));
  }

  @Test
  public void testEnrollmentPost() throws Exception {
    PKCS10CertificationRequest csr = getCsr(name, pubKey, priKey,
        "password".toCharArray());

    PkcsPkiEnvelopeEncoder envEncoder = new PkcsPkiEnvelopeEncoder(
        getRecipient(), "DES");
    PkiMessageEncoder encoder = new PkiMessageEncoder(priKey, sender,
View Full Code Here

TOP

Related Classes of org.bouncycastle.pkcs.PKCS10CertificationRequest

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.