All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.cert.crmf.CertificateReqMessages Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.8 and up. The APIs are designed primarily to be used in conjunction with the BC LTS provider but may also be used with other providers providing cryptographic services.

There is a newer version: 2.73.7
Show newest version
package org.bouncycastle.cert.crmf;

import org.bouncycastle.asn1.cmp.PKIBody;
import org.bouncycastle.asn1.crmf.CertReqMessages;
import org.bouncycastle.asn1.crmf.CertReqMsg;

public class CertificateReqMessages
{
    private final CertReqMsg[] reqs;

    public CertificateReqMessages(CertReqMessages certReqMessages)
    {
        reqs = certReqMessages.toCertReqMsgArray();
    }

    public static CertificateReqMessages fromPKIBody(PKIBody pkiBody)
    {
        if (!isCertificateRequestMessages(pkiBody.getType()))
        {
            throw new IllegalArgumentException("content of PKIBody wrong type: " + pkiBody.getType());
        }

        return new CertificateReqMessages(CertReqMessages.getInstance(pkiBody.getContent()));
    }

    public static boolean isCertificateRequestMessages(int bodyType)
    {
        switch (bodyType)
        {
        case PKIBody.TYPE_INIT_REQ:
        case PKIBody.TYPE_CERT_REQ:
        case PKIBody.TYPE_KEY_UPDATE_REQ:
        case PKIBody.TYPE_KEY_RECOVERY_REQ:
        case PKIBody.TYPE_CROSS_CERT_REQ:
            return true;
        default:
            return false;
        }
    }

    public CertificateRequestMessage[] getRequests()
    {
        CertificateRequestMessage[] requestMessages = new CertificateRequestMessage[reqs.length];
        for (int i = 0; i != requestMessages.length; i++)
        {
            requestMessages[i] = new CertificateRequestMessage(reqs[i]);
        }

        return requestMessages;
    }

    public CertReqMessages toASN1Structure()
    {
        return new CertReqMessages(reqs);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy