/*
* Title: Oyster Project
* Description: S/MIME email sending capabilities
* @Author Vladimir Radisic
* @Version 2.1.6
*/
package org.enhydra.oyster.cms;
import org.enhydra.oyster.exception.SMIMEException;
import org.enhydra.oyster.der.DERClassContextSpecific;
import org.enhydra.oyster.der.DERSequencePr;
import org.enhydra.oyster.der.DEROctetString;
/**
* EncapsulatedContentInfo class is DER encoded content info represented in
* ASN.1 notation according to RFC2630. This class is used in CMS objects for
* signed messages. It contains message content in case of implicit signing.<BR>
* <BR>
* <DL>
* EncapsulatedContentInfo ::= SEQUENCE {<BR>
* <DD> eContentType ContentType, <BR>
* <DD> eContent [0] EXPLICIT OCTET STRING OPTIONAL }<BR>
* </DL>
* <BR>
* ContentType ::= OBJECT IDENTIFIER<BR>
*/
public class EncapsulatedContentInfo extends DERSequencePr {
/**
* Determinate order of adding commponents.
*/
int orderIdentifier = 0;
/**
* Constructs empty EncapsulatedContentInfo object.
* @exception SMIMEException thrown from super class constructor.
*/
public EncapsulatedContentInfo () throws SMIMEException
{
}
/**
* Adds Content Type
* @param contType0 content type represented as byte array
* @exception SMIMEException if order of adding components is wrong. Also, it
* can be thrown from super class addContent method.
*/
public void addContentType (byte[] contType0) throws SMIMEException {
if (orderIdentifier == 0) {
super.addContent(contType0);
orderIdentifier++;
}
else
throw new SMIMEException(1018);
}
/**
* Adds Encapsulated Content
* @param cont0 content represented as byte array
* @exception SMIMEException if order of adding components is wrong. Also, it
* can be thrown from super class addContent method.
*/
public void addEncapsulatedContent (byte[] cont0) throws SMIMEException {
if (orderIdentifier == 1) {
DERClassContextSpecific eContent = new DERClassContextSpecific(0, true);
eContent.addContent(new DEROctetString(cont0).getDEREncoded());
super.addContent(eContent.getDEREncoded());
orderIdentifier++;
}
else
throw new SMIMEException(1018);
}
}
|