com.ibm.security.pkcs9
Class ChallengePassword

java.lang.Object
  |
  +--com.ibm.security.pkcsutil.PKCSDerObject
        |
        +--com.ibm.security.pkcs9.PKCS9DerObject
              |
              +--com.ibm.security.pkcs9.ChallengePassword

public final class ChallengePassword
extends PKCS9DerObject
implements Cloneable

Implements the ASN.1 ChallengePassword attribute type.

A ChallengePassword attribute must have a single attribute value.

ChallengePassword ::= CHOICE { PrintableString, T61String }

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


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
ChallengePassword(byte[] der)
          Create a ChallengePassword object with a DER byte array.
ChallengePassword(byte[] der, String provider)
          Create a ChallengePassword object with a DER byte array.
ChallengePassword(char[] password)
          Create a ChallengePassword object with a character array.
ChallengePassword(char[] password, byte type)
          Create a ChallengePassword object with a character array and a type to indicate if the String should be encoded as PrintableString or T61String.
ChallengePassword(char[] password, byte type, String provider)
          Create a ChallengePassword object with a character array and a type to indicate if the String should be encoded as PrintableString or T61String.
ChallengePassword(char[] password, String provider)
          Create a ChallengePassword object with a character array.
ChallengePassword(String filename, boolean base64)
          Create a ChallengePassword with the filename of the DER-encoded or BASE64-encoded object.
ChallengePassword(String filename, boolean base64, String provider)
          Create a ChallengePassword with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 Object clone()
          Creates a clone of this ChallengePassword object.
protected  void decode(com.ibm.security.pkcs9.DerValue encoding)
          Initializes a ChallengePassword object from a DerValue.
 void encode(OutputStream os)
          Encodes this object to an OutputStream.
 boolean equals(Object obj)
          Determines if this ChallengePassword object is equivalent to the input object.
protected  void finalize()
          Ensures that the password is blanked out when there are no more references to this object.
 String getAttributeName()
          Returns a String indicating the name of the attribute.
 ObjectIdentifier getObjectIdentifier()
          Returns the ObjectIdentifer for the ChallengePassword attribute.
 char[] getPassword()
          Returns a copy of the password of this ChallengePassword object.
 byte getType()
          Returns the type attribute to indicate how the password should be encoded.
 Object getValue()
          Calls the getPassword method.
 boolean isSingleValued()
          Returns true.
 boolean isTagValid(byte tag)
          Returns a boolean indicating if the tag is valid for this object.
 String toString()
          Returns a string representation of this ChallengePassword object.
 
Methods inherited from class com.ibm.security.pkcs9.PKCS9DerObject
getName, getOID, getPKCSAttribute
 
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
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChallengePassword

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

ChallengePassword

public ChallengePassword(byte[] der,
                         String provider)
                  throws IOException
Create a ChallengePassword object with a DER byte array.
Parameters:
der - a DER byte array of a ChallengePassword object.
provider - the provider to be used.
Throws:
IOException - on decoding errors.

ChallengePassword

public ChallengePassword(char[] password)
Create a ChallengePassword object with a character array. The type format defaults to PrintableString.
Parameters:
password - String

ChallengePassword

public ChallengePassword(char[] password,
                         String provider)
Create a ChallengePassword object with a character array. The type format defaults to PrintableString.
Parameters:
password - String
provider - the provider to be used

ChallengePassword

public ChallengePassword(char[] password,
                         byte type)
Create a ChallengePassword object with a character array and a type to indicate if the String should be encoded as PrintableString or T61String.
Parameters:
password - a character array holding the password.
type - PrintableString or T61String.

ChallengePassword

public ChallengePassword(char[] password,
                         byte type,
                         String provider)
Create a ChallengePassword object with a character array and a type to indicate if the String should be encoded as PrintableString or T61String.
Parameters:
password - a character array holding the password.
type - PrintableString or T61String.
provider - the provider to be used.

ChallengePassword

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

ChallengePassword

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

clone

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

equals

public boolean equals(Object obj)
Determines if this ChallengePassword 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 ChallengePassword attribute.
Overrides:
getObjectIdentifier in class PKCSDerObject
Returns:
the ObjectIdentifer for the ChallengePassword attribute.

encode

public void encode(OutputStream os)
            throws IOException
Encodes this object to an OutputStream. The ChallengePassword object is encoded as a PrintableString or T61String depending upon the type attribute value.
Overrides:
encode in class PKCSDerObject
Parameters:
os - the OutputStream to write the encoded data to.
Throws:
IOException - on encoding errors.

getPassword

public char[] getPassword()
Returns a copy of the password of this ChallengePassword object.
Returns:
password stored with this ChallengePassword object.

getType

public byte getType()
Returns the type attribute to indicate how the password should be encoded. The type attribute is an immutable object.
Returns:
PrintableString or T61String.

getValue

public Object getValue()
Calls the getPassword method. Standard method to access the value of the PKCS #9 object.
Overrides:
getValue in class PKCS9DerObject

isTagValid

public boolean isTagValid(byte tag)
Returns a boolean indicating if the tag is valid for this object.
Overrides:
isTagValid in class PKCS9DerObject
Returns:
true if PrintableString or T61String, false otherwise.

isSingleValued

public boolean isSingleValued()
Returns true. ChallengePassword must have a single attribute value.
Overrides:
isSingleValued in class PKCS9DerObject
Returns:
true

getAttributeName

public String getAttributeName()
Returns a String indicating the name of the attribute.
Overrides:
getAttributeName in class PKCS9DerObject
Returns:
name of the ChallengePassword attribute.

toString

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

decode

protected void decode(com.ibm.security.pkcs9.DerValue encoding)
               throws IOException
Initializes a ChallengePassword object from a DerValue. The DER encoding must be in the format specified by the ChallengePassword ASN.1 notation. The type attribute on the ChallengePassword object is set according to the DER encoding tag.
Overrides:
decode in class PKCS9DerObject
Parameters:
encoding - a DER-encoded ChallengePassword object.
Throws:
IOException - on parsing error.

finalize

protected void finalize()
Ensures that the password is blanked out when there are no more references to this object.
Overrides:
finalize in class Object