org.bouncycastle.dvcs.DVCSResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-fips Show documentation
Show all versions of bcpkix-fips Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, S/MIME and certificate generation. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
The newest version!
package org.bouncycastle.dvcs;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.SignedData;
import org.bouncycastle.asn1.dvcs.DVCSObjectIdentifiers;
import org.bouncycastle.cms.CMSSignedData;
/**
* DVCResponse is general response to DVCS (RFC 3029).
* It represents responses for all types of services.
*/
public class DVCSResponse
extends DVCSMessage
{
private org.bouncycastle.asn1.dvcs.DVCSResponse asn1;
/**
* Constructs DVCResponse from CMS SignedData object.
*
* @param signedData the CMS SignedData object containing the request
* @throws org.bouncycastle.dvcs.DVCSConstructionException
*/
public DVCSResponse(CMSSignedData signedData)
throws DVCSConstructionException
{
this(SignedData.getInstance(signedData.toASN1Structure().getContent()).getEncapContentInfo());
}
/**
* Construct a DVCS Response from a ContentInfo
*
* @param contentInfo the contentInfo representing the DVCSRequest
* @throws org.bouncycastle.dvcs.DVCSConstructionException
*/
public DVCSResponse(ContentInfo contentInfo)
throws DVCSConstructionException
{
super(contentInfo);
if (!DVCSObjectIdentifiers.id_ct_DVCSResponseData.equals(contentInfo.getContentType()))
{
throw new DVCSConstructionException("ContentInfo not a DVCS Response");
}
try
{
if (contentInfo.getContent().toASN1Primitive() instanceof ASN1Sequence)
{
this.asn1 = org.bouncycastle.asn1.dvcs.DVCSResponse.getInstance(contentInfo.getContent());
}
else
{
this.asn1 = org.bouncycastle.asn1.dvcs.DVCSResponse.getInstance(ASN1OctetString.getInstance(contentInfo.getContent()).getOctets());
}
}
catch (Exception e)
{
throw new DVCSConstructionException("Unable to parse content: " + e.getMessage(), e);
}
}
/**
* Return the ASN.1 DVCSResponse structure making up the body of this response.
*
* @return an org.bouncycastle.asn1.dvcs.DVCSResponse object.
*/
public ASN1Encodable getContent()
{
return asn1;
}
}