org.jboss.security.integration.password
Class XMLEncryptionUtil

java.lang.Object
  extended by org.jboss.security.integration.password.XMLEncryptionUtil

public class XMLEncryptionUtil
extends Object

XML Encryption Util Note: This utility is currently using Apache XML Security library API. JSR-106 is not yet final. Until that happens,we rely on the non-standard API.

Since:
Feb 4, 2009
Author:
Anil.Saldhana@redhat.com

Field Summary
static String CIPHER_DATA_LOCALNAME
           
static String DS_KEY_INFO
           
static String ENCRYPTED_DATA_LOCALNAME
           
static String ENCRYPTED_KEY_LOCALNAME
           
static String XMLENC_NS
           
static String XMLNS
           
static String XMLSIG_NS
           
 
Constructor Summary
XMLEncryptionUtil()
           
 
Method Summary
static Document decrypt(Document encryptedDoc, PrivateKey privateKey)
          Decrypt a document
static Document encrypt(Document document, SecretKey secretKey, PublicKey publicKey, int keySize)
          Encrypt a document at the root (Use aes-128)
static org.apache.xml.security.encryption.EncryptedKey encryptKey(Document document, SecretKey keyToBeEncrypted, PublicKey keyUsedToEncryptSecretKey, int keySize)
           Encrypt the Key to be transported
static String getXMLEncryptionURL(String algo, int keySize)
          From the secret key, get the W3C XML Encryption URL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CIPHER_DATA_LOCALNAME

public static final String CIPHER_DATA_LOCALNAME
See Also:
Constant Field Values

ENCRYPTED_DATA_LOCALNAME

public static final String ENCRYPTED_DATA_LOCALNAME
See Also:
Constant Field Values

ENCRYPTED_KEY_LOCALNAME

public static final String ENCRYPTED_KEY_LOCALNAME
See Also:
Constant Field Values

DS_KEY_INFO

public static final String DS_KEY_INFO
See Also:
Constant Field Values

XMLNS

public static final String XMLNS
See Also:
Constant Field Values

XMLSIG_NS

public static String XMLSIG_NS

XMLENC_NS

public static String XMLENC_NS
Constructor Detail

XMLEncryptionUtil

public XMLEncryptionUtil()
Method Detail

encryptKey

public static org.apache.xml.security.encryption.EncryptedKey encryptKey(Document document,
                                                                         SecretKey keyToBeEncrypted,
                                                                         PublicKey keyUsedToEncryptSecretKey,
                                                                         int keySize)
                                                                  throws Exception

Encrypt the Key to be transported

Data is encrypted with a SecretKey. Then the key needs to be transported to the other end where it is needed for decryption. For the Key transport, the SecretKey is encrypted with the recipient's public key. At the receiving end, the receiver can decrypt the Secret Key using his private key.s

Parameters:
document -
keyToBeEncrypted - Symmetric Key (SecretKey)
keyUsedToEncryptSecretKey - Asymmetric Key (Public Key)
keySize - Length of the key
Returns:
Throws:
Exception

encrypt

public static Document encrypt(Document document,
                               SecretKey secretKey,
                               PublicKey publicKey,
                               int keySize)
                        throws Exception
Encrypt a document at the root (Use aes-128)

Parameters:
document -
secretKey -
publicKey -
keySize -
Returns:
Throws:
Exception

decrypt

public static Document decrypt(Document encryptedDoc,
                               PrivateKey privateKey)
                        throws Exception
Decrypt a document

Parameters:
encryptedDoc -
privateKey -
Returns:
Throws:
Exception

getXMLEncryptionURL

public static String getXMLEncryptionURL(String algo,
                                         int keySize)
From the secret key, get the W3C XML Encryption URL

Parameters:
secretKey -
keySize -
Returns:


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.