atg.nucleus
Class Validator

java.lang.Object
  extended by atg.nucleus.Validator

public class Validator
extends java.lang.Object

This class contains utility methods for validating the property values of a service against a DSA signature.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
Validator()
           
 
Method Summary
static java.lang.String byteArrayToPropertyValue(byte[] pBytes)
          Converts the specified byte array to a comma-separated list of values suitable for use in a property file.
static java.lang.String calculateSignature(java.lang.Object pService, java.lang.String[] pPropertyList, java.security.PrivateKey pKey)
          Calculates the signature determined by serializing the values of each of the named properties of the specified service, signing the resulting serialized byte array with the specified private key, then listing the resulting bytes as a comma-separated list suitable for use in a properties file.
static java.security.PrivateKey deserializePrivateKey(java.lang.String pKey)
          Deserializes a private key from the specified string, which contains the serialized form of the key represented as hexadecimal digits.
static java.security.PublicKey deserializePublicKey(java.lang.String pKey)
          Deserializes a public key from the specified string, which contains the serialized form of the key represented as hexadecimal digits.
static void validateProperties(java.lang.Object pService, java.lang.String[] pPropertyList, byte[] pSignature, java.security.PublicKey pKey, java.lang.String pMessage)
          This tests to see if the the currently serialized values of the given properties match the values signed by the given key's corresponding private key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

Validator

public Validator()
Method Detail

validateProperties

public static void validateProperties(java.lang.Object pService,
                                      java.lang.String[] pPropertyList,
                                      byte[] pSignature,
                                      java.security.PublicKey pKey,
                                      java.lang.String pMessage)
                               throws ValidationException
This tests to see if the the currently serialized values of the given properties match the values signed by the given key's corresponding private key.

Parameters:
pService - the object whose properties are to be examined
pPropertyList - the list of property names to be examined
pSignature - the signature obtained by signing the expected property values with a private key.
pKey - the public key corresponding to the private key used to generate the signature.
pMessage - a message to be attached to the ValidationException if the property values do not match.
Throws:
ValidationException - if the property values do not match the digest, or if some other error occurred while attempting to verify the property values.

calculateSignature

public static java.lang.String calculateSignature(java.lang.Object pService,
                                                  java.lang.String[] pPropertyList,
                                                  java.security.PrivateKey pKey)
Calculates the signature determined by serializing the values of each of the named properties of the specified service, signing the resulting serialized byte array with the specified private key, then listing the resulting bytes as a comma-separated list suitable for use in a properties file.


byteArrayToPropertyValue

public static java.lang.String byteArrayToPropertyValue(byte[] pBytes)
Converts the specified byte array to a comma-separated list of values suitable for use in a property file.


deserializePublicKey

public static java.security.PublicKey deserializePublicKey(java.lang.String pKey)
Deserializes a public key from the specified string, which contains the serialized form of the key represented as hexadecimal digits. Because this is intended to be used in an initializer, it handles exceptions by printing them to stdout then exitting the program.


deserializePrivateKey

public static java.security.PrivateKey deserializePrivateKey(java.lang.String pKey)
Deserializes a private key from the specified string, which contains the serialized form of the key represented as hexadecimal digits. Because this is intended to be used in an initializer, it handles exceptions by printing them to stdout then exitting the program.