org.bouncycastle.cert.cmp.CertificateConfirmationContent 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.cmp;
import org.bouncycastle.asn1.cmp.CertConfirmContent;
import org.bouncycastle.asn1.cmp.CertStatus;
import org.bouncycastle.asn1.cmp.PKIBody;
import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;
/**
* Carrier class for a {@link CertConfirmContent} message.
*/
public class CertificateConfirmationContent
{
private DigestAlgorithmIdentifierFinder digestAlgFinder;
private CertConfirmContent content;
public CertificateConfirmationContent(CertConfirmContent content)
{
this(content, new DefaultDigestAlgorithmIdentifierFinder());
}
public CertificateConfirmationContent(CertConfirmContent content, DigestAlgorithmIdentifierFinder digestAlgFinder)
{
this.digestAlgFinder = digestAlgFinder;
this.content = content;
}
public static CertificateConfirmationContent fromPKIBody(PKIBody pkiBody)
{
return fromPKIBody(pkiBody, new DefaultDigestAlgorithmIdentifierFinder());
}
public static CertificateConfirmationContent fromPKIBody(PKIBody pkiBody, DigestAlgorithmIdentifierFinder digestAlgFinder)
{
if (!isCertificateConfirmationContent(pkiBody.getType()))
{
throw new IllegalArgumentException("content of PKIBody wrong type: " + pkiBody.getType());
}
return new CertificateConfirmationContent(CertConfirmContent.getInstance(pkiBody.getContent()), digestAlgFinder);
}
public static boolean isCertificateConfirmationContent(int bodyType)
{
switch (bodyType)
{
case PKIBody.TYPE_CERT_CONFIRM:
return true;
default:
return false;
}
}
public CertConfirmContent toASN1Structure()
{
return content;
}
public CertificateStatus[] getStatusMessages()
{
CertStatus[] statusArray = content.toCertStatusArray();
CertificateStatus[] ret = new CertificateStatus[statusArray.length];
for (int i = 0; i != ret.length; i++)
{
ret[i] = new CertificateStatus(digestAlgFinder, statusArray[i]);
}
return ret;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy