org.keyczar
Class Verifier

java.lang.Object
  extended by org.keyczar.Verifier
Direct Known Subclasses:
Signer

public class Verifier
extends java.lang.Object

Verifiers are used strictly to verify signatures. Typically, Verifiers will read sets of public keys, although may also be instantiated with sets of symmetric or private keys. Signer objects should be used with symmetric or private key sets to generate signatures.

Author:
steveweis@gmail.com (Steve Weis)

Constructor Summary
Verifier(KeyczarReader reader)
          Initialize a new Verifier with a KeyczarReader.
Verifier(java.lang.String fileLocation)
          Initialize a new Verifier with a key set location.
 
Method Summary
 java.lang.String toString()
           
 boolean verify(byte[] data, byte[] signature)
          Verifies a signature on the given byte array of data
 boolean verify(java.nio.ByteBuffer data, java.nio.ByteBuffer signature)
          Verifies the signature on the data stored in the given ByteBuffer
 boolean verify(java.lang.String data, java.lang.String signature)
          Verifies the signature on the given String
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Verifier

public Verifier(KeyczarReader reader)
         throws KeyczarException
Initialize a new Verifier with a KeyczarReader. The corresponding key set must have a purpose of either KeyPurpose.VERIFY or KeyPurpose.SIGN_AND_VERIFY.

Parameters:
reader - A reader to read keys from
Throws:
KeyczarException - In the event of an IO error reading keys or if the key set does not have the appropriate purpose.

Verifier

public Verifier(java.lang.String fileLocation)
         throws KeyczarException
Initialize a new Verifier with a key set location. This will attempt to read the keys using a KeyczarFileReader. The corresponding key set must have a purpose of either KeyPurpose.VERIFY or KeyPurpose.SIGN_AND_VERIFY

Parameters:
fileLocation - Directory containing a key set
Throws:
KeyczarException - In the event of an IO error reading keys or if the key set does not have the appropriate purpose.
Method Detail

verify

public boolean verify(byte[] data,
                      byte[] signature)
               throws KeyczarException
Verifies a signature on the given byte array of data

Parameters:
data - The data to verify the signature on
signature - The signture to verify
Returns:
Whether this is a valid signature
Throws:
KeyczarException - If the signature is malformed or a JCE error occurs.

verify

public boolean verify(java.nio.ByteBuffer data,
                      java.nio.ByteBuffer signature)
               throws KeyczarException
Verifies the signature on the data stored in the given ByteBuffer

Parameters:
data - The data to verify the signature on
signature - The signature to verify
Returns:
Whether this is a valid signature
Throws:
KeyczarException - If the signature is malformed or a JCE error occurs.

verify

public boolean verify(java.lang.String data,
                      java.lang.String signature)
               throws KeyczarException
Verifies the signature on the given String

Parameters:
data - The data to verify the signature on
signature - The signature to verify
Returns:
Whether this is a valid signature
Throws:
KeyczarException - If the signature is malformed or a JCE error occurs.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object