org.bouncycastle.asn1.cms.TimeStampedDataParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-fips Show documentation
Show all versions of bcutil-fips Show documentation
The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls 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!
/***************************************************************/
/****** DO NOT EDIT THIS CLASS bc-java SOURCE FILE ******/
/***************************************************************/
package org.bouncycastle.asn1.cms;
import java.io.IOException;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1OctetStringParser;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1SequenceParser;
import org.bouncycastle.asn1.DERIA5String;
/**
* Parser for RFC 5544:
* {@link TimeStampedData} object.
*
*
* TimeStampedData ::= SEQUENCE {
* version INTEGER { v1(1) },
* dataUri IA5String OPTIONAL,
* metaData MetaData OPTIONAL,
* content OCTET STRING OPTIONAL,
* temporalEvidence Evidence
* }
*
*/
public class TimeStampedDataParser
{
private ASN1Integer version;
private DERIA5String dataUri;
private MetaData metaData;
private ASN1OctetStringParser content;
private Evidence temporalEvidence;
private ASN1SequenceParser parser;
private TimeStampedDataParser(ASN1SequenceParser parser)
throws IOException
{
this.parser = parser;
this.version = ASN1Integer.getInstance(parser.readObject());
ASN1Encodable obj = parser.readObject();
if (obj instanceof DERIA5String)
{
this.dataUri = DERIA5String.getInstance(obj);
obj = parser.readObject();
}
if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
{
this.metaData = MetaData.getInstance(obj.toASN1Primitive());
obj = parser.readObject();
}
if (obj instanceof ASN1OctetStringParser)
{
this.content = (ASN1OctetStringParser)obj;
}
}
public static TimeStampedDataParser getInstance(Object obj)
throws IOException
{
if (obj instanceof ASN1Sequence)
{
return new TimeStampedDataParser(((ASN1Sequence)obj).parser());
}
if (obj instanceof ASN1SequenceParser)
{
return new TimeStampedDataParser((ASN1SequenceParser)obj);
}
return null;
}
public int getVersion()
{
return version.getValue().intValue();
}
public DERIA5String getDataUri()
{
return dataUri;
}
public MetaData getMetaData()
{
return metaData;
}
public ASN1OctetStringParser getContent()
{
return content;
}
public Evidence getTemporalEvidence()
throws IOException
{
if (temporalEvidence == null)
{
temporalEvidence = Evidence.getInstance(parser.readObject().toASN1Primitive());
}
return temporalEvidence;
}
}