Package org.ejbca.core.protocol

Examples of org.ejbca.core.protocol.PKCS10RequestMessage


     */
    public byte[] pkcs10CertRequest(SignSessionLocal signsession, byte[] b64Encoded,
        String username, String password, int resulttype, boolean doSplitLines) throws Exception {
        byte[] result = null
        Certificate cert=null;
    PKCS10RequestMessage req = RequestMessageUtils.genPKCS10RequestMessage(b64Encoded);
    req.setUsername(username);
        req.setPassword(password);
        IResponseMessage resp = signsession.createCertificate(administrator, req, X509ResponseMessage.class, null);
        cert = CertTools.getCertfromByteArray(resp.getResponseMessage());
        if(resulttype == ENCODED_CERTIFICATE) {
          result = cert.getEncoded();
        } else
View Full Code Here


          userData.setCertificateProfileId(certificateProfileId);
          userData.setCAId(cAInfo.getCAId());
          userData.setPassword(password);
          userData.setStatus(UserDataConstants.STATUS_NEW);
          userAdminSession.changeUser(admin, userData, false);
          PKCS10RequestMessage pkcs10req = new PKCS10RequestMessage(next.getPkcs10Data());
          java.security.cert.Certificate cert;
          if(eDate == null){
              cert =  signSession.createCertificate(admin,userData.getUsername(),password, pkcs10req.getRequestPublicKey());
          }else{
            cert =  signSession.createCertificate(admin,userData.getUsername(),password, pkcs10req.getRequestPublicKey(), -1, bDate, eDate);
          }
         
          genCertificates.add(cert);
          retval.add(new TokenCertificateResponseWS(new Certificate(cert)));
        }else
View Full Code Here

        log.trace("<test04TestPixScep()");
    } */
   
    public void test05KeyToolP10() throws Exception {
        log.trace(">test05KeyToolP10()");
        PKCS10RequestMessage msg = new PKCS10RequestMessage(keytoolp10);

        boolean ret = msg.verify();
        assertTrue(ret);
        String dn = msg.getRequestDN();
        log.debug("DN: " + dn);
        assertEquals("CN=Test,O=AnaTom,C=SE", dn);
        String pwd = msg.getPassword();
        assertNull(pwd);
        String username = msg.getUsername();
        assertEquals("Test", username);
        PublicKey pk = msg.getRequestPublicKey();
        assertNotNull(pk);
        String alg = pk.getAlgorithm();
        assertEquals("RSA",alg);
       
        log.trace("<test05KeyToolP10()");       
View Full Code Here

        log.trace("<test05KeyToolP10()");       
    }

    public void test06OldBCP10() throws Exception {
        log.trace(">test06OldBCP10()");
        PKCS10RequestMessage msg = new PKCS10RequestMessage(oldbcp10);

        boolean ret = msg.verify();
        assertTrue(ret);
        String dn = msg.getRequestDN();
        log.debug("DN: " + dn);
        assertEquals("C=SE,O=AnaTom,CN=Test", dn);
        String pwd = msg.getPassword();
        assertNull(pwd);
        String username = msg.getUsername();
        assertEquals("Test", username);
        PublicKey pk = msg.getRequestPublicKey();
        assertNotNull(pk);
        String alg = pk.getAlgorithm();
        assertEquals("RSA",alg);
       
        log.trace("<test06OldBCP10()");       
View Full Code Here

       
        log.trace("<test06OldBCP10()");       
    }
    public void test07IEP10() throws Exception {
        log.trace(">test07IEP10()");
        PKCS10RequestMessage msg = new PKCS10RequestMessage(iep10);

        boolean ret = msg.verify();
        assertTrue(ret);
        String dn = msg.getRequestDN();
        log.debug("DN: " + dn);
        assertEquals("CN=6AEK347fw8vWE424", dn);
        String pwd = msg.getPassword();
        assertNull(pwd);
        String username = msg.getUsername();
        assertEquals("6AEK347fw8vWE424", username);
        PublicKey pk = msg.getRequestPublicKey();
        assertNotNull(pk);
        String alg = pk.getAlgorithm();
        assertEquals("RSA",alg);
       
        log.trace("<test07IEP10()");       
View Full Code Here

    }

    public void test08AltNameP10() throws Exception {
     
      // P10 generated with openssl
        PKCS10RequestMessage msg = new PKCS10RequestMessage(altnamep10);

        boolean ret = msg.verify();
        assertTrue(ret);
        String dn = msg.getRequestDN();
        assertEquals("C=AU,CN=asd,E=asd@sdf.se", dn);
        String pwd = msg.getPassword();
        assertEquals("dsfsdf", pwd);
        String username = msg.getUsername();
        assertEquals("asd", username);
        PublicKey pk = msg.getRequestPublicKey();
        assertNotNull(pk);
        String alg = pk.getAlgorithm();
        assertEquals("RSA",alg);
       
        // Get altNames if we can find them
        String altNames = msg.getRequestAltNames();
        assertEquals("rfc822name=foo@bar.se",altNames);
    }
View Full Code Here

  public static PKCS10RequestMessage genPKCS10RequestMessage(byte[] bytes) {
    byte[] buffer = getDecodedBytes(bytes);
    if (buffer == null) {
      return null;
    }   
    return new PKCS10RequestMessage(buffer);
  } // genPKCS10RequestMessageFromPEM
View Full Code Here

        String certf = args[4];
        try {
      byte[] bytes = FileTools.readFiletoBuffer(csr);
      IRequestMessage req = RequestMessageUtils.parseRequestMessage(bytes);
      if (req instanceof PKCS10RequestMessage) {
        PKCS10RequestMessage p10req = (PKCS10RequestMessage) req;
        p10req.setUsername(username);
        p10req.setPassword(password);
      } else {
        getLogger().error("Input file '"+csr+"' is not a PKCS#10 request.");
        return;
      }
      // Call signsession to create a certificate
View Full Code Here

                responseTypeInt);            
          } else {
            switch (submessage.getRequestType()) {
            case CertificateRequestRequest.REQUEST_TYPE_PKCS10:
              Certificate cert = null;
              PKCS10RequestMessage req = RequestMessageUtils.genPKCS10RequestMessage(submessage.getRequestData());
              req.setUsername(submessage.getUsername());
              req.setPassword(submessage.getPassword());
              IResponseMessage resp = signSession.createCertificate(admin, req, X509ResponseMessage.class, null);
              cert = CertTools.getCertfromByteArray(resp.getResponseMessage());
              if (submessage.getResponseType() == CertificateRequestRequest.RESPONSE_TYPE_CERTIFICATE) {
                result = cert.getEncoded();
              } else
View Full Code Here

        String pwd = "foo123"; // use default hard coded soft CA token password
        // first we just try to create a simple request from an active X.509 CA.
        // A request like this can be used to request a cross certificate
        byte[] request = ejbcaraws.caRenewCertRequest(getAdminCAName(), cachain, false, false, false, pwd);
        assertNotNull(request);
        PKCS10RequestMessage msg = RequestMessageUtils.genPKCS10RequestMessage(request);
        assertNotNull(msg);
        CAInfo info = caAdminSessionRemote.getCAInfo(intAdmin, getAdminCAName());
        assertEquals(info.getSubjectDN(), msg.getRequestDN());
        assertTrue(msg.verify());
        // System.out.println(ASN1Dump.dumpAsString(msg.getCertificationRequest()));

        /*
         * First test is to renew a CA signed by an external CA *without
         * renewing the keys*. This just creates a new certificate request,
View Full Code Here

TOP

Related Classes of org.ejbca.core.protocol.PKCS10RequestMessage

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.