org.osesb.utilities.encryption
Class XMLSymmetricEncryptionHelper

java.lang.Object
  extended by org.osesb.utilities.encryption.JCESymmetricEncryptionHelper
      extended by org.osesb.utilities.encryption.XMLSymmetricEncryptionHelper

public class XMLSymmetricEncryptionHelper
extends JCESymmetricEncryptionHelper

This class extends JCEEncryptionHelper, adding methods for encrypting org.w3c.dom.Element(s) and Attributes (org.w3c.dom.Attr) using symmetric keys with JCE.

Construct this Class with an EncryptionProviderConfiguration or use getXMLSymmetricEncryptionHelper() to get a XMLEncryptionHelper using a EncryptionProviderConfiguration file that has been configured for the framework.

Since:
Version .9

Field Summary
 
Fields inherited from class org.osesb.utilities.encryption.JCESymmetricEncryptionHelper
DEFAULT_ENCRYPTION_PROVIDER_CONFIGFILE, ENCRYPTION_PROVIDER_CONFIGFILE_PROPERTY, encryptionKey, encryptionProviderConfiguration, log, thisClassName
 
Constructor Summary
XMLSymmetricEncryptionHelper(EncryptionProviderConfiguration encryptionProviderConfiguration)
          Creates a new instance of XMLEncryptionHelper with the EncryptionProviderConfiguration.
 
Method Summary
 void encryptAttributeValue(org.w3c.dom.Attr attribute)
          Encrypts the value of a DOM Attribute.
 void encryptAttributeValue(org.w3c.dom.Attr attribute, java.lang.String prefix)
          Encrypts the value of a DOM Attribute and prepends a prefix to the encrypted value.
 void encryptElementValue(org.w3c.dom.Element element)
          Encrypts the value of a DOM Element.
 void encryptElementValue(org.w3c.dom.Element element, java.lang.String prefix)
          Encrypts the value of a DOM Element and prepends a prefix to the encrypted value.
 void encryptElementValueAndAddAttribute(org.w3c.dom.Element element, java.lang.String attributeName, java.lang.String attributeValue)
          Encrypts the value of a DOM Element and adds an Attribute to the Element with the specified name and value.
 void encryptNodeValue(org.w3c.dom.Node node)
          Encrypts the value of a DOM Node (Element or Attribute).
 void encryptNodeValue(org.w3c.dom.Node node, java.lang.String prefix)
          Encrypts the value of a DOM Node and prepends a prefix to the encrypted value.
static XMLSymmetricEncryptionHelper getXMLSymmetricEncryptionHelper()
          Construct and return a new instance of XMLEncryptionHelper, using the following ordered lookup:

1.

static void main(java.lang.String[] args)
          main() for sandboxing and testing.
 
Methods inherited from class org.osesb.utilities.encryption.JCESymmetricEncryptionHelper
decryptBase64String, decryptByteArray, encryptByteArray, encryptToBase64String, generateKey, getEncryptionKey, getJCESymmetricEncryptionHelper, getProvidersInfo, readKeyObjectFromFile, readKeyObjectFromPath, readKeyObjectFromResource, setEncryptionKey, writeKeyObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSymmetricEncryptionHelper

public XMLSymmetricEncryptionHelper(EncryptionProviderConfiguration encryptionProviderConfiguration)
                             throws java.lang.Exception
Creates a new instance of XMLEncryptionHelper with the EncryptionProviderConfiguration.

Parameters:
encryptionProviderConfiguration - The EncryptionProviderConfiguration object to use for this helper.
Throws:
java.lang.Exception - if constructed with null EncryptionProviderConfiguration or if there is a problem loading the encryption provider or reading the encryption key.
Method Detail

getXMLSymmetricEncryptionHelper

public static XMLSymmetricEncryptionHelper getXMLSymmetricEncryptionHelper()
                                                                    throws java.lang.Exception
Construct and return a new instance of XMLEncryptionHelper, using the following ordered lookup:

1. The System Property defined by ENCRYPTION_PROVIDER_CONFIGFILE_PROPERTY is used to determine the EncryptionProviderConfiguration file, which is used to construct a new instance of JCEEncryptionHelper.

2. The default EncryptionProviderConfiguration file, DEFAULT_ENCRYPTION_PROVIDER_CONFIGFILE, is used to construct a new instance of JCEEncryptionHelper.

Returns:
a new instance of XMLEncryptionHelper.
Throws:
java.lang.Exception - if an instance of XMLEncryptionHelper cannot be returned.

encryptNodeValue

public void encryptNodeValue(org.w3c.dom.Node node)
                      throws java.lang.Exception
Encrypts the value of a DOM Node (Element or Attribute).

Parameters:
node - The DOM Node to encrypt.
Throws:
java.lang.Exception

encryptNodeValue

public void encryptNodeValue(org.w3c.dom.Node node,
                             java.lang.String prefix)
                      throws java.lang.Exception
Encrypts the value of a DOM Node and prepends a prefix to the encrypted value.

Parameters:
node - The DOM Node to encrypt.
prefix - The prefix to prepend to the encrypted Node's value.
Throws:
java.lang.Exception

encryptElementValue

public void encryptElementValue(org.w3c.dom.Element element)
                         throws java.lang.Exception
Encrypts the value of a DOM Element.

Parameters:
element - The DOM Element to encrypt.
Throws:
java.lang.Exception

encryptElementValue

public void encryptElementValue(org.w3c.dom.Element element,
                                java.lang.String prefix)
                         throws java.lang.Exception
Encrypts the value of a DOM Element and prepends a prefix to the encrypted value.

Parameters:
element - The DOM Element to encrypt.
prefix - The prefix to prepend to the encrypted Element's value.
Throws:
java.lang.Exception

encryptElementValueAndAddAttribute

public void encryptElementValueAndAddAttribute(org.w3c.dom.Element element,
                                               java.lang.String attributeName,
                                               java.lang.String attributeValue)
                                        throws java.lang.Exception
Encrypts the value of a DOM Element and adds an Attribute to the Element with the specified name and value.

Parameters:
element - The DOM Element to encrypt.
attributeName - The name of the Attribute to add to the Element.
attributeValue - The value of the Attribute to add to the Element.
Throws:
java.lang.Exception

encryptAttributeValue

public void encryptAttributeValue(org.w3c.dom.Attr attribute)
                           throws java.lang.Exception
Encrypts the value of a DOM Attribute.

Parameters:
attribute - The DOM Attribute to encrypt.
Throws:
java.lang.Exception

encryptAttributeValue

public void encryptAttributeValue(org.w3c.dom.Attr attribute,
                                  java.lang.String prefix)
                           throws java.lang.Exception
Encrypts the value of a DOM Attribute and prepends a prefix to the encrypted value.

Parameters:
attribute - The DOM Attribute to encrypt.
prefix - The prefix to prepend to the encrypted Attribute's value.
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
main() for sandboxing and testing.

Parameters:
args - commandline arguments