com.ibm.security.pkcsutil
Class PKCSDerObject

java.lang.Object
  |
  +--com.ibm.security.pkcsutil.PKCSDerObject
Direct Known Subclasses:
AuthenticatedSafe, CertBag, CertificationRequest, CertificationRequestInfo, Content, ContentInfo, CrlBag, DigestInfo, EncapsulatedContentInfo, EncryptedContentInfo, EncryptedPrivateKeyInfo, IssuerAndSerialNumber, KeyBag, MacData, MailListKeyIdentifier, OriginatorInfo, PKCS9DerObject, PrivateKeyInfo, PublicKeyAndChallenge, RecipientInfo, RecipientKeyIdentifier, SafeBag, SafeContents, SafeContentsBag, SecretBag, ShroudedKeyBag, SignedPublicKeyAndChallenge, SignerIdentifier, SubjectKeyIdentifier, UserKeyingMaterial

public abstract class PKCSDerObject
extends Object
implements Cloneable

Abstract class inherited by other PKCS objects.


Field Summary
protected  String provider
           
 
Constructor Summary
PKCSDerObject()
          Create a PKCSDerObject subclass with attributes to be filled in at a later stage.
PKCSDerObject(byte[] der)
          Create a PKCSDerObject subclass with a DER-encoded byte array.
PKCSDerObject(byte[] der, String provider)
          Create a PKCSDerObject subclass with a DER-encoded byte array.
PKCSDerObject(String provider)
          Create a PKCSDerObject subclass with attributes to be filled in at a later stage.
PKCSDerObject(String filename, boolean base64)
          Create a PKCSDerObject subclass with the filename of the DER-encoded or BASE64-encoded object.
PKCSDerObject(String filename, boolean base64, String provider)
          Create a PKCSDerObject subclass with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
protected  void decode(byte[] der)
          Decode the attributes of the PKCSDerObject subclass from a DER byte array.
protected abstract  void decode(com.ibm.security.pkcsutil.DerValue encoding)
          Decode the attributes of the PKCSDerObject subclass from a DerValue.
 byte[] encode()
          Return an encoded DER byte array.
abstract  void encode(OutputStream os)
          Return an encoded DER byte array on an OutputStream.
abstract  boolean equals(Object obj)
          Determines if this object is equivalent to the input object.
 ObjectIdentifier getObjectIdentifier()
          Return the ObjectIdentifier for the object, if specified.
 int hashCode()
          Returns a hashcode value for this object.
protected  void read(String filename)
          Read the byte array of a DER-encode object from the input file and decode the contents into the current object.
protected  void readBASE64(String filename)
          Read the BASE64 encoding of a DER-encode object from the input file and decode the contents into the current object.
abstract  String toString()
          Returns a string representation of this object.
protected  void write(String filename)
          DER-encode the object and write the encoded bytes to the output file.
 void write(String filename, boolean isBase64)
          DER-encode the object and write the encoded bytes to the output file.
protected  void writeBASE64(String filename)
          DER-encode the object and write the encoded bytes to the output file in BASE64 format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

provider

protected String provider
Constructor Detail

PKCSDerObject

public PKCSDerObject()
Create a PKCSDerObject subclass with attributes to be filled in at a later stage.

PKCSDerObject

public PKCSDerObject(String provider)
Create a PKCSDerObject subclass with attributes to be filled in at a later stage.

PKCSDerObject

public PKCSDerObject(byte[] der)
              throws IOException
Create a PKCSDerObject subclass with a DER-encoded byte array.

PKCSDerObject

public PKCSDerObject(byte[] der,
                     String provider)
              throws IOException
Create a PKCSDerObject subclass with a DER-encoded byte array.

PKCSDerObject

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

PKCSDerObject

public PKCSDerObject(String filename,
                     boolean base64,
                     String provider)
              throws IOException
Create a PKCSDerObject subclass 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 be used
Throws:
IOException - on decoding errors.
Method Detail

encode

public byte[] encode()
              throws IOException
Return an encoded DER byte array.

hashCode

public int hashCode()
Returns a hashcode value for this object.
Overrides:
hashCode in class Object

getObjectIdentifier

public ObjectIdentifier getObjectIdentifier()
Return the ObjectIdentifier for the object, if specified.

write

public void write(String filename,
                  boolean isBase64)
           throws IOException
DER-encode the object and write the encoded bytes to the output file. If the isBase64 boolean argument is true, write the DER-encoded object in BASE64 format.
Parameters:
filename - the file to write the DER-encoded object to.
isBase64 - true if the DER-encoded object should be written in BASE64 format, false otherwise.
Throws:
IOException - if the file cannot be created or written to.

decode

protected void decode(byte[] der)
               throws IOException
Decode the attributes of the PKCSDerObject subclass from a DER byte array.

read

protected void read(String filename)
             throws IOException
Read the byte array of a DER-encode object from the input file and decode the contents into the current object.
Parameters:
filename - the file to read an object's DER encoding from.
Throws:
IOException - if the file cannot be created or read from.

readBASE64

protected void readBASE64(String filename)
                   throws IOException
Read the BASE64 encoding of a DER-encode object from the input file and decode the contents into the current object.
Parameters:
filename - the BASE64 file to read an object's DER encoding from.
Throws:
IOException - if the file cannot be created or read from.

write

protected void write(String filename)
              throws IOException
DER-encode the object and write the encoded bytes to the output file.
Parameters:
filename - the file to write the DER-encoded object to.
Throws:
IOException - if the file cannot be created or written to.

writeBASE64

protected void writeBASE64(String filename)
                    throws IOException
DER-encode the object and write the encoded bytes to the output file in BASE64 format.
Parameters:
filename - the file to write the BASE64 DER-encoded object to.
Throws:
IOException - if the file cannot be created or written to.

decode

protected abstract void decode(com.ibm.security.pkcsutil.DerValue encoding)
                        throws IOException
Decode the attributes of the PKCSDerObject subclass from a DerValue.

encode

public abstract void encode(OutputStream os)
                     throws IOException
Return an encoded DER byte array on an OutputStream.

toString

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

equals

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