com.ibm.security.pkcs7
Class EncapsulatedContentInfo

java.lang.Object
  |
  +--com.ibm.security.pkcsutil.PKCSDerObject
        |
        +--com.ibm.security.pkcs7.EncapsulatedContentInfo

public final class EncapsulatedContentInfo
extends PKCSDerObject
implements Cloneable

Implements the ASN.1 EncapsulatedContentInfo data type as defined in S/MIME CMS.

EncapsulatedContentInfo ::= SEQUENCE { eContentType ContentType, eContent [0] EXPLICIT OCTET STRING OPTIONAL }

This definition reflects PKCS #7 version 1.5 specifications with selected enhancements from the Cryptographic Message Syntax (CMS) RFC 2630 specifications.

EncapsulatedContentInfo objects are immutable; they cannot be changed once created.


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
EncapsulatedContentInfo(byte[] der)
          Create an EncapsulatedContentInfo object with a DER-encoded byte array.
EncapsulatedContentInfo(byte[] der, String provider)
          Create an EncapsulatedContentInfo object with a DER-encoded byte array.
EncapsulatedContentInfo(ContentInfo contentInfo)
          Create an EncapsulatedContentInfo from a ContentInfo.
EncapsulatedContentInfo(ContentInfo contentInfo, String provider)
          Create an EncapsulatedContentInfo from a ContentInfo.
EncapsulatedContentInfo(String filename, boolean base64)
          Create an EncapsulatedContentInfo with the filename of the DER-encoded or BASE64-encoded object.
EncapsulatedContentInfo(String filename, boolean base64, String provider)
          Create an EncapsulatedContentInfo with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 Object clone()
          Creates a clone of this EncapsulatedContentInfo object.
protected  void decode(com.ibm.security.pkcs7.DerValue encoding)
          Initializes an EncapsulatedContentInfo object from a DerValue.
 void encode(OutputStream os)
          Encodes this object to an OutputStream.
 boolean equals(Object other)
          Determines if this EncapsulatedContentInfo object is equivalent to the input object.
 byte[] getContent()
          Returns a copy of the content byte array contained in this EncapsulatedContentInfo object.
 ContentInfo getContentInfo()
          Constructs and returns a ContentInfo object based on this EncapsulatedContentInfo object's contentType and content attributes.
 ObjectIdentifier getContentType()
          Returns a reference to the ObjectIdentifer for the EncapsulatedContentInfo object.
 String toString()
          Returns a string representation of this EncapsulatedContentInfo object.
 
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject
decode, decode, encode, getObjectIdentifier, hashCode, read, readBASE64, write, write, writeBASE64
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EncapsulatedContentInfo

public EncapsulatedContentInfo(byte[] der)
                        throws IOException
Create an EncapsulatedContentInfo object with a DER-encoded byte array.
Parameters:
der - a DER-encoded byte array of an EncapsulatedContentInfo object.
Throws:
IOException - on decoding errors.

EncapsulatedContentInfo

public EncapsulatedContentInfo(byte[] der,
                               String provider)
                        throws IOException
Create an EncapsulatedContentInfo object with a DER-encoded byte array.
Parameters:
der - a DER-encoded byte array of an EncapsulatedContentInfo object.
provider - the name of the java security provider to use
Throws:
IOException - on decoding errors.

EncapsulatedContentInfo

public EncapsulatedContentInfo(ContentInfo contentInfo)
                        throws IOException
Create an EncapsulatedContentInfo from a ContentInfo. The method derives the ContentType from the ContentInfo object.
Parameters:
contentInfo - ContentInfo object.
Throws:
IOException - on decoding errors.

EncapsulatedContentInfo

public EncapsulatedContentInfo(ContentInfo contentInfo,
                               String provider)
                        throws IOException
Create an EncapsulatedContentInfo from a ContentInfo. The method derives the ContentType from the ContentInfo object.
Parameters:
contentInfo - ContentInfo object.
provider - the name of the java security provider to use
Throws:
IOException - on decoding errors.

EncapsulatedContentInfo

public EncapsulatedContentInfo(String filename,
                               boolean base64)
                        throws IOException
Create an EncapsulatedContentInfo with the filename of the DER-encoded or BASE64-encoded object.
Parameters:
filename - name of the DER-encoded or base64-encoded object
base64 - true if BASE64-encoded, false if DER-encoded
Throws:
IOException - on decoding errors.

EncapsulatedContentInfo

public EncapsulatedContentInfo(String filename,
                               boolean base64,
                               String provider)
                        throws IOException
Create an EncapsulatedContentInfo with the filename of the DER-encoded or BASE64-encoded object.
Parameters:
filename - name of the DER-encoded or base64-encoded object
base64 - true if BASE64-encoded, false if DER-encoded
provider - the name of the java security provider to use
Throws:
IOException - on decoding errors.
Method Detail

clone

public Object clone()
Creates a clone of this EncapsulatedContentInfo object.
Overrides:
clone in class Object
Returns:
clone of this EncapsulatedContentInfo object.

encode

public void encode(OutputStream os)
            throws IOException
Encodes this object to an OutputStream.
Overrides:
encode in class PKCSDerObject
Parameters:
os - the OutputStream to write the encoded data to.
Throws:
IOException - on encoding errors.

decode

protected void decode(com.ibm.security.pkcs7.DerValue encoding)
               throws IOException
Initializes an EncapsulatedContentInfo object from a DerValue. The DER encoding must be in the format specified by the EncapsulatedContentInfo ASN.1 notation.
Parameters:
encoding - a DER-encoded EncapsulatedContentInfo object.
Throws:
IOException - on parsing error.

equals

public boolean equals(Object other)
Determines if this EncapsulatedContentInfo object is equivalent to the input object.
Overrides:
equals in class PKCSDerObject
Parameters:
other - the object to compare this one to.
Returns:
true, if the two objects are equivalent, false otherwise.

toString

public String toString()
Returns a string representation of this EncapsulatedContentInfo object.
Overrides:
toString in class PKCSDerObject
Returns:
a string representation of this object.

getContentType

public ObjectIdentifier getContentType()
Returns a reference to the ObjectIdentifer for the EncapsulatedContentInfo object.
Returns:
an ObjectIdentifer for the EncapsulatedContentInfo object.

getContentInfo

public ContentInfo getContentInfo()
                           throws IOException
Constructs and returns a ContentInfo object based on this EncapsulatedContentInfo object's contentType and content attributes.
Returns:
ContentInfo object based on the contentType and content.
Throws:
IOException - on ContentInfo construction error

getContent

public byte[] getContent()
Returns a copy of the content byte array contained in this EncapsulatedContentInfo object.
Returns:
a copy of the content byte array