Package org.apache.wss4j.dom.util
Class EncryptionUtils
- java.lang.Object
-
- org.apache.wss4j.dom.util.EncryptionUtils
-
public final class EncryptionUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static WSDataRef
decryptEncryptedData(Document doc, String dataRefURI, Element encData, SecretKey symmetricKey, String symEncAlgo, CallbackHandler attachmentCallbackHandler)
Decrypt the EncryptedData argument using a SecretKey.static WSDataRef
decryptEncryptedData(Document doc, String dataRefURI, Element encData, SecretKey symmetricKey, String symEncAlgo, CallbackHandler attachmentCallbackHandler, org.apache.xml.security.encryption.Serializer encryptionSerializer)
Decrypt the EncryptedData argument using a SecretKey.static Element
findEncryptedDataElement(Document doc, WSDocInfo wsDocInfo, String dataRefURI)
Look up the encrypted data.static Element
getCipherValueFromEncryptedData(Element encData)
static byte[]
getDecodedBase64EncodedData(Element element)
Method getDecodedBase64EncodedDatastatic String
getDigestAlgorithm(Node encBodyData)
static String
getMGFAlgorithm(Node encBodyData)
static byte[]
getPSource(Node encBodyData)
static String
getXOPURIFromCipherValue(Element cipherValue)
static String
getXPath(Node decryptedNode)
-
-
-
Method Detail
-
findEncryptedDataElement
public static Element findEncryptedDataElement(Document doc, 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:
doc
- The document in which to find EncryptedDatawsDocInfo
- The WSDocInfo object to usedataRefURI
- 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 EncryptedDatadataRefURI
- The URI of EncryptedDataencData
- The EncryptedData elementsymmetricKey
- The SecretKey with which to decrypt EncryptedDatasymEncAlgo
- The symmetric encryption algorithm to useattachmentCallbackHandler
- 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 EncryptedDatadataRefURI
- The URI of EncryptedDataencData
- The EncryptedData elementsymmetricKey
- The SecretKey with which to decrypt EncryptedDatasymEncAlgo
- The symmetric encryption algorithm to useattachmentCallbackHandler
- The CallbackHandler from which to get attachments- Throws:
WSSecurityException
-
getCipherValueFromEncryptedData
public static Element getCipherValueFromEncryptedData(Element encData)
-
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
-
-