Skip navigation links

Oracle Fusion Middleware XML Security Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10680-04


oracle.security.xmlsec.enc
Class XEncUtils

java.lang.Object
  extended by oracle.security.xmlsec.enc.XEncUtils


public class XEncUtils
extends java.lang.Object

Simple API for encrypting and decrypting XML Key, Element or Element Content.

Since:
1.1

Method Summary
static java.io.InputStream decryptBytes(XEEncryptedData ed, java.security.PrivateKey keyDecKey)
          Decrypt an EncrytedData, by at first searching for the EncrytedKey inside the KeyInfo of the EncrytedData, and then decrypting the EncryptedKey and then that decrypted key to decrypt the EncryptedData.
static org.w3c.dom.Element decryptElement(org.w3c.dom.Element encryptedData, java.security.Key key)
          Decrypt the given EncryptedData element of data type XML Element or XML Content, and replaces the EncryptedData element with the result.
static java.io.OutputStream encryptBytes(XEEncryptedData ed, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.lang.String dataEncKeyName, java.lang.String keyEncAlg, java.security.PublicKey keyEncKey, java.lang.String keyEncKeyName)
          Encrypt bytes into an EncryptedData element, and encrypt the key into and EncryptedKey element.
static XEEncryptedData encryptElement(org.w3c.dom.Element inputElement, boolean contentOnly, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.lang.String dataEncKeyName)
          Encrypt XML data of type XML Element or XML Element Content with the given algorithm and key, where the key is identified by a key name.
static XEEncryptedData encryptElement(org.w3c.dom.Element inputElement, boolean contentOnly, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.lang.String keyEncAlg, java.security.Key keyEncKey, java.lang.String keyEncKeyName)
          Encrypt XML data of type XML Element or XML Element Content with the given algorithm and key, where the data encryption key is encrypted with the given key encryption key.
static XEEncryptedData encryptElement(org.w3c.dom.Element inputElement, boolean contentOnly, java.lang.String dataEncAlg, java.lang.String keyEncAlg, java.security.Key keyEncKey, java.lang.String keyEncKeyName, java.security.SecureRandom rbs)
          Encrypt XML data of type XML Element or XML Element Content with the given algorithm.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

encryptElement

public static XEEncryptedData encryptElement(org.w3c.dom.Element inputElement,
                                             boolean contentOnly,
                                             java.lang.String dataEncAlg,
                                             javax.crypto.SecretKey dataEncKey,
                                             java.lang.String dataEncKeyName)
                                      throws XEException
Encrypt XML data of type XML Element or XML Element Content with the given algorithm and key, where the key is identified by a key name.

The supported data encrytion algorithms are:

Parameters:
inputElement - The input XML element to be encrypted.
contentOnly - If true, only encrypt the content of the input element; else encrypt the whole element.
dataEncAlg - The URI identifying the data encryption algorithm.
dataEncKey - The data encryption key.
dataEncKeyName - The name identifying the data encryption key, optional.
Returns:
A new XEEncryptedData which replaces the inputElement or its content in its owner document.
Throws:
XEException - If an error occurs in encrypting the data.

encryptElement

public static XEEncryptedData encryptElement(org.w3c.dom.Element inputElement,
                                             boolean contentOnly,
                                             java.lang.String dataEncAlg,
                                             javax.crypto.SecretKey dataEncKey,
                                             java.lang.String keyEncAlg,
                                             java.security.Key keyEncKey,
                                             java.lang.String keyEncKeyName)
                                      throws XEException
Encrypt XML data of type XML Element or XML Element Content with the given algorithm and key, where the data encryption key is encrypted with the given key encryption key.

The supported data encrytion algorithms are:

The supported key encrytion algorithms are:

For RSA-OAEP, the following parameters are used:

Parameters:
inputElement - The input XML elemen to be encrypted.
contentOnly - If true, only encrypt the content of the input element; else encrypt the whole element.
dataEncAlg - The URI identifying the data encryption algorithm.
dataEncKey - The data encryption key.
keyEncAlg - The URI identifying the key encryption algorithm.
keyEncKey - The key encryption key.
keyEncKeyName - The name identifying the key encryption key, optional.
Returns:
A new XEEncryptedData which replaces the inputElement or its content in its owner document.
Throws:
XEException - If an error occurs in encrypting the data.

encryptElement

public static XEEncryptedData encryptElement(org.w3c.dom.Element inputElement,
                                             boolean contentOnly,
                                             java.lang.String dataEncAlg,
                                             java.lang.String keyEncAlg,
                                             java.security.Key keyEncKey,
                                             java.lang.String keyEncKeyName,
                                             java.security.SecureRandom rbs)
                                      throws XEException
Encrypt XML data of type XML Element or XML Element Content with the given algorithm. A random data encryption key is generated for the given algorithm, and is itself encrypted using the given key encryption key.

The supported data encrytion algorithms are:

The supported key encrytion algorithms are:

For RSA-OAEP, the following parameters are used:

Parameters:
inputElement - The input XML elemen to be encrypted.
contentOnly - If true, only encrypt the content of the input element; else encrypt the whole element.
dataEncAlg - The URI identifying the data encryption algorithm.
keyEncAlg - The URI identifying the key encryption algorithm.
keyEncKey - The key encryption key.
keyEncKeyName - The name identifying the key encryption key, optional.
rbs - A PRNG to use for generating the data encryption key, optional. If rbs is null, the default PRNG will be used.
Returns:
A new XEEncryptedData which replaces the inputElement or its content in its owner document.
Throws:
XEException - If an error occurs in encrypting the data.
Since:
2.0

decryptElement

public static org.w3c.dom.Element decryptElement(org.w3c.dom.Element encryptedData,
                                                 java.security.Key key)
                                          throws XEException
Decrypt the given EncryptedData element of data type XML Element or XML Content, and replaces the EncryptedData element with the result.

If the data encryption key is encrypted, the key decryption key will be obtained from the EncryptedData's KeyInfo element. This may be a recursive step, as the key-encryption key may itself be encrypted. The decryption key for the bottom EncryptedKey element (or the EncryptedData element itself if the data encryption key is not encrypted) is either provided by the user, or can be derived by the Diffe-Hellman key agreement method. In the latter case the Diffie-Hellamn private key must be provided by the user.

Parameters:
encryptedData - The EncryptedData element to be decrypted.
key - Data- or key-decryption key, or a Diffie-Hellman private key.
Returns:
The decrypted XML Element.
Throws:
XEException

encryptBytes

public static java.io.OutputStream encryptBytes(XEEncryptedData ed,
                                                java.lang.String dataEncAlg,
                                                javax.crypto.SecretKey dataEncKey,
                                                java.lang.String dataEncKeyName,
                                                java.lang.String keyEncAlg,
                                                java.security.PublicKey keyEncKey,
                                                java.lang.String keyEncKeyName)
                                         throws XEException,
                                                java.io.IOException
Encrypt bytes into an EncryptedData element, and encrypt the key into and EncryptedKey element. Before calling this function you must create a new XEEncryptedData element and put it in your document. This function will create an EncryptedKey inside the EncryptedData function and return an OutputStream. Any bytes that you write into this OutputStream will get encrypted and stored into the CipherData of the EncryptedData element
Parameters:
ed - The EncryptedData element
dataEncAlg - data encryption algorithm
dataEncKey - data encryption key
dataEncKeyName - data encryption key name (optional)
keyEncAlg - Key encryption algorithm
keyEncKey - key encryption key
keyEncKeyName - key encryption key name
Returns:
Throws:
XEException
java.io.IOException

decryptBytes

public static java.io.InputStream decryptBytes(XEEncryptedData ed,
                                               java.security.PrivateKey keyDecKey)
                                        throws XEException
Decrypt an EncrytedData, by at first searching for the EncrytedKey inside the KeyInfo of the EncrytedData, and then decrypting the EncryptedKey and then that decrypted key to decrypt the EncryptedData. The decryption takes place as you read from the returned InputStream
Parameters:
ed - The EncryptedData element to decrypt
keyDecKey - The key decryption key
Returns:
Throws:
XEException

Skip navigation links

Oracle Fusion Middleware XML Security Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10680-04


Copyright © 2005, 2011 , Oracle. All rights reserved.