com.ibm.security.pkcs12
Class AuthenticatedSafe

java.lang.Object
  |
  +--com.ibm.security.pkcsutil.PKCSDerObject
        |
        +--com.ibm.security.pkcs12.AuthenticatedSafe

public final class AuthenticatedSafe
extends PKCSDerObject
implements Cloneable

Implements the PKCS #12 AuthenticatedSafe data type, which is a sequence of ContentInfos. AuthenticatedSafe is defined as follows:

AuthenticatedSafe ::= SEQUENCE OF ContentInfo -- Data if unencrypted -- EncryptedData if password-encrypted -- EnvelopedData if public key-encrypted

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

See Also:
SafeContents, ContentInfo

Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
AuthenticatedSafe(byte[] der)
          Create an AuthenticatedSafe object with a DER byte array.
AuthenticatedSafe(byte[] der, String provider)
          Create an AuthenticatedSafe object with a DER byte array, and a provider specified.
AuthenticatedSafe(ContentInfo[] info)
          Create an AuthenticatedSafe object with the input ContentInfo array.
AuthenticatedSafe(ContentInfo[] info, String provider)
          Create an AuthenticatedSafe object with the input ContentInfo array, and the provider.
AuthenticatedSafe(String filename, boolean base64)
          Create an AuthenticatedSafe with the filename of the DER-encoded or BASE64-encoded object.
AuthenticatedSafe(String filename, boolean base64, String provider)
          Create an AuthenticatedSafe with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 AuthenticatedSafe addContentInfo(ContentInfo[] contents)
          Add one or more ContentInfos to this AuthenticatedSafe object and return the combined ContentInfos in a new object.
 Object clone()
          Creates a clone of this AuthenticatedSafe object.
protected  void decode(com.ibm.security.pkcs12.DerValue encoding)
          Initialize a AuthenticatedSafe object from an input stream.
 void encode(OutputStream out)
          Encodes this object to a DER OutputStream.
 boolean equals(Object obj)
          Determines if this AuthenticatedSafe object is equivalent to the input object.
 ContentInfo[] getContentInfos()
          Return a copy of the ContentInfos in this AuthenticatedSafe.
 ContentInfo toContentInfo()
          Transform the DER-encoded data in this object into a ContentInfo with content type Data.
 String toString()
          Returns a string representation of this AuthenticatedSafe 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

AuthenticatedSafe

public AuthenticatedSafe(byte[] der)
                  throws IOException
Create an AuthenticatedSafe object with a DER byte array.

AuthenticatedSafe

public AuthenticatedSafe(byte[] der,
                         String provider)
                  throws IOException
Create an AuthenticatedSafe object with a DER byte array, and a provider specified.

AuthenticatedSafe

public AuthenticatedSafe(ContentInfo[] info)
                  throws IOException
Create an AuthenticatedSafe object with the input ContentInfo array.

AuthenticatedSafe

public AuthenticatedSafe(ContentInfo[] info,
                         String provider)
                  throws IOException
Create an AuthenticatedSafe object with the input ContentInfo array, and the provider.

AuthenticatedSafe

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

AuthenticatedSafe

public AuthenticatedSafe(String filename,
                         boolean base64,
                         String provider)
                  throws IOException
Create an AuthenticatedSafe 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 provider to use
Throws:
IOException - on decoding errors.
Method Detail

encode

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

addContentInfo

public AuthenticatedSafe addContentInfo(ContentInfo[] contents)
Add one or more ContentInfos to this AuthenticatedSafe object and return the combined ContentInfos in a new object. The original AuthenticatedSafe object remains unchanged.
Parameters:
contents - the ContentInfos to add.

getContentInfos

public ContentInfo[] getContentInfos()
Return a copy of the ContentInfos in this AuthenticatedSafe.
Returns:
a copy of the ContentInfos in this object.

toContentInfo

public ContentInfo toContentInfo()
                          throws IOException
Transform the DER-encoded data in this object into a ContentInfo with content type Data.
Returns:
a ContentInfo whose content is the DER-encoding of this object.

clone

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

equals

public boolean equals(Object obj)
Determines if this AuthenticatedSafe 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 AuthenticatedSafe object.
Overrides:
toString in class PKCSDerObject
Returns:
a string representation of this object.

decode

protected void decode(com.ibm.security.pkcs12.DerValue encoding)
               throws IOException
Initialize a AuthenticatedSafe object from an input stream. The data on that input stream must be a DER-encoded AuthenticatedSafe object.
Parameters:
encoding - an input stream with a DER-encoded AuthenticatedSafe object.
Throws:
IOException - on parsing errors.