/** * Produce an object suitable for an ASN1OutputStream. * <pre> * SignedData ::= SEQUENCE { * version Version, * digestAlgorithms DigestAlgorithmIdentifiers, * contentInfo ContentInfo, * certificates * [0] IMPLICIT ExtendedCertificatesAndCertificates * OPTIONAL, * crls * [1] IMPLICIT CertificateRevocationLists OPTIONAL, * signerInfos SignerInfos } * </pre> */ public DERObject toASN1Object() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(version); v.add(digestAlgorithms); v.add(contentInfo); if (certificates != null) { v.add(new DERTaggedObject(false, 0, certificates)); } if (crls != null) { v.add(new DERTaggedObject(false, 1, crls)); } v.add(signerInfos); return new BERSequence(v); }
/** * Produce an object suitable for an ASN1OutputStream. * <pre> * SignedData ::= SEQUENCE { * version Version, * digestAlgorithms DigestAlgorithmIdentifiers, * contentInfo ContentInfo, * certificates * [0] IMPLICIT ExtendedCertificatesAndCertificates * OPTIONAL, * crls * [1] IMPLICIT CertificateRevocationLists OPTIONAL, * signerInfos SignerInfos } * </pre> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(version); v.add(digestAlgorithms); v.add(contentInfo); if (certificates != null) { v.add(new DERTaggedObject(false, 0, certificates)); } if (crls != null) { v.add(new DERTaggedObject(false, 1, crls)); } v.add(signerInfos); return new BERSequence(v); }
public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); for (int i = 0; i != info.length; i++) { v.add(info[i]); } if (isBer) { return new BERSequence(v); } else { return new DLSequence(v); } }
/** * Produce an object suitable for an ASN1OutputStream. * <pre> * ContentInfo ::= SEQUENCE { * contentType ContentType, * content * [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL } * </pre> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(contentType); if (content != null) { v.add(new BERTaggedObject(true, 0, content)); } if (isBer) { return new BERSequence(v); } else { return new DLSequence(v); } }
/** * Produce an object suitable for an ASN1OutputStream. * <pre> * EnvelopedData ::= SEQUENCE { * version CMSVersion, * originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, * recipientInfos RecipientInfos, * encryptedContentInfo EncryptedContentInfo, * unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL * } * </pre> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(version); if (originatorInfo != null) { v.add(new DERTaggedObject(false, 0, originatorInfo)); } v.add(recipientInfos); v.add(encryptedContentInfo); if (unprotectedAttrs != null) { v.add(new DERTaggedObject(false, 1, unprotectedAttrs)); } return new BERSequence(v); }
/** * <pre> * TimeStampedData ::= SEQUENCE { * version INTEGER { v1(1) }, * dataUri IA5String OPTIONAL, * metaData MetaData OPTIONAL, * content OCTET STRING OPTIONAL, * temporalEvidence Evidence * } * </pre> * @return */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); 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); }
/** * <pre> * TimeStampedData ::= SEQUENCE { * version INTEGER { v1(1) }, * dataUri IA5String OPTIONAL, * metaData MetaData OPTIONAL, * content OCTET STRING OPTIONAL, * temporalEvidence Evidence * } * </pre> * @return * @deprecated will be removed */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); 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); }
/** * Produce an object suitable for an ASN1OutputStream. */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(version); if (originatorInfo != null) { v.add(new DERTaggedObject(false, 0, originatorInfo)); } v.add(recipientInfos); v.add(encryptedContentInfo); if (unprotectedAttrs != null) { v.add(new DERTaggedObject(false, 1, unprotectedAttrs)); } return new BERSequence(v); }
public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); 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); }
public void shouldFailOnExtraData() throws Exception { // basic construction DERBitString s1 = new DERBitString(new byte[0], 0); ASN1Primitive.fromByteArray(s1.getEncoded()); ASN1Primitive.fromByteArray(new BERSequence(s1).getEncoded()); try { ASN1Primitive obj = ASN1Primitive.fromByteArray(Arrays.concatenate(s1.getEncoded(), new byte[1])); fail("no exception"); } catch (IOException e) { if (!"Extra data detected in stream".equals(e.getMessage())) { fail("wrong exception"); } } }
/** * Produce an object suitable for an ASN1OutputStream. * <pre> * SignedData ::= SEQUENCE { * version Version, * digestAlgorithms DigestAlgorithmIdentifiers, * contentInfo ContentInfo, * certificates * [0] IMPLICIT ExtendedCertificatesAndCertificates * OPTIONAL, * crls * [1] IMPLICIT CertificateRevocationLists OPTIONAL, * signerInfos SignerInfos } * </pre> */ public DERObject getDERObject() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(version); v.add(digestAlgorithms); v.add(contentInfo); if (certificates != null) { v.add(new DERTaggedObject(false, 0, certificates)); } if (crls != null) { v.add(new DERTaggedObject(false, 1, crls)); } v.add(signerInfos); return new BERSequence(v); }