Search in sources :

Example 6 with ProofOfPossession

use of org.bouncycastle.asn1.crmf.ProofOfPossession in project xipki by xipki.

the class CaClientImpl method envelope.

@Override
public byte[] envelope(CertRequest certRequest, ProofOfPossession pop, String profileName, String caName) throws CaClientException {
    ParamUtil.requireNonNull("certRequest", certRequest);
    ParamUtil.requireNonNull("pop", pop);
    profileName = ParamUtil.requireNonNull("profileName", profileName).toLowerCase();
    init0(false);
    if (caName == null) {
        // detect the CA name
        caName = getCaNameForProfile(profileName);
        if (caName == null) {
            throw new CaClientException("certprofile " + profileName + " is not supported by any CA");
        }
    } else {
        caName = caName.toLowerCase();
        checkCertprofileSupportInCa(profileName, caName);
    }
    CaConf ca = casMap.get(caName);
    if (ca == null) {
        throw new CaClientException("could not find CA named " + caName);
    }
    PKIMessage pkiMessage;
    try {
        pkiMessage = ca.getRequestor().envelope(certRequest, pop, profileName);
    } catch (CmpRequestorException ex) {
        throw new CaClientException("CmpRequestorException: " + ex.getMessage(), ex);
    }
    try {
        return pkiMessage.getEncoded();
    } catch (IOException ex) {
        throw new CaClientException("IOException: " + ex.getMessage(), ex);
    }
}
Also used : PKIMessage(org.bouncycastle.asn1.cmp.PKIMessage) IOException(java.io.IOException) CaClientException(org.xipki.ca.client.api.CaClientException)

Aggregations

PKIMessage (org.bouncycastle.asn1.cmp.PKIMessage)4 POPOSigningKey (org.bouncycastle.asn1.crmf.POPOSigningKey)3 ProofOfPossession (org.bouncycastle.asn1.crmf.ProofOfPossession)3 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)2 PKIBody (org.bouncycastle.asn1.cmp.PKIBody)2 AttributeTypeAndValue (org.bouncycastle.asn1.crmf.AttributeTypeAndValue)2 CertReqMessages (org.bouncycastle.asn1.crmf.CertReqMessages)2 CertReqMsg (org.bouncycastle.asn1.crmf.CertReqMsg)2 CertRequest (org.bouncycastle.asn1.crmf.CertRequest)2 CertTemplateBuilder (org.bouncycastle.asn1.crmf.CertTemplateBuilder)2 X500Name (org.bouncycastle.asn1.x500.X500Name)2 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)2 ProofOfPossessionSigningKeyBuilder (org.bouncycastle.cert.crmf.ProofOfPossessionSigningKeyBuilder)2 File (java.io.File)1 IOException (java.io.IOException)1 InvalidKeyException (java.security.InvalidKeyException)1 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 PublicKey (java.security.PublicKey)1 X509Certificate (java.security.cert.X509Certificate)1