|
||||||||||
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)
append a child element |
static org.w3c.dom.Text |
createBase64EncodedTextNode(org.w3c.dom.Document doc,
byte[] data)
create a base64 test node |
static org.w3c.dom.Element |
createBinarySecurityToken(org.w3c.dom.Document doc,
java.lang.String wsuIdVal)
Create a BinarySecurityToken element |
static int |
decodeAction(java.lang.String action,
java.util.Vector actions)
|
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 containes an Id with value uri and namespace . |
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 |
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)
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)
prepend a child element |
static java.lang.String |
setNamespace(org.w3c.dom.Element element,
java.lang.String namespace,
java.lang.String prefix)
set the namespace 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 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
startNode
- Where to start the searchname
- Local name of the elementnamespace
- Namespace URI of the element
null
public 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 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 createBinarySecurityToken(org.w3c.dom.Document doc, java.lang.String wsuIdVal)
doc
- the DOM document (SOAP request)wsuIdVal
- the value for the wsu:Id
public static org.w3c.dom.Element appendChildElement(org.w3c.dom.Document doc, org.w3c.dom.Element parent, org.w3c.dom.Element child)
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.Document doc, org.w3c.dom.Element parent, org.w3c.dom.Element child, boolean addWhitespace)
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 envelopeactor
- the acttoer (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 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 attribute
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |