Package com.sun.identity.saml2.xmlenc
Class FMEncProvider
- java.lang.Object
-
- com.sun.identity.saml2.xmlenc.FMEncProvider
-
- All Implemented Interfaces:
EncProvider
public final class FMEncProvider extends Object implements EncProvider
FMEncProvieris a class for encrypting and decrypting XML documents, it implementsEncProvider.
-
-
Constructor Summary
Constructors Constructor Description FMEncProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Elementdecrypt(String xmlString, Set<PrivateKey> privateKeys)Decrypts an XML document that contains encrypted data.Elementencrypt(String xmlString, Key recipientPublicKey, String dataEncAlgorithm, int dataEncStrength, String recipientEntityID, String outerElementName)Encrypts the root element of the given XML document.Elementencrypt(String xmlString, Key recipientPublicKey, SecretKey secretKey, String dataEncAlgorithm, int dataEncStrength, String recipientEntityID, String outerElementName)Encrypts the root element of the given XML document.SecretKeygetSecretKey(String xmlString, Set<PrivateKey> privateKeys)Returns the secret key that encrypts encrypted data and is encrypted with recipient's public key in the XML document.
-
-
-
Method Detail
-
encrypt
public Element encrypt(String xmlString, Key recipientPublicKey, String dataEncAlgorithm, int dataEncStrength, String recipientEntityID, String outerElementName) throws SAML2Exception
Encrypts the root element of the given XML document.- Specified by:
encryptin interfaceEncProvider- Parameters:
xmlString- String representing an XML document whose root element is to be encrypted.recipientPublicKey- Public key used to encrypt the data encryption (secret) key, it is the public key of the recipient of the XML document to be encrypted.dataEncAlgorithm- Data encryption algorithm.dataEncStrength- Data encryption strength.recipientEntityID- Unique identifier of the recipient, it is used as the index to the cached secret key so that the key can be reused for the same recipient; It can be null in which case the secret key will be generated every time and will not be cached and reused. Note that the generation of a secret key is a relatively expensive operation.outerElementName- Name of the element that will wrap around the encrypted data and encrypted key(s) sub-elements- Returns:
- org.w3c.dom.Element Root element of the encypted document; The name of this root element is indicated by the last input parameter
- Throws:
SAML2Exception- if there is an error during the encryption process
-
encrypt
public Element encrypt(String xmlString, Key recipientPublicKey, SecretKey secretKey, String dataEncAlgorithm, int dataEncStrength, String recipientEntityID, String outerElementName) throws SAML2Exception
Encrypts the root element of the given XML document.- Specified by:
encryptin interfaceEncProvider- Parameters:
xmlString- String representing an XML document whose root element is to be encrypted.recipientPublicKey- Public key used to encrypt the data encryption (secret) key, it is the public key of the recipient of the XML document to be encrypted.secretKey- the secret key used to encrypted data.dataEncAlgorithm- Data encryption algorithm.dataEncStrength- Data encryption strength.recipientEntityID- Unique identifier of the recipient, it is used as the index to the cached secret key so that the key can be reused for the same recipient; It can be null in which case the secret key will be generated every time and will not be cached and reused. Note that the generation of a secret key is a relatively expensive operation.outerElementName- Name of the element that will wrap around the encrypted data and encrypted key(s) sub-elements- Returns:
- org.w3c.dom.Element Root element of the encypted document; The name of this root element is indicated by the last input parameter
- Throws:
SAML2Exception- if there is an error during the encryption process
-
getSecretKey
public SecretKey getSecretKey(String xmlString, Set<PrivateKey> privateKeys) throws SAML2Exception
Description copied from interface:EncProviderReturns the secret key that encrypts encrypted data and is encrypted with recipient's public key in the XML document.- Specified by:
getSecretKeyin interfaceEncProvider- Parameters:
xmlString- String representing an XML document with encrypted secret key.privateKeys- Private keys used to decrypt the secret key.- Returns:
- the secret key.
- Throws:
SAML2Exception- if there is an error during the decryption process
-
decrypt
public Element decrypt(String xmlString, Set<PrivateKey> privateKeys) throws SAML2Exception
Description copied from interface:EncProviderDecrypts an XML document that contains encrypted data.- Specified by:
decryptin interfaceEncProvider- Parameters:
xmlString- String representing an XML document with encrypted data.privateKeys- Private keys used to decrypt the secret key.- Returns:
- org.w3c.dom.Element Decrypted XML document. For example, if the input document's root element is EncryptedID, then the return element will be NameID
- Throws:
SAML2Exception- if there is an error during the decryption process
-
-