public EnrollmentResponse enrol(final X509Certificate identity,
            final PrivateKey key, final PKCS10CertificationRequest csr,
            final String profile) throws ClientException, TransactionException {
        LOGGER.debug("Enrolling certificate with CA");

        if (isSelfSigned(identity)) {
            LOGGER.debug("Certificate is self-signed");
            X500Name csrSubject = csr.getSubject();
            X500Name idSubject = X500Utils.toX500Name(identity
                    .getSubjectX500Principal());

            if (!csrSubject.equals(idSubject)) {
                LOGGER.error("The self-signed certificate MUST use the same subject name as in the PKCS#10 request.");
            }
        }
        // TRANSACTIONAL
        // Certificate enrollment
        final Transport transport = createTransport(profile);
        PkiMessageEncoder encoder = getEncoder(identity, key, profile);
        PkiMessageDecoder decoder = getDecoder(identity, key, profile);
        final EnrollmentTransaction trans = new EnrollmentTransaction(
                transport, encoder, decoder, csr);

        try {
            MessageDigest digest = getCaCapabilities(profile)
                    .getStrongestMessageDigest();
            byte[] hash = digest.digest(csr.getEncoded());

            LOGGER.debug("{} PKCS#10 Fingerprint: [{}]", digest.getAlgorithm(),
                    new String(Hex.encodeHex(hash)));
        } catch (IOException e) {
            LOGGER.error("Error getting encoded CSR", e);
        }

        return send(trans);
    }
public EnrollmentResponse enrol ( final X509Certificate identity , final PrivateKey key , final PKCS10CertificationRequest csr , final String profile ) throws ClientException , TransactionException { LOGGER . debug ( "Enrolling certificate with CA" ) ; if ( isSelfSigned ( identity ) ) { LOGGER . debug ( "Certificate is self-signed" ) ; X500Name csrSubject = csr . getSubject ( ) ; X500Name idSubject = X500Utils . toX500Name ( identity . getSubjectX500Principal ( ) ) ; if ( ! csrSubject . equals ( idSubject ) ) { LOGGER . error ( "The self-signed certificate MUST use the same subject name as in the PKCS#10 request." ) ; } } final Transport transport = createTransport ( profile ) ; PkiMessageEncoder encoder = getEncoder ( identity , key , profile ) ; PkiMessageDecoder decoder = getDecoder ( identity , key , profile ) ; final EnrollmentTransaction trans = new EnrollmentTransaction ( transport , encoder , decoder , csr ) ; try { MessageDigest digest = getCaCapabilities ( profile ) . getStrongestMessageDigest ( ) ; byte [ ] hash = digest . digest ( csr . getEncoded ( ) ) ; LOGGER . debug ( "{} PKCS#10 Fingerprint: [{}]" , digest . getAlgorithm ( ) , new String ( Hex . encodeHex ( hash ) ) ) ; } catch ( IOException e ) { LOGGER . error ( "Error getting encoded CSR" , e ) ; } return send ( trans ) ; }
Sends a CSR to the SCEP server for enrolling in a PKI.
<p>
This method enrols the provider <tt>CertificationRequest</tt> into the
PKI represented by the SCEP server.

@param identity
the identity of the client.
@param key
the private key to sign the SCEP request.
@param csr
the CSR to enrol.
@param profile
the SCEP server profile.
@return the certificate store returned by the server.
@throws ClientException
if any client error occurs.
@throws TransactionException
if there is a problem with the SCEP transaction.
@see CertStoreInspector