com.ibm.security.pkcsutil
Class SignedPublicKeyAndChallenge

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

public final class SignedPublicKeyAndChallenge
extends PKCSDerObject

Implements SignedPublicKeyAndChallenge

SignedPublicKeyAndChallenge ::= SEQUENCE { publicKeyAndChallenge PublicKeyAndChallenge, signatureAlgorithm AlgorithmIdentifier, signature BIT STRING }

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


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
SignedPublicKeyAndChallenge(byte[] der)
          Create a SignedPublicKeyAndChallenge object with a DER byte array.
SignedPublicKeyAndChallenge(byte[] der, String provider)
          Create a SignedPublicKeyAndChallenge object with a DER byte array.
SignedPublicKeyAndChallenge(PublicKeyAndChallenge publicKeyAndChallenge, String signatureAlgorithm, PrivateKey privateKey)
          Create a SignedPublicKeyAndChallenge object from a PublicKeyAndChallenge and a privateKey.
SignedPublicKeyAndChallenge(PublicKeyAndChallenge publicKeyAndChallenge, String signatureAlgorithm, PrivateKey privateKey, String provider)
          Create a SignedPublicKeyAndChallenge object from a PublicKeyAndChallenge and a privateKey.
 
Method Summary
 Object clone()
          Creates a clone of this SignedPublicKeyAndChallenge object.
protected  void decode(com.ibm.security.pkcsutil.DerValue encoding)
          Initializes a SignedPublicKeyAndChallenge object from a DerValue.
 void encode(OutputStream os)
          Encodes this object to an OutputStream.
 boolean equals(Object other)
          Determines if this SignedPublicKeyAndChallenge object is equivalent to the input object.
 PublicKeyAndChallenge getPublicKeyAndChallenge()
          Returns the PublicKeyAndChallenge.
 byte[] getSignature()
          Returns a copy of the signature byte array.
 AlgorithmId getSignatureAlgorithm()
          Returns a copy of the signature algorithm for this object.
 String toString()
          Returns a string representation of this SignedPublicKeyAndChallenge object.
 boolean verify()
          Verifies the signature of the SignedPublicKeyAndChallenge based on the public key stored with the PublicKeyAndChallenge.
 
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

SignedPublicKeyAndChallenge

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

SignedPublicKeyAndChallenge

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

SignedPublicKeyAndChallenge

public SignedPublicKeyAndChallenge(PublicKeyAndChallenge publicKeyAndChallenge,
                                   String signatureAlgorithm,
                                   PrivateKey privateKey)
                            throws NoSuchAlgorithmException,
                                   SignatureException,
                                   InvalidKeyException
Create a SignedPublicKeyAndChallenge object from a PublicKeyAndChallenge and a privateKey. The private key will be used to sign the contents of the SignedPublicKeyAndChallenge
Parameters:
publicKey - PublicKey
challenge - Challenge string
signatureAlgorithm - Signature algorithm string

SignedPublicKeyAndChallenge

public SignedPublicKeyAndChallenge(PublicKeyAndChallenge publicKeyAndChallenge,
                                   String signatureAlgorithm,
                                   PrivateKey privateKey,
                                   String provider)
                            throws NoSuchAlgorithmException,
                                   SignatureException,
                                   InvalidKeyException
Create a SignedPublicKeyAndChallenge object from a PublicKeyAndChallenge and a privateKey. The private key will be used to sign the contents of the SignedPublicKeyAndChallenge
Parameters:
publicKey - PublicKey
challenge - Challenge string
signatureAlgorithm - Signature algorithm string
provider - the provider to be used
Method Detail

getSignatureAlgorithm

public AlgorithmId getSignatureAlgorithm()
                                  throws IOException
Returns a copy of the signature algorithm for this object.
Returns:
the signature algorithm for this object.

getSignature

public byte[] getSignature()
Returns a copy of the signature byte array.
Returns:
the signature byte array.

getPublicKeyAndChallenge

public PublicKeyAndChallenge getPublicKeyAndChallenge()
Returns the PublicKeyAndChallenge.
Returns:
PublicKeyAndChallenge

verify

public boolean verify()
               throws NoSuchAlgorithmException,
                      InvalidKeyException,
                      SignatureException,
                      IOException
Verifies the signature of the SignedPublicKeyAndChallenge based on the public key stored with the PublicKeyAndChallenge.
Returns:
boolean true if the signature is valid; false otherwise

encode

public void encode(OutputStream os)
            throws IOException
Encodes this 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 SignedPublicKeyAndChallenge object from a DerValue. The DER encoding must be in the format specified by the SignedPublicKeyAndChallenge ASN.1 notation.
Overrides:
decode in class PKCSDerObject
Parameters:
encoding - a DER-encoded SignedPublicKeyAndChallenge object.
Throws:
IllegalArgumentException - invalid version.
IOException - on parsing error.

equals

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

clone

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