Package org.bouncycastle.jce

Examples of org.bouncycastle.jce.PKCS10CertificationRequest


        }

        DERObject derobj = new ASN1InputStream(new ByteArrayInputStream(decBytes)).readObject();
        if (messageType == ScepRequestMessage.SCEP_TYPE_PKCSREQ) {
            ASN1Sequence seq = (ASN1Sequence) derobj;
            pkcs10 = new PKCS10CertificationRequest(seq);
            if (log.isDebugEnabled()) {
              log.debug("Successfully extracted PKCS10:"+new String(Base64.encode(pkcs10.getEncoded())));
            }
        }
        if (messageType == ScepRequestMessage.SCEP_TYPE_GETCRL) {
View Full Code Here


    final byte[] requestBytes = RequestMessageUtils.getDecodedBytes(bytes);
    ret = getCvcDump(false);
    if ((ret == null) && (requestBytes != null) && (requestBytes.length > 0)) {
      // Not a CVC request, perhaps a PKCS10 request
      try {
        final PKCS10CertificationRequest pkcs10 = new PKCS10CertificationRequest(requestBytes);
//        ret = pkcs10.toString();
        final ASN1InputStream ais = new ASN1InputStream(new ByteArrayInputStream(pkcs10.getEncoded()));
        final DERObject obj = ais.readObject();
        ret = ASN1Dump.dumpAsString(obj);
        type = "PKCS#10";
      } catch (IOException e1) {
         // ignore, move on to certificate decoding
View Full Code Here

                requestBytes = result.getContent();
                request.setSignerChain(result.getSignerChain());
            }

            // Parse PKCS10 and fill in requested DN
            PKCS10CertificationRequest pkcs10 = getPkcs10Request(requestBytes);
            request.setRequestedDN(pkcs10.getCertificationRequestInfo()
                    .getSubject().toString());

            request.setInFile(inFile);
            request.setOutFile(new File(inFile.getParentFile(),
                    suggestOutFile(inFile.getName())));
View Full Code Here

        }
    }

    private PKCS10CertificationRequest getPkcs10Request(byte[] requestBytes)
            throws IOException, IllegalArgumentException {
        return new PKCS10CertificationRequest(
                RequestMessageUtils.getRequestBytes(requestBytes));
    }
View Full Code Here

                } catch (IOException e) {
                  log.debug("Uploaded file was not a PEM.. tryin to parse it as a DER encoded request.");
                }
                // See if it as a PKCS10
                try {
                    new PKCS10CertificationRequest(buf);
                } catch (Exception e) {
                  context.addMessage(null /*actionEvent.getComponent().getClientId(context)*/, new FacesMessage(FacesMessage.SEVERITY_ERROR, getMessage("enroll.csrcert.uploadfailednotpkcs10"), null));
                  log.debug("Rejected uploaded file since it's not a valid PKCS#10 request.");
                  return;
                }
View Full Code Here

      buf = FileTools.getBytesFromPEM(buf, PEM_CSR_BEGIN, PEM_CSR_END);
      certificateRequest = PEM_CSR_BEGIN + "\n" + new String(Base64.encode(buf)) + "\n" + PEM_CSR_END;
      if (log.isDebugEnabled()) {
              log.debug("cleaned req: " + certificateRequest);
      }
            new PKCS10CertificationRequest(buf);
    } catch (Exception e) {
      context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, getMessage("enroll.invalidreqdata"), null));
      return;
    }
    // Determine what kind of response the user has requested
View Full Code Here

        certificateRequest = certificateRequest.replaceAll(PEM_CSR_END_VISTA, PEM_CSR_END);
        if (certificateRequest.indexOf(PEM_CSR_BEGIN) == -1) {
          certificateRequest = PEM_CSR_BEGIN + "\n" + certificateRequest + "\n" + PEM_CSR_END;
        }
        buf = FileTools.getBytesFromPEM(certificateRequest.getBytes(), PEM_CSR_BEGIN, PEM_CSR_END);
              new PKCS10CertificationRequest(buf);
      } catch (Exception e) {
        log.error("",e);
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, getMessage("enroll.invalidreqdata"), null));
        return;
      }
View Full Code Here

    }

    protected void generatePkcs10() throws Exception {

        KeyPair keys = KeyTools.genKeys("1024", AlgorithmConstants.KEYALGORITHM_RSA);
        PKCS10CertificationRequest pkcs10 = new PKCS10CertificationRequest("SHA1WithRSA", CertTools.stringToBcX509Name("CN=NOUSED"), keys.getPublic(),
                new DERSet(), keys.getPrivate());

        CertificateResponse certenv = ejbcaraws.pkcs10Request(CA1_WSTESTUSER1, "foo123", new String(Base64.encode(pkcs10.getEncoded())), null,
                CertificateHelper.RESPONSETYPE_CERTIFICATE);

        assertNotNull(certenv);

        X509Certificate cert = (X509Certificate) CertificateHelper.getCertificate(certenv.getData());
View Full Code Here

     * Generate a new key pair and return a B64 encoded PKCS#10 encoded
     * certificate request for the keypair.
     */
    private String getP10() throws Exception {
        final KeyPair keys = KeyTools.genKeys("1024", AlgorithmConstants.KEYALGORITHM_RSA);
        return new String(Base64.encode(new PKCS10CertificationRequest("SHA1WithRSA", CertTools.stringToBcX509Name("CN=NOUSED"), keys.getPublic(),
                new DERSet(), keys.getPrivate()).getEncoded()));
    }
View Full Code Here

        tokenUser1.setTokenType(UserDataVOWS.TOKEN_TYPE_USERGENERATED);
        tokenUser1.setEndEntityProfileName("EMPTY");
        tokenUser1.setCertificateProfileName("ENDUSER");

        KeyPair basickeys = KeyTools.genKeys("1024", AlgorithmConstants.KEYALGORITHM_RSA);
        PKCS10CertificationRequest basicpkcs10 = new PKCS10CertificationRequest("SHA1WithRSA", CertTools.stringToBcX509Name("CN=NOUSED"),
                basickeys.getPublic(), new DERSet(), basickeys.getPrivate());

        ArrayList<TokenCertificateRequestWS> requests = new ArrayList<TokenCertificateRequestWS>();
        TokenCertificateRequestWS tokenCertReqWS = new TokenCertificateRequestWS();
        tokenCertReqWS.setCAName(getAdminCAName());
        tokenCertReqWS.setCertificateProfileName("WSTESTPROFILE");
        tokenCertReqWS.setValidityIdDays("1");
        tokenCertReqWS.setPkcs10Data(basicpkcs10.getDEREncoded());
        tokenCertReqWS.setType(HardTokenConstants.REQUESTTYPE_PKCS10_REQUEST);
        requests.add(tokenCertReqWS);
        tokenCertReqWS = new TokenCertificateRequestWS();
        tokenCertReqWS.setCAName(getAdminCAName());
        tokenCertReqWS.setCertificateProfileName("ENDUSER");
View Full Code Here

TOP

Related Classes of org.bouncycastle.jce.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.