|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ws.security.util.WSSecurityUtil
public class WSSecurityUtil
WS-Security Utility methods.
Constructor Summary | |
---|---|
WSSecurityUtil()
|
Method Summary | |
---|---|
static org.w3c.dom.Element |
appendChildElement(org.w3c.dom.Document doc,
org.w3c.dom.Element parent,
org.w3c.dom.Element child)
Deprecated. use Node.appendChild(Node) instead |
static org.w3c.dom.Text |
createBase64EncodedTextNode(org.w3c.dom.Document doc,
byte[] data)
create a base64 test node |
static int |
decodeAction(java.lang.String action,
java.util.Vector actions)
|
static int |
decodeAction(java.lang.String action,
java.util.Vector actions,
WSSConfig wssConfig)
Decode an action String. |
static java.security.cert.X509Certificate |
ensureSignedTogether(java.util.Iterator results,
org.w3c.dom.Element[] elements)
Search through a WSS4J results vector for a single signature covering all these elements. |
static WSSecurityEngineResult |
fetchActionResult(java.util.Vector wsResultVector,
int action)
Fetch the result of a given action from a given result vector |
static java.util.Vector |
fetchAllActionResults(java.util.Vector wsResultVector,
int action,
java.util.Vector results)
Fetch the result of a given action from a given result vector |
static org.w3c.dom.Element |
findBodyElement(org.w3c.dom.Document doc,
SOAPConstants sc)
return the first soap "Body" element. |
static org.w3c.dom.Node |
findElement(org.w3c.dom.Node startNode,
java.lang.String name,
java.lang.String namespace)
Returns the first element that matches name and
namespace . |
static org.w3c.dom.Element |
findElementById(org.w3c.dom.Node startNode,
java.lang.String value,
java.lang.String namespace)
Returns the single element that contains an Id with value uri and namespace . |
static org.w3c.dom.Element |
findSAMLAssertionElementById(org.w3c.dom.Node startNode,
java.lang.String value)
Returns the single SAMLAssertion element that contains an AssertionID/ID that matches the supplied parameter. |
static org.w3c.dom.Element |
findWsseSecurityHeaderBlock(org.w3c.dom.Document doc,
org.w3c.dom.Element envelope,
boolean doCreate)
find the first ws-security header block |
static org.w3c.dom.Element |
findWsseSecurityHeaderBlock(org.w3c.dom.Document doc,
org.w3c.dom.Element envelope,
java.lang.String actor,
boolean doCreate)
find a ws-security header block for a given actor |
static byte[] |
generateNonce(int length)
Generate a nonce of the given length |
static javax.crypto.Cipher |
getCipherInstance(java.lang.String cipherAlgo)
|
static org.w3c.dom.Node |
getDirectChild(org.w3c.dom.Node fNode,
java.lang.String localName,
java.lang.String namespace)
Gets a direct child with specified localname and namespace. |
static org.w3c.dom.Element |
getDirectChildElement(org.w3c.dom.Node fNode,
java.lang.String localName,
java.lang.String namespace)
Gets a direct child with specified localname and namespace. |
static org.w3c.dom.Element |
getElementByGenId(org.w3c.dom.Document doc,
java.lang.String id)
Search for an element given its generic id. |
static org.w3c.dom.Element |
getElementByWsuId(org.w3c.dom.Document doc,
java.lang.String id)
Search for an element given its wsu:id. |
static javax.xml.namespace.QName |
getFullQNameFromString(java.lang.String str,
org.w3c.dom.Node e)
Return a QName when passed a string like "foo:bar" by mapping the "foo" prefix to a namespace in the context of the given Node. |
static java.lang.String |
getIDfromReference(java.lang.String ref)
Deprecated. use getIDFromReference instead |
static java.lang.String |
getIDFromReference(java.lang.String ref)
Turn a reference (eg "#5") into an ID (eg "5"). |
static int |
getKeyLength(java.lang.String algorithm)
Returns the length of the key in # of bytes |
static java.lang.String |
getNamespace(java.lang.String prefix,
org.w3c.dom.Node e)
|
static java.lang.String |
getPrefixNS(java.lang.String uri,
org.w3c.dom.Node e)
|
static javax.xml.namespace.QName |
getQNameFromString(java.lang.String str,
org.w3c.dom.Node e)
Return a QName when passed a string like "foo:bar" by mapping the "foo" prefix to a namespace in the context of the given Node. |
static org.w3c.dom.Element |
getSecurityHeader(org.w3c.dom.Document doc,
java.lang.String actor,
SOAPConstants sc)
Returns the first WS-Security header element for a given actor. |
static SOAPConstants |
getSOAPConstants(org.w3c.dom.Element startElement)
|
static java.lang.String |
getStringForQName(javax.xml.namespace.QName qname,
org.w3c.dom.Element e)
Return a string for a particular QName, mapping a new prefix if necessary. |
static boolean |
isActorEqual(java.lang.String actor,
java.lang.String hActor)
Compares two actor strings and returns true if these are equal. |
static javax.crypto.SecretKey |
prepareSecretKey(java.lang.String symEncAlgo,
byte[] rawKey)
|
static org.w3c.dom.Element |
prependChildElement(org.w3c.dom.Document doc,
org.w3c.dom.Element parent,
org.w3c.dom.Element child,
boolean addWhitespace)
Deprecated. use prependChildElement(Element, Element)
instead |
static org.w3c.dom.Element |
prependChildElement(org.w3c.dom.Element parent,
org.w3c.dom.Element child)
prepend a child element |
static java.security.SecureRandom |
resolveSecureRandom()
|
static java.security.SecureRandom |
resolveSecureRandom(java.lang.String algorithm)
|
static java.lang.String |
setNamespace(org.w3c.dom.Element element,
java.lang.String namespace,
java.lang.String prefix)
Set a namespace/prefix on an element if it is not set already. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WSSecurityUtil()
Method Detail |
---|
public static org.w3c.dom.Element getSecurityHeader(org.w3c.dom.Document doc, java.lang.String actor, SOAPConstants sc)
doc
- actor
-
wsse:Security
element or null
if not such element foundpublic static boolean isActorEqual(java.lang.String actor, java.lang.String hActor)
actor
- hActor
-
public static org.w3c.dom.Node getDirectChild(org.w3c.dom.Node fNode, java.lang.String localName, java.lang.String namespace)
fNode
- the node where to start the searchlocalName
- local name of the child to getnamespace
- the namespace of the child to get
null
if not such node foundpublic static org.w3c.dom.Element getDirectChildElement(org.w3c.dom.Node fNode, java.lang.String localName, java.lang.String namespace)
fNode
- the node where to start the searchlocalName
- local name of the child to getnamespace
- the namespace of the child to get
null
if not such node foundpublic static org.w3c.dom.Element findBodyElement(org.w3c.dom.Document doc, SOAPConstants sc)
doc
-
null
if document does not
contain a SOAP bodypublic static org.w3c.dom.Node findElement(org.w3c.dom.Node startNode, java.lang.String name, java.lang.String namespace)
name
and
namespace
. This is a replacement for a XPath lookup
//name
with the given namespace. It's somewhat faster than
XPath, and we do not deal with prefixes, just with the real namespace URI
start
- Node Where to start the searchname
- Local name of the elementnamespace
- Namespace URI of the element
null
public static org.w3c.dom.Element findSAMLAssertionElementById(org.w3c.dom.Node startNode, java.lang.String value)
startNode
- Where to start the searchvalue
- Value of the AssertionID/ID attribute
null
otherwisepublic static org.w3c.dom.Element findElementById(org.w3c.dom.Node startNode, java.lang.String value, java.lang.String namespace)
uri
and namespace
. This is a
replacement for a XPath Id lookup with the given namespace. It's somewhat
faster than XPath, and we do not deal with prefixes, just with the real
namespace URI
If there are multiple elements, we log a warning and return null as this
can be used to get around the signature checking.
startNode
- Where to start the searchvalue
- Value of the Id attributenamespace
- Namespace URI of the Id
null
otherwisepublic static java.lang.String setNamespace(org.w3c.dom.Element element, java.lang.String namespace, java.lang.String prefix)
element
- namespace
- prefix
-
public static java.lang.String getPrefixNS(java.lang.String uri, org.w3c.dom.Node e)
public static java.lang.String getNamespace(java.lang.String prefix, org.w3c.dom.Node e)
public static javax.xml.namespace.QName getQNameFromString(java.lang.String str, org.w3c.dom.Node e)
public static javax.xml.namespace.QName getFullQNameFromString(java.lang.String str, org.w3c.dom.Node e)
public static java.lang.String getStringForQName(javax.xml.namespace.QName qname, org.w3c.dom.Element e)
public static org.w3c.dom.Element getElementByWsuId(org.w3c.dom.Document doc, java.lang.String id)
doc
- the DOM document (SOAP request)id
- the Id of the element
public static java.lang.String getIDFromReference(java.lang.String ref)
ref
-
public static java.lang.String getIDfromReference(java.lang.String ref)
ref
-
public static org.w3c.dom.Element getElementByGenId(org.w3c.dom.Document doc, java.lang.String id)
doc
- the DOM document (SOAP request)id
- the Id of the element
public static org.w3c.dom.Element appendChildElement(org.w3c.dom.Document doc, org.w3c.dom.Element parent, org.w3c.dom.Element child)
Node.appendChild(Node)
instead
doc
- the DOM document (SOAP request)parent
- element of this child elementchild
- the element to append
public static org.w3c.dom.Element prependChildElement(org.w3c.dom.Element parent, org.w3c.dom.Element child)
parent
- element of this child elementchild
- the element to append
public static org.w3c.dom.Element prependChildElement(org.w3c.dom.Document doc, org.w3c.dom.Element parent, org.w3c.dom.Element child, boolean addWhitespace)
prependChildElement(Element, Element)
instead
doc
- the DOM document (SOAP request)parent
- element of this child elementchild
- the element to appendaddWhitespace
- if true prepend a newline before child
public static org.w3c.dom.Element findWsseSecurityHeaderBlock(org.w3c.dom.Document doc, org.w3c.dom.Element envelope, boolean doCreate)
doc
- the DOM document (SOAP request)envelope
- the SOAP envelopedoCreate
- if true create a new WSS header block if none exists
public static org.w3c.dom.Element findWsseSecurityHeaderBlock(org.w3c.dom.Document doc, org.w3c.dom.Element envelope, java.lang.String actor, boolean doCreate)
doc
- the DOM document (SOAP request)envelope
- the SOAP envelopeactot
- the actor (role) name of the WSS headerdoCreate
- if true create a new WSS header block if none exists
public static org.w3c.dom.Text createBase64EncodedTextNode(org.w3c.dom.Document doc, byte[] data)
doc
- the DOM document (SOAP request)data
- to encode
public static javax.crypto.SecretKey prepareSecretKey(java.lang.String symEncAlgo, byte[] rawKey)
public static SOAPConstants getSOAPConstants(org.w3c.dom.Element startElement)
public static javax.crypto.Cipher getCipherInstance(java.lang.String cipherAlgo) throws WSSecurityException
WSSecurityException
public static WSSecurityEngineResult fetchActionResult(java.util.Vector wsResultVector, int action)
wsResultVector
- The result vector to fetch an action fromaction
- The action to fetch
public static java.util.Vector fetchAllActionResults(java.util.Vector wsResultVector, int action, java.util.Vector results)
wsResultVector
- The result vector to fetch an action fromaction
- The action to fetchresults
- where to store the found results data for the action
public static int decodeAction(java.lang.String action, java.util.Vector actions) throws WSSecurityException
WSSecurityException
public static int decodeAction(java.lang.String action, java.util.Vector actions, WSSConfig wssConfig) throws WSSecurityException
action
- The initial String of actions to performactions
- The vector of created actions that will be performedwssConfig
- This object holds the list of custom actions to be performed.
WSSecurityException
public static int getKeyLength(java.lang.String algorithm) throws WSSecurityException
algorithm
-
WSSecurityException
public static byte[] generateNonce(int length) throws WSSecurityException
java.lang.Exception
WSSecurityException
public static java.security.cert.X509Certificate ensureSignedTogether(java.util.Iterator results, org.w3c.dom.Element[] elements) throws WSSecurityException
results
- results (e.g., as stored as WSHandlerConstants.RECV_RESULTS on
an Axis MessageContext)elements
- the elements to check
WSSecurityException
- if no suitable signature could be found or if any element
didn't have a wsu:Id attributepublic static java.security.SecureRandom resolveSecureRandom() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static java.security.SecureRandom resolveSecureRandom(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
algorithm
-
java.security.NoSuchAlgorithmException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |