com.ibm.security.pkcs7
Class Data

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

public final class Data
extends Content
implements Cloneable

Implements the ASN.1 Data type.

Data ::= OCTET STRING

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

Data objects are immutable; they cannot be changed once constructed and initialized. If the setData() method is called and the Data value has already been set, the setData() method will throw a PKCSException.


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
Data()
          Create an uninitialized Data object.
Data(byte[] der)
          Create a Data object with a DER-encoded byte array.
Data(byte[] der, String provider)
          Create a Data object with a DER-encoded byte array.
Data(String provider)
          Create an uninitialized Data object.
Data(String filename, boolean base64)
          Create a Data with the filename of the DER-encoded or BASE64-encoded object.
Data(String filename, boolean base64, String provider)
          Create a Data with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 Object clone()
          Creates a clone of this Data object.
protected  void decode(com.ibm.security.pkcs7.DerValue encoding)
          Initializes a Data object from a DerValue.
 void encode(OutputStream os)
          Encodes this object to an OutputStream.
 boolean equals(Object other)
          Determines if this Data object is equivalent to the input object.
 byte[] getData()
          Returns a copy of the data contents of this Data object.
 ObjectIdentifier getObjectIdentifier()
          Returns the ObjectIdentifer for the Data object.
 void setData(byte[] data)
          Set the data contents for this Data object.
 String toString()
          Returns a string representation of this Data 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

Data

public Data()
Create an uninitialized Data object. The data contents of this uninitialized object can be initialized with the setData method.

Data

public Data(String provider)
Create an uninitialized Data object. The data contents of this uninitialized object can be initialized with the setData method.
Parameters:
provname - the name of the java.security provider to use

Data

public Data(byte[] der)
     throws IOException
Create a Data object with a DER-encoded byte array. To set the byte contents of the Data object without a DER-encoded byte array of the Data object, call the setData method.
Parameters:
der - a DER-encoded byte array of a Data object.
Throws:
IOException - on decoding errors.

Data

public Data(byte[] der,
            String provider)
     throws IOException
Create a Data object with a DER-encoded byte array. To set the byte contents of the Data object without a DER-encoded byte array of the Data object, call the setData method.
Parameters:
der - a DER-encoded byte array of a Data object.
provider - the name of the java.security provider to use
Throws:
IOException - on decoding errors.

Data

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

Data

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

equals

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

getObjectIdentifier

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

setData

public void setData(byte[] data)
             throws PKCSException
Set the data contents for this Data object.
Parameters:
data - byte array of the data.
Throws:
PKCSException - if the data byte array was already set.

getData

public byte[] getData()
Returns a copy of the data contents of this Data object.
Returns:
a byte array of the data contents

toString

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