org.bouncycastle.cert.crmf.CertificateReqMessages Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-debug-jdk15to18 Show documentation
Show all versions of bcpkix-debug-jdk15to18 Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.5 to JDK 1.8. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.
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