|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.identity.federation.api.util.XMLEncryptionUtil
public class XMLEncryptionUtil
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.
Field Summary | |
---|---|
static java.lang.String |
CIPHER_DATA_LOCALNAME
|
static java.lang.String |
DS_KEY_INFO
|
static java.lang.String |
ENCRYPTED_KEY_LOCALNAME
|
static java.lang.String |
XMLENC_NS
|
static java.lang.String |
XMLNS
|
static java.lang.String |
XMLSIG_NS
|
Constructor Summary | |
---|---|
XMLEncryptionUtil()
|
Method Summary | |
---|---|
static org.w3c.dom.Element |
decryptElementInDocument(org.w3c.dom.Document documentWithEncryptedElement,
java.security.PrivateKey privateKey)
Decrypt an encrypted element inside a document |
static void |
encryptElement(javax.xml.namespace.QName elementQName,
org.w3c.dom.Document document,
java.security.PublicKey publicKey,
javax.crypto.SecretKey secretKey,
int keySize,
javax.xml.namespace.QName wrappingElementQName,
boolean addEncryptedKeyInKeyInfo)
Given an element in a Document, encrypt the element and replace the element in the document with the encrypted data |
static org.w3c.dom.Element |
encryptElementInDocument(org.w3c.dom.Document document,
java.security.PublicKey publicKey,
javax.crypto.SecretKey secretKey,
int keySize,
javax.xml.namespace.QName wrappingElementQName,
boolean addEncryptedKeyInKeyInfo)
Encrypt the root document element inside a Document. |
static org.apache.xml.security.encryption.EncryptedKey |
encryptKey(org.w3c.dom.Document document,
javax.crypto.SecretKey keyToBeEncrypted,
java.security.PublicKey keyUsedToEncryptSecretKey,
int keySize)
Encrypt the Key to be transported |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CIPHER_DATA_LOCALNAME
public static final java.lang.String ENCRYPTED_KEY_LOCALNAME
public static final java.lang.String DS_KEY_INFO
public static final java.lang.String XMLNS
public static java.lang.String XMLSIG_NS
public static java.lang.String XMLENC_NS
Constructor Detail |
---|
public XMLEncryptionUtil()
Method Detail |
---|
public static org.apache.xml.security.encryption.EncryptedKey encryptKey(org.w3c.dom.Document document, javax.crypto.SecretKey keyToBeEncrypted, java.security.PublicKey keyUsedToEncryptSecretKey, int keySize) throws java.lang.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
document
- keyToBeEncrypted
- Symmetric Key (SecretKey)keyUsedToEncryptSecretKey
- Asymmetric Key (Public Key)keySize
- Length of the key
java.lang.Exception
public static void encryptElement(javax.xml.namespace.QName elementQName, org.w3c.dom.Document document, java.security.PublicKey publicKey, javax.crypto.SecretKey secretKey, int keySize, javax.xml.namespace.QName wrappingElementQName, boolean addEncryptedKeyInKeyInfo) throws java.lang.Exception
elementQName
- QName of the element that we like to encryptpublicKey
- secretKey
- keySize
- wrappingElementQName
- A QName of an element that will wrap the encrypted elementaddEncryptedKeyInKeyInfo
- Need for the EncryptedKey to be placed in ds:KeyInfo
java.lang.Exception
public static org.w3c.dom.Element encryptElementInDocument(org.w3c.dom.Document document, java.security.PublicKey publicKey, javax.crypto.SecretKey secretKey, int keySize, javax.xml.namespace.QName wrappingElementQName, boolean addEncryptedKeyInKeyInfo) throws java.lang.Exception
document
- Document that contains an element to encryptpublicKey
- The Public Key used to encrypt the secret encryption keysecretKey
- The secret encryption keykeySize
- Length of keywrappingElementQName
- QName of the element to be used to wrap around
the cipher data.addEncryptedKeyInKeyInfo
- Should the encrypted key be inside a KeyInfo
or added as a peer of Cipher Data
java.lang.Exception
public static org.w3c.dom.Element decryptElementInDocument(org.w3c.dom.Document documentWithEncryptedElement, java.security.PrivateKey privateKey) throws java.lang.Exception
documentWithEncryptedElement
- privateKey
- key need to unwrap the encryption key
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |