Examples of CertificateResponse


Examples of br.net.woodstock.rockframework.security.cert.CertificateResponse

          }
        }
      }

      BouncyCastleCertificateRequest bcRequest = new BouncyCastleCertificateRequest(request);
      CertificateResponse response = null;

      if (CertificateVersionType.V3.equals(bcRequest.getVersion())) {
        response = this.buildV3Certificate(bcRequest);
      } else {
        response = this.buildV1Certificate(bcRequest);
View Full Code Here

Examples of br.net.woodstock.rockframework.security.cert.CertificateResponse

    X509CertificateHolder holder = builder.build(contentSigner);

    X509Certificate certificate = (X509Certificate) Certificates.get(holder.getEncoded());
    PrivateKey privateKey = request.getPrivateKey();
    Identity identity = new Identity(privateKey, new Certificate[] { certificate });
    CertificateResponse response = new CertificateResponse(identity);

    return response;
  }
View Full Code Here

Examples of br.net.woodstock.rockframework.security.cert.CertificateResponse

      certificate.verify(request.getIssuerCertificate().getPublicKey());
    }

    PrivateKey privateKey = request.getPrivateKey();
    Identity identity = new Identity(privateKey, new Certificate[] { certificate });
    CertificateResponse response = new CertificateResponse(identity);

    return response;
  }
View Full Code Here

Examples of br.net.woodstock.rockframework.security.cert.CertificateResponse

  @Override
  public CertificateResponse generate(final CertificateRequest request) {
    try {
      BouncyCastleCertificateRequest bcRequest = new BouncyCastleCertificateRequest(request);
      CertificateResponse response = null;

      if (CertificateVersionType.V3.equals(bcRequest.getVersion())) {
        response = this.buildV3Certificate(bcRequest);
      } else {
        response = this.buildV1Certificate(bcRequest);
View Full Code Here

Examples of br.net.woodstock.rockframework.security.cert.CertificateResponse

    X509CertificateHolder holder = builder.build(contentSigner);

    X509Certificate certificate = (X509Certificate) CertificateUtils.getCertificateFromFile(holder.getEncoded(), CertificateType.X509);
    PrivateKey privateKey = request.getPrivateKey();
    Identity identity = new Identity(privateKey, new Certificate[] { certificate });
    CertificateResponse response = new CertificateResponse(identity);

    return response;
  }
View Full Code Here

Examples of br.net.woodstock.rockframework.security.cert.CertificateResponse

      certificate.verify(request.getIssuerCertificate().getPublicKey());
    }

    PrivateKey privateKey = request.getPrivateKey();
    Identity identity = new Identity(privateKey, new Certificate[] { certificate });
    CertificateResponse response = new CertificateResponse(identity);

    return response;
  }
View Full Code Here

Examples of org.ejbca.core.protocol.ws.client.gen.CertificateResponse

        X509Certificate tmpCert = null;
        final Iterator<X509Certificate> i;
        try {
            final PKCS10CertificationRequest pkcs10 = new PKCS10CertificationRequest("SHA1WithRSA", CertTools.stringToBcX509Name("CN=NOUSED"), keyPair.getPublic(), new DERSet(),
                                                                                     keyPair.getPrivate(), this.privateKeyContainerKeyStore.providerName );
            final CertificateResponse certificateResponse = ejbcaWS.pkcs10Request(userData.getUsername(), userData.getPassword(),
                                                                                  new String(Base64.encode(pkcs10.getEncoded())),null,CertificateHelper.RESPONSETYPE_CERTIFICATE);
            i = (Iterator<X509Certificate>)CertificateFactory.getInstance("X.509").generateCertificates(new ByteArrayInputStream(Base64.decode(certificateResponse.getData()))).iterator();
        } catch (Exception e) {
            m_log.error("Certificate generation problem.", e);
            return null;
        }
        while ( i.hasNext() ) {
View Full Code Here

Examples of org.ejbca.core.protocol.ws.client.gen.CertificateResponse

                            user.setPassword(new String(password));
                            user.setStatus(10);
                            ejbcaWS.editUser(user);
                        }

                        final CertificateResponse response =
                                ejbcaWS.pkcs10Request(request.getEndEntity()
                                    .getUsername(),
                                new String(password),
                                new String(request.getRequestBytes()), null,
                                CertificateHelper.RESPONSETYPE_CERTIFICATE);

                        final String base64EncodedData
                                = new String(response.getData());

                        out.println("-----BEGIN CERTIFICATE-----");
                        out.println(base64EncodedData);
                        out.println("-----END CERTIFICATE-----");
                        request.setDone(true);
View Full Code Here

Examples of org.ejbca.core.protocol.ws.client.gen.CertificateResponse

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

        assertNotNull(cert);

        assertEquals(getDN(CA1_WSTESTUSER1), cert.getSubjectDN().toString());
View Full Code Here

Examples of org.ejbca.core.protocol.ws.client.gen.CertificateResponse

     * Certificate and PKCS#7. If the first one fails an error code will be
     * returned. I the second fails a Exception will be thrown.
     */
    private ErrorCode certreqInternal(UserDataVOWS userdata, String requestdata, int requesttype) throws Exception {
        // Request a certificate via the WS API
        final CertificateResponse certificateResponse;
        try {
            certificateResponse = ejbcaraws.certificateRequest(userdata, requestdata, requesttype, null, CertificateHelper.RESPONSETYPE_CERTIFICATE);
        } catch (EjbcaException_Exception e) {
            final ErrorCode errorCode = e.getFaultInfo().getErrorCode();
            log.info(errorCode.getInternalErrorCode(), e);
            assertNotNull("error code should not be null", errorCode);
            return errorCode;
        }
        // Verify that the response is of the right type
        assertNotNull(certificateResponse);
        assertTrue(certificateResponse.getResponseType().equals(CertificateHelper.RESPONSETYPE_CERTIFICATE));
        // Verify that the certificate in the response has the same Subject DN
        // as in the request.
        final X509Certificate cert = certificateResponse.getCertificate();
        assertNotNull(cert);
        assertTrue(cert.getSubjectDN().toString().equals(userdata.getSubjectDN()));

        // Request a PKCS#7 via the WS API
        final CertificateResponse pkcs7Response = ejbcaraws.certificateRequest(userdata, requestdata, requesttype, null, CertificateHelper.RESPONSETYPE_PKCS7);
        // Verify that the response is of the right type
        assertTrue(pkcs7Response.getResponseType().equals(CertificateHelper.RESPONSETYPE_PKCS7));
        // Verify that the PKCS#7 response contains a certificate
        CMSSignedData cmsSignedData = new CMSSignedData(CertificateHelper.getPKCS7(pkcs7Response.getData()));
        assertNotNull(cmsSignedData);
        CertStore certStore = cmsSignedData.getCertificatesAndCRLs("Collection", "BC");
        assertTrue(certStore.getCertificates(null).size() == 1);
        return null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.