Class EncryptionUtils

java.lang.Object
org.apache.wss4j.dom.util.EncryptionUtils

public final class EncryptionUtils extends Object
  • Method Details

    • findEncryptedDataElement

      public static Element findEncryptedDataElement(WSDocInfo wsDocInfo, String dataRefURI) throws WSSecurityException
      Look up the encrypted data. First try Id="someURI". If no such Id then try wsu:Id="someURI".
      Parameters:
      wsDocInfo - The WSDocInfo object to use
      dataRefURI - The URI of EncryptedData
      Returns:
      The EncryptedData element
      Throws:
      WSSecurityException - if the EncryptedData element referenced by dataRefURI is not found
    • decryptEncryptedData

      public static WSDataRef decryptEncryptedData(Document doc, String dataRefURI, Element encData, SecretKey symmetricKey, String symEncAlgo, CallbackHandler attachmentCallbackHandler) throws WSSecurityException
      Decrypt the EncryptedData argument using a SecretKey.
      Parameters:
      doc - The (document) owner of EncryptedData
      dataRefURI - The URI of EncryptedData
      encData - The EncryptedData element
      symmetricKey - The SecretKey with which to decrypt EncryptedData
      symEncAlgo - The symmetric encryption algorithm to use
      attachmentCallbackHandler - The CallbackHandler from which to get attachments
      Throws:
      WSSecurityException
    • decryptEncryptedData

      public static WSDataRef decryptEncryptedData(Document doc, String dataRefURI, Element encData, SecretKey symmetricKey, String symEncAlgo, CallbackHandler attachmentCallbackHandler, org.apache.xml.security.encryption.Serializer encryptionSerializer) throws WSSecurityException
      Decrypt the EncryptedData argument using a SecretKey.
      Parameters:
      doc - The (document) owner of EncryptedData
      dataRefURI - The URI of EncryptedData
      encData - The EncryptedData element
      symmetricKey - The SecretKey with which to decrypt EncryptedData
      symEncAlgo - The symmetric encryption algorithm to use
      attachmentCallbackHandler - The CallbackHandler from which to get attachments
      Throws:
      WSSecurityException
    • getCipherValueFromEncryptedData

      public static Element getCipherValueFromEncryptedData(Element encData)
    • getXOPURIFromCipherValue

      public static String getXOPURIFromCipherValue(Element cipherValue)
    • getXPath

      public static String getXPath(Node decryptedNode)
      Parameters:
      decryptedNode - the decrypted node
      Returns:
      a fully built xpath (eg. "/soapenv:Envelope/soapenv:Body/ns:decryptedElement") if the decryptedNode is an Element or an Attr node and is not detached from the document. null otherwise
    • getDigestAlgorithm

      public static String getDigestAlgorithm(Node encBodyData) throws WSSecurityException
      Throws:
      WSSecurityException
    • getMGFAlgorithm

      public static String getMGFAlgorithm(Node encBodyData) throws WSSecurityException
      Throws:
      WSSecurityException
    • getPSource

      public static byte[] getPSource(Node encBodyData) throws WSSecurityException
      Throws:
      WSSecurityException
    • getDecodedBase64EncodedData

      public static byte[] getDecodedBase64EncodedData(Element element) throws WSSecurityException
      Method getDecodedBase64EncodedData
      Parameters:
      element -
      Returns:
      a byte array containing the decoded data
      Throws:
      WSSecurityException