com.ibm.security.pkcs12
Class ShroudedKeyBag

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

public final class ShroudedKeyBag
extends PKCSDerObject
implements Bag, Cloneable

Implements the PKCS #12 PKCS8ShroudedKeyBag data type, which is a container for PKCS #8 EncryptedPrivateKeyInfo data.

PKCS8ShroudedKeyBg ::= EncryptedPrivateKeyInfo

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

See Also:
EncryptedPrivateKeyInfo

Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
ShroudedKeyBag(byte[] der)
          Create a ShroudedKeyBag with a DER byte array.
ShroudedKeyBag(byte[] der, String provider)
          Create a ShroudedKeyBag with a DER byte array.
ShroudedKeyBag(EncryptedPrivateKeyInfo keyInfo)
          Create a ShroudedKeyBag with the input EncryptedPrivateKeyInfo.
ShroudedKeyBag(EncryptedPrivateKeyInfo keyInfo, String provider)
          Create a ShroudedKeyBag with the input EncryptedPrivateKeyInfo.
ShroudedKeyBag(String filename, boolean base64)
          Create a ShroudedKeyBag with the filename of the DER-encoded or BASE64-encoded object.
ShroudedKeyBag(String filename, boolean base64, String provider)
          Create a ShroudedKeyBag with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 Object clone()
          Creates a clone of this ShroudedKeyBag object.
protected  void decode(com.ibm.security.pkcs12.DerValue encoding)
          Initialize a ShroudedKeyBag object from an input stream.
 void encode(OutputStream out)
          Encodes this object to a DER OutputStream.
 boolean equals(Object other)
          Determines if this ShroudedKeyBag object is equivalent to the input object.
 byte[] getEncodedValue()
          Returns the DER-encoded contents of this object.
 String getName()
          Returns the common name for this bag type: "ShroudedKeyBag".
 ObjectIdentifier getObjectIdentifier()
          Returns the object identifier for this PKCS #12 bag.
 Object getValue()
          Returns a copy of the contents of this PKCS #12 bag.
 String toString()
          Returns a string representation of this ShroudedKeyBag 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

ShroudedKeyBag

public ShroudedKeyBag(byte[] der)
               throws IOException
Create a ShroudedKeyBag with a DER byte array. The byte array must represent a DER-encoded ShroudedKeyBag object.
Parameters:
der - a byte array with a DER-encoded KeyBag object.
Throws:
IOException - on parsing errors.

ShroudedKeyBag

public ShroudedKeyBag(byte[] der,
                      String provider)
               throws IOException
Create a ShroudedKeyBag with a DER byte array. The byte array must represent a DER-encoded ShroudedKeyBag object.
Parameters:
der - a byte array with a DER-encoded KeyBag object.
provider - a provider to be used.
Throws:
IOException - on parsing errors.

ShroudedKeyBag

public ShroudedKeyBag(EncryptedPrivateKeyInfo keyInfo)
Create a ShroudedKeyBag with the input EncryptedPrivateKeyInfo.
Parameters:
keyInfo - an EncryptedPrivateKeyInfo object.

ShroudedKeyBag

public ShroudedKeyBag(EncryptedPrivateKeyInfo keyInfo,
                      String provider)
Create a ShroudedKeyBag with the input EncryptedPrivateKeyInfo.
Parameters:
keyInfo - an EncryptedPrivateKeyInfo object.
provider - a provider to be used.

ShroudedKeyBag

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

ShroudedKeyBag

public ShroudedKeyBag(String filename,
                      boolean base64,
                      String provider)
               throws IOException
Create a ShroudedKeyBag 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 - a provider to be used
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.

getObjectIdentifier

public ObjectIdentifier getObjectIdentifier()
Returns the object identifier for this PKCS #12 bag. This object identifier is an immutable object.
Specified by:
getObjectIdentifier in interface Bag
Overrides:
getObjectIdentifier in class PKCSDerObject
Returns:
the ObjectIdentifier for this bag.

getValue

public Object getValue()
Returns a copy of the contents of this PKCS #12 bag. The type of the contents object is an EncryptedPrivateKeyInfo object.
Specified by:
getValue in interface Bag
Returns:
the contents for this bag.

getEncodedValue

public byte[] getEncodedValue()
Returns the DER-encoded contents of this object.
Specified by:
getEncodedValue in interface Bag
Returns:
the DER-encoded EncryptedPrivateKeyInfo of this bag. Null may be returned if the EncryptedPrivateKeyInfo cannot be successfully encoded.

getName

public String getName()
Returns the common name for this bag type: "ShroudedKeyBag".
Specified by:
getName in interface Bag
Returns:
the name of this bag.

equals

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

clone

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

toString

public String toString()
Returns a string representation of this ShroudedKeyBag 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 ShroudedKeyBag object from an input stream. The data on that input stream must be a DER-encoded EncryptedPrivateKeyInfo object.
Parameters:
encoding - an input stream with a DER-encoded EncryptedPrivateKeyInfo object.
Throws:
IOException - on parsing errors.