com.ibm.security.pkcs7
Class DigestedData

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

public final class DigestedData
extends Content
implements Cloneable

Implements the ASN.1 DigestedData type.

The DigestedData content type adds an integrity check to the content of the Data content type, the result of which will become the content input to the EnvelopedData content type.

DigestedData :: = SEQUENCE { version CMSVersion, digestAlgorithm DigestAlgorithmIdentifier, encapContentInfo EncapsulatedContentInfo, digest Digest }

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


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
DigestedData(byte[] der)
          Create a DigestedData object with a DER byte array.
DigestedData(byte[] der, String provider)
          Create a DigestedData object with a DER byte array.
DigestedData(String filename, boolean base64)
          Create a DigestedData with the filename of the DER-encoded or BASE64-encoded object.
DigestedData(String filename, boolean base64, String provider)
          Create a DigestedData with the filename of the DER-encoded or BASE64-encoded object.
DigestedData(String digestAlgorithm, EncapsulatedContentInfo eci)
          Create a DigestedData object with specified values.
DigestedData(String digestAlgorithm, EncapsulatedContentInfo eci, String provider)
          Create a DigestedData object with specified values.
 
Method Summary
 Object clone()
          Creates a clone of this DigestedData object.
protected  void decode(com.ibm.security.pkcs7.DerValue encoding)
          Initializes an DigestedData object from a DerValue.
 void encode(OutputStream os)
          Encodes this object to an OutputStream.
 boolean equals(Object other)
          Determines if this DigestedData object is equivalent to the input object.
 byte[] getDigest()
          Returns a copy of the message digest byte array for this object.
 AlgorithmId getDigestAlgorithm()
          Returns a copy of the message digest AlgorithmId for this object.
 EncapsulatedContentInfo getEncapsulatedContentInfo()
          Returns a copy of the EncapsulatedContentInfo for this object.
 ObjectIdentifier getObjectIdentifier()
          Returns a reference to the ObjectIdentifer for the DigestedData object.
 BigInteger getVersion()
          Returns a reference to the version for this object.
 String toString()
          Returns a string representation of this DigestedData object.
 
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject
decode, decode, encode, hashCode, read, readBASE64, write, write, writeBASE64
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DigestedData

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

DigestedData

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

DigestedData

public DigestedData(String digestAlgorithm,
                    EncapsulatedContentInfo eci)
             throws IOException,
                    NoSuchAlgorithmException
Create a DigestedData object with specified values. The message digest is calculated from the message digest algorithm and EncapsulatedContentInfo.
Parameters:
digestAlgorithm - message digest algorithm
EncapsulatedContentInfo - EncapsulatedContentInfo object
Throws:
NoSuchAlgorithmException - on an invalid algorithm
IOException - on creation errors.

DigestedData

public DigestedData(String digestAlgorithm,
                    EncapsulatedContentInfo eci,
                    String provider)
             throws IOException,
                    NoSuchAlgorithmException
Create a DigestedData object with specified values. The message digest is calculated from the message digest algorithm and EncapsulatedContentInfo.
Parameters:
digestAlgorithm - message digest algorithm
EncapsulatedContentInfo - EncapsulatedContentInfo object
provider - the name of the java security provider to use.
Throws:
NoSuchAlgorithmException - on an invalid algorithm
IOException - on creation errors.

DigestedData

public DigestedData(String filename,
                    boolean base64)
             throws IOException
Create a DigestedData 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.

DigestedData

public DigestedData(String filename,
                    boolean base64,
                    String provider)
             throws IOException
Create a DigestedData 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 DigestedData object.
Overrides:
clone in class Object
Returns:
clone of this DigestedData object.

getObjectIdentifier

public ObjectIdentifier getObjectIdentifier()
Returns a reference to the ObjectIdentifer for the DigestedData object.
Overrides:
getObjectIdentifier in class PKCSDerObject
Returns:
an ObjectIdentifer for the DigestedData 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 DigestedData object from a DerValue. The DER encoding must be in the format specified by the DigestedData ASN.1 notation.
Parameters:
encoding - a DER-encoded DigestedData object.
Throws:
IOException - on parsing error.

equals

public boolean equals(Object other)
Determines if this DigestedData 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.

getVersion

public BigInteger getVersion()
Returns a reference to the version for this object. BigInteger is an immutable object.
Returns:
the version for this object.

getDigestAlgorithm

public AlgorithmId getDigestAlgorithm()
                               throws IOException
Returns a copy of the message digest AlgorithmId for this object.
Returns:
the message digest AlgorithmId for this object.

getEncapsulatedContentInfo

public EncapsulatedContentInfo getEncapsulatedContentInfo()
Returns a copy of the EncapsulatedContentInfo for this object.
Returns:
the EncapsulatedContentInfo for this object

getDigest

public byte[] getDigest()
Returns a copy of the message digest byte array for this object.
Returns:
the message digest byte array for this object.

toString

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