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

org.bouncycastle.asn1.cms.TimeStampedData Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls. This jar contains APIs for JDK 1.5 and up.

The newest version!
package org.bouncycastle.asn1.cms;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1IA5String;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.BERSequence;
import org.bouncycastle.asn1.DERIA5String;

/**
 * RFC 5544:
 * Binding Documents with Time-Stamps; TimeStampedData object.
 * 

*

 * TimeStampedData ::= SEQUENCE {
 *   version              INTEGER { v1(1) },
 *   dataUri              IA5String OPTIONAL,
 *   metaData             MetaData OPTIONAL,
 *   content              OCTET STRING OPTIONAL,
 *   temporalEvidence     Evidence
 * }
 * 
*/ public class TimeStampedData extends ASN1Object { private ASN1Integer version; private ASN1IA5String dataUri; private MetaData metaData; private ASN1OctetString content; private Evidence temporalEvidence; public TimeStampedData(ASN1IA5String dataUri, MetaData metaData, ASN1OctetString content, Evidence temporalEvidence) { this.version = new ASN1Integer(1); this.dataUri = dataUri; this.metaData = metaData; this.content = content; this.temporalEvidence = temporalEvidence; } private TimeStampedData(ASN1Sequence seq) { this.version = ASN1Integer.getInstance(seq.getObjectAt(0)); int index = 1; if (seq.getObjectAt(index) instanceof ASN1IA5String) { this.dataUri = ASN1IA5String.getInstance(seq.getObjectAt(index++)); } if (seq.getObjectAt(index) instanceof MetaData || seq.getObjectAt(index) instanceof ASN1Sequence) { this.metaData = MetaData.getInstance(seq.getObjectAt(index++)); } if (seq.getObjectAt(index) instanceof ASN1OctetString) { this.content = ASN1OctetString.getInstance(seq.getObjectAt(index++)); } this.temporalEvidence = Evidence.getInstance(seq.getObjectAt(index)); } /** * Return a TimeStampedData object from the given object. *

* Accepted inputs: *

    *
  • null → null *
  • {@link RecipientKeyIdentifier} object *
  • {@link org.bouncycastle.asn1.ASN1Sequence#getInstance(java.lang.Object) ASN1Sequence} input formats with TimeStampedData structure inside *
* * @param obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static TimeStampedData getInstance(Object obj) { if (obj == null || obj instanceof TimeStampedData) { return (TimeStampedData)obj; } return new TimeStampedData(ASN1Sequence.getInstance(obj)); } /** * @deprecated Use {@link #getDataUriIA5()} instead. */ public DERIA5String getDataUri() { return null == dataUri || dataUri instanceof DERIA5String ? (DERIA5String)dataUri : new DERIA5String(dataUri.getString(), false); } public ASN1IA5String getDataUriIA5() { return dataUri; } public MetaData getMetaData() { return metaData; } public ASN1OctetString getContent() { return content; } public Evidence getTemporalEvidence() { return temporalEvidence; } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(5); v.add(version); if (dataUri != null) { v.add(dataUri); } if (metaData != null) { v.add(metaData); } if (content != null) { v.add(content); } v.add(temporalEvidence); return new BERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy