Class FMEncProvider

  • All Implemented Interfaces:
    EncProvider

    public final class FMEncProvider
    extends Object
    implements EncProvider
    FMEncProvier is a class for encrypting and decrypting XML documents, it implements EncProvider.
    • Constructor Detail

      • FMEncProvider

        public FMEncProvider()
    • 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:
        encrypt in interface EncProvider
        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:
        encrypt in interface EncProvider
        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: EncProvider
        Returns the secret key that encrypts encrypted data and is encrypted with recipient's public key in the XML document.
        Specified by:
        getSecretKey in interface EncProvider
        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: EncProvider
        Decrypts an XML document that contains encrypted data.
        Specified by:
        decrypt in interface EncProvider
        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