Package org.apache.wss4j.dom.util
Class WSSecurityUtil
java.lang.Object
org.apache.wss4j.dom.util.WSSecurityUtil
WS-Security Utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ElementcloneElement(Document doc, Element clonedElement) Register the jakarta.xml.soap.Node with new Cloned Dom Node with java9static TextcreateBase64EncodedTextNode(Document doc, byte[] data) create a base64 test nodedecodeAction(String action) static List<HandlerAction>decodeHandlerAction(String action, WSSConfig wssConfig) Decode an action String.static ElementfindBodyElement(Document doc) return the first soap "Body" element.findElements(org.apache.wss4j.common.WSEncryptionPart part, CallbackLookup callbackLookup) Find the DOM Element in the SOAP Envelope that is referenced by the WSEncryptionPart argument.static ElementfindWsseSecurityHeaderBlock(Document doc, Element envelope, boolean doCreate) find the first ws-security header blockstatic ElementfindWsseSecurityHeaderBlock(Document doc, Element envelope, String actor, boolean doCreate) find a WS-Security header block for a given actorstatic StringgetAttachmentId(String xopUri) static byte[]getBytesFromAttachment(String xopUri, CallbackHandler attachmentCallbackHandler) static byte[]getBytesFromAttachment(String xopUri, CallbackHandler attachmentCallbackHandler, boolean removeAttachments) static byte[]getBytesFromAttachment(String xopUri, RequestData data) static org.apache.wss4j.common.WSEncryptionPartGet the default encryption part - the SOAP Body of type "Content".getDirectChildElements(Node fNode, String localName, String namespace) Gets all direct children with specified localname and namespace.static ElementgetSecurityHeader(Document doc, String actor) Returns the first WS-Security header element for a given actor.static ElementgetSecurityHeader(Element soapHeader, String actor, boolean soap12) Returns the first WS-Security header element for a given actor.static SOAPConstantsgetSOAPConstants(Element startElement) static ElementgetSOAPHeader(Document doc) static StringgetSOAPNamespace(Element startElement) static voidinlineAttachments(List<Element> includeElements, CallbackHandler attachmentCallbackHandler, boolean removeAttachments) static booleanisActorEqual(String actor, String hActor) Compares two actor strings and returns true if these are equal.static ElementprependChildElement(Element parent, Element child) prepend a child element
-
Method Details
-
getSOAPHeader
-
getSecurityHeader
public static Element getSecurityHeader(Document doc, String actor) throws org.apache.wss4j.common.ext.WSSecurityException Returns the first WS-Security header element for a given actor. Only one WS-Security header is allowed for an actor.- Parameters:
doc-actor-- Returns:
- the
wsse:Securityelement ornullif not such element found - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
getSecurityHeader
public static Element getSecurityHeader(Element soapHeader, String actor, boolean soap12) throws org.apache.wss4j.common.ext.WSSecurityException Returns the first WS-Security header element for a given actor. Only one WS-Security header is allowed for an actor.- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
isActorEqual
Compares two actor strings and returns true if these are equal. Takes care of the null length strings and uses ignore case.- Parameters:
actor-hActor-- Returns:
- true is the actor arguments are equal
-
getDirectChildElements
Gets all direct children with specified localname and namespace.- Parameters:
fNode- the node where to start the searchlocalName- local name of the children to getnamespace- the namespace of the children to get- Returns:
- the list of nodes or
nullif not such nodes are found
-
findBodyElement
return the first soap "Body" element.- Parameters:
doc-- Returns:
- the body element or
nullif document does not contain a SOAP body
-
findElements
public static List<Element> findElements(org.apache.wss4j.common.WSEncryptionPart part, CallbackLookup callbackLookup) throws org.apache.wss4j.common.ext.WSSecurityException Find the DOM Element in the SOAP Envelope that is referenced by the WSEncryptionPart argument. The "Id" is used before the Element localname/namespace.- Parameters:
part- The WSEncryptionPart object corresponding to the DOM Element(s) we wantcallbackLookup- The CallbackLookup object used to find Elements- Returns:
- the DOM Element in the SOAP Envelope that is found
- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
getDefaultEncryptionPart
Get the default encryption part - the SOAP Body of type "Content". -
prependChildElement
prepend a child element- Parameters:
parent- element of this child elementchild- the element to append- Returns:
- the child element
-
findWsseSecurityHeaderBlock
public static Element findWsseSecurityHeaderBlock(Document doc, Element envelope, boolean doCreate) throws org.apache.wss4j.common.ext.WSSecurityException find the first ws-security header block- Parameters:
doc- the DOM document (SOAP request)envelope- the SOAP envelopedoCreate- if true create a new WSS header block if none exists- Returns:
- the WSS header or null if none found and doCreate is false
- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
findWsseSecurityHeaderBlock
public static Element findWsseSecurityHeaderBlock(Document doc, Element envelope, String actor, boolean doCreate) throws org.apache.wss4j.common.ext.WSSecurityException find a WS-Security header block for a given actor- Parameters:
doc- the DOM document (SOAP request)envelope- the SOAP envelopeactor- the actor (role) name of the WSS headerdoCreate- if true create a new WSS header block if none exists- Returns:
- the WSS header or null if none found and doCreate is false
- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
createBase64EncodedTextNode
create a base64 test node- Parameters:
doc- the DOM document (SOAP request)data- to encode- Returns:
- a Text node containing the base64 encoded data
-
getSOAPConstants
-
getSOAPNamespace
-
decodeAction
public static List<Integer> decodeAction(String action) throws org.apache.wss4j.common.ext.WSSecurityException - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
decodeHandlerAction
public static List<HandlerAction> decodeHandlerAction(String action, WSSConfig wssConfig) throws org.apache.wss4j.common.ext.WSSecurityException Decode an action String. This method should only be called on the outbound side.- Parameters:
action- The initial String of actions to performwssConfig- This object holds the list of custom actions to be performed.- Returns:
- The list of HandlerAction Objects
- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
inlineAttachments
public static void inlineAttachments(List<Element> includeElements, CallbackHandler attachmentCallbackHandler, boolean removeAttachments) throws org.apache.wss4j.common.ext.WSSecurityException - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
cloneElement
public static Element cloneElement(Document doc, Element clonedElement) throws org.apache.wss4j.common.ext.WSSecurityException Register the jakarta.xml.soap.Node with new Cloned Dom Node with java9- Parameters:
doc- The SOAPDocumentImplclonedElement- The cloned Element- Returns:
- new clonedElement which already associated with the SAAJ Node
- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
getBytesFromAttachment
public static byte[] getBytesFromAttachment(String xopUri, RequestData data) throws org.apache.wss4j.common.ext.WSSecurityException - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
getBytesFromAttachment
public static byte[] getBytesFromAttachment(String xopUri, CallbackHandler attachmentCallbackHandler) throws org.apache.wss4j.common.ext.WSSecurityException - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
getBytesFromAttachment
public static byte[] getBytesFromAttachment(String xopUri, CallbackHandler attachmentCallbackHandler, boolean removeAttachments) throws org.apache.wss4j.common.ext.WSSecurityException - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
getAttachmentId
public static String getAttachmentId(String xopUri) throws org.apache.wss4j.common.ext.WSSecurityException - Throws:
org.apache.wss4j.common.ext.WSSecurityException
-