com.ibm.security.pkcsutil
Class PublicKeyAndChallenge

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

public final class PublicKeyAndChallenge
extends PKCSDerObject

Implements PublicKeyAndChallenge

PublicKeyAndChallenge ::= SEQUENCE { spki SubjectPublicKeyInfo, challenge IA5STRING }

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


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
PublicKeyAndChallenge(byte[] der)
          Create a PublicKeyAndChallenge object with a DER byte array.
PublicKeyAndChallenge(byte[] der, String provider)
          Create a PublicKeyAndChallenge object with a DER byte array.
PublicKeyAndChallenge(PublicKey publicKey, String challenge)
          Create a PublicKeyAndChallenge object.
PublicKeyAndChallenge(PublicKey publicKey, String challenge, String provider)
          Create a PublicKeyAndChallenge object.
 
Method Summary
 Object clone()
          Creates a clone of this PublicKeyAndChallenge object.
protected  void decode(com.ibm.security.pkcsutil.DerValue encoding)
          Initializes a PublicKeyAndChallenge object from a DerValue.
 void encode(OutputStream os)
          Encodes this PublicKeyAndChallenge object to an OutputStream.
 boolean equals(Object other)
          Determines if this PublicKeyAndChallenge object is equivalent to the input object.
 String getChallenge()
          Returns the challenge String.
 PublicKey getSubjectPublicKeyInfo()
          Returns a copy of the subject public key info.
 String toString()
          Returns a string representation of this PublicKeyAndChallenge object.
 
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject
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

PublicKeyAndChallenge

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

PublicKeyAndChallenge

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

PublicKeyAndChallenge

public PublicKeyAndChallenge(PublicKey publicKey,
                             String challenge)
                      throws InvalidKeyException
Create a PublicKeyAndChallenge object.
Parameters:
publicKey - the public key in X.509 format
challenge - the challenge string

PublicKeyAndChallenge

public PublicKeyAndChallenge(PublicKey publicKey,
                             String challenge,
                             String provider)
                      throws InvalidKeyException
Create a PublicKeyAndChallenge object.
Parameters:
publicKey - the public key in X.509 format
challenge - the challenge string
provider - the provider to be used
Method Detail

getSubjectPublicKeyInfo

public PublicKey getSubjectPublicKeyInfo()
                                  throws InvalidKeyException,
                                         IOException
Returns a copy of the subject public key info.
Returns:
the public key info for this object.
Throws:
InvalidKeyException - if a copy of the public key info cannot be generated.

getChallenge

public String getChallenge()
Returns the challenge String.
Returns:
the challenge String.

encode

public void encode(OutputStream os)
            throws IOException
Encodes this PublicKeyAndChallenge object to an OutputStream.
Overrides:
encode in class PKCSDerObject
Parameters:
os - the OutputStream to write the encoded data to.
Throws:
IOException - on encoding error.

decode

protected void decode(com.ibm.security.pkcsutil.DerValue encoding)
               throws IOException
Initializes a PublicKeyAndChallenge object from a DerValue. The DER encoding must be in the format specified by the PublicKeyAndChallenge ASN.1 notation.
Overrides:
decode in class PKCSDerObject
Parameters:
encoding - a DER-encoded PublicKeyAndChallenge object.
Throws:
IOException - on parsing error.

equals

public boolean equals(Object other)
Determines if this PublicKeyAndChallenge object is equivalent to the input object.
Overrides:
equals in class PKCSDerObject
Parameters:
other - the PublicKeyAndChallenge 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 PublicKeyAndChallenge object.
Overrides:
toString in class PKCSDerObject
Returns:
a string representation of this object.

clone

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