Class XMLEncryptionManager


  • public class XMLEncryptionManager
    extends Object
    • Constructor Detail

      • XMLEncryptionManager

        protected XMLEncryptionManager()
        Constructor
    • Method Detail

      • getInstance

        public static XMLEncryptionManager getInstance()
        Gets the instance of XMLEncryptionManager with default KeyProvider and EncryptionProvider.
        Returns:
        XMLEncryptionManager
      • encryptAndReplace

        public Document encryptAndReplace​(Document doc,
                                          Element element,
                                          String secretKeyAlg,
                                          int keySize,
                                          String certAlias)
                                   throws EncryptionException
        Encrypts the given XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption key size
        certAlias - KeyEncryption Key cert alias.
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • encryptAndReplace

        public Document encryptAndReplace​(Document doc,
                                          Element element,
                                          String secretKeyAlg,
                                          int keySize,
                                          String certAlias,
                                          String providerID)
                                   throws EncryptionException
        Encrypts the given XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption key size
        certAlias - KeyEncryption Key cert alias.
        providerID - Unique provider ID.
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • encryptAndReplaceResourceID

        public Document encryptAndReplaceResourceID​(Document doc,
                                                    Element element,
                                                    String secretKeyAlg,
                                                    int keySize,
                                                    String certAlias,
                                                    String providerID)
                                             throws EncryptionException
        Encrypts the given ResourceID XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption key size
        certAlias - KeyEncryption Key cert alias.
        providerID - Unique provider ID.
        Returns:
        org.w3c.dom.Document XML Document for EncryptedResourceID.
        Throws:
        EncryptionException
      • encryptAndReplace

        public Document encryptAndReplace​(Document doc,
                                          Element element,
                                          String secretKeyAlg,
                                          int keySize,
                                          String certAlias,
                                          int kekStrength)
                                   throws EncryptionException
        Encrypts the given XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption key size
        certAlias - KeyEncryption Key cert alias.
        kekStrength - Key Encryption Key Strength.
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • encryptAndReplace

        public Document encryptAndReplace​(Document doc,
                                          Element element,
                                          String secretKeyAlg,
                                          int keySize,
                                          Key kek,
                                          int kekStrength)
                                   throws EncryptionException
        Encrypts the given XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption Key Strength.
        kek - Key Encryption Key.
        kekStrength - Key Encryption Key Strength
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • encryptAndReplace

        public Document encryptAndReplace​(Document doc,
                                          Element element,
                                          String secretKeyAlg,
                                          int keySize,
                                          Key kek,
                                          int kekStrength,
                                          String providerID)
                                   throws EncryptionException
        Encrypts the given XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption Key Strength.
        kek - Key Encryption Key.
        kekStrength - Key Encryption Key Strength
        providerID - provider entityID
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • encryptAndReplaceResourceID

        public Document encryptAndReplaceResourceID​(Document doc,
                                                    Element element,
                                                    String secretKeyAlg,
                                                    int keySize,
                                                    Key kek,
                                                    int kekStrength,
                                                    String providerID)
                                             throws EncryptionException
        Encrypts the given XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        element - Element to be encrypted.
        secretKeyAlg - Encryption Key Algorithm.
        keySize - Encryption Key Strength.
        kek - Key Encryption Key.
        kekStrength - Key Encryption Key Strength
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • encryptAndReplaceWSSElements

        public Document encryptAndReplaceWSSElements​(Document doc,
                                                     Map elmMap,
                                                     String encDataEncAlg,
                                                     int encDataEncAlgStrength,
                                                     String certAlias,
                                                     int kekStrength,
                                                     String tokenType,
                                                     String providerID)
                                              throws EncryptionException
        Encrypts the given WSS XML element in a given XML Context document.
        Parameters:
        doc - the context XML Document.
        elmMap - Map of (Element, wsu_id) to be encrypted.
        encDataEncAlg - Encryption Key Algorithm.
        encDataEncAlgStrength - Encryption Key Strength.
        certAlias - Key Encryption Key cert alias.
        kekStrength - Key Encryption Key Strength.
        tokenType - Security token type.
        providerID - Provider ID.
        Returns:
        org.w3c.dom.Document XML Document replaced with encrypted data for a given XML element.
        Throws:
        EncryptionException
      • decryptAndReplace

        public Document decryptAndReplace​(Document encryptedDoc,
                                          String kekAlias)
                                   throws EncryptionException
        Decrypts and replaces the XML element in a given XML DOM Document.
        Parameters:
        encryptedDoc - Encrypted XML Document.
        kekAlias - Key Encryption Key Cert Alias.
        Returns:
        org.w3.dom.Document Decrypted XML Document.
        Throws:
        XMLEncryptionException
        EncryptionException
      • decryptAndReplace

        public Document decryptAndReplace​(Document encryptedDoc,
                                          Key privKey)
                                   throws EncryptionException
        Decrypts an XML Document that contains encrypted data.
        Parameters:
        encryptedDoc - XML Document with encrypted data.
        privKey - Key Encryption Key used for encryption.
        Returns:
        org.w3c.dom.Document Decrypted XML Document.
        Throws:
        EncryptionException
      • decryptKey

        public Key decryptKey​(Element encryptedKey,
                              String certAlias)
        Decrypts key and returns the associated secret key.
        Parameters:
        encryptedKey - the encrypted key.
        certAlias - the private key alias that is used to decrypt the key.
        Returns:
        the decrypted secret key.