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

org.bouncycastle.sasn1.cms.EnvelopedDataParser Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java CMS and S/MIME APIs for handling the CMS and S/MIME protocols. This jar contains CMS and S/MIME APIs for JDK 1.6. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs. If the S/MIME API is used, the JavaMail API and the Java activation framework will also be needed.

There is a newer version: 1.46
Show newest version
package org.bouncycastle.sasn1.cms;

import org.bouncycastle.sasn1.Asn1Integer;
import org.bouncycastle.sasn1.Asn1Object;
import org.bouncycastle.sasn1.Asn1Sequence;
import org.bouncycastle.sasn1.Asn1Set;
import org.bouncycastle.sasn1.Asn1TaggedObject;
import org.bouncycastle.sasn1.BerTag;

import java.io.IOException;

/** 
 * 
 * EnvelopedData ::= SEQUENCE {
 *     version CMSVersion,
 *     originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,
 *     recipientInfos RecipientInfos,
 *     encryptedContentInfo EncryptedContentInfo,
 *     unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL 
 * }
 * 
* @deprecated use corresponding class in org.bouncycastle.asn1.cms */ public class EnvelopedDataParser { private Asn1Sequence _seq; private Asn1Integer _version; private Asn1Object _nextObject; public EnvelopedDataParser( Asn1Sequence seq) throws IOException { this._seq = seq; this._version = (Asn1Integer)seq.readObject(); } public Asn1Integer getVersion() { return _version; } public Asn1Set getCertificates() throws IOException { _nextObject = _seq.readObject(); if (_nextObject instanceof Asn1TaggedObject && ((Asn1TaggedObject)_nextObject).getTagNumber() == 0) { Asn1Set certs = (Asn1Set)((Asn1TaggedObject)_nextObject).getObject(BerTag.SET, false); _nextObject = null; return certs; } return null; } public Asn1Set getCrls() throws IOException { if (_nextObject == null) { _nextObject = _seq.readObject(); } if (_nextObject instanceof Asn1TaggedObject && ((Asn1TaggedObject)_nextObject).getTagNumber() == 1) { Asn1Set crls = (Asn1Set)((Asn1TaggedObject)_nextObject).getObject(BerTag.SET, false); _nextObject = null; return crls; } return null; } public Asn1Set getRecipientInfos() throws IOException { return (Asn1Set)_seq.readObject(); } public EncryptedContentInfoParser getEncryptedContentInfo() throws IOException { return new EncryptedContentInfoParser((Asn1Sequence)_seq.readObject()); } public Asn1Set getUnprotectedAttrs() throws IOException { Asn1Object o = _seq.readObject(); if (o != null) { return (Asn1Set)((Asn1TaggedObject)o).getObject(BerTag.SET, false); } return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy