|
||||||||||
| 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 Element |
appendChildElement(Document doc,
Element parent,
Element child)
Deprecated. use Node.appendChild(Node) instead |
static Text |
createBase64EncodedTextNode(Document doc,
byte[] data)
create a base64 test node |
static int |
decodeAction(String action,
Vector actions)
|
static int |
decodeAction(String action,
Vector actions,
WSSConfig wssConfig)
Decode an action String. |
static X509Certificate |
ensureSignedTogether(Iterator results,
Element[] elements)
Search through a WSS4J results vector for a single signature covering all these elements. |
static WSSecurityEngineResult |
fetchActionResult(Vector wsResultVector,
int action)
Fetch the result of a given action from a given result vector |
static Vector |
fetchAllActionResults(Vector wsResultVector,
int action,
Vector results)
Fetch the result of a given action from a given result vector |
static Element |
findBodyElement(Document doc,
SOAPConstants sc)
return the first soap "Body" element. |
static Node |
findElement(Node startNode,
String name,
String namespace)
Returns the first element that matches name and
namespace. |
static Element |
findElementById(Node startNode,
String value,
String namespace)
Returns the single element that contains an Id with value uri and namespace. |
static Element |
findSAMLAssertionElementById(Node startNode,
String value)
Returns the single SAMLAssertion element that contains an AssertionID/ID that matches the supplied parameter. |
static Element |
findWsseSecurityHeaderBlock(Document doc,
Element envelope,
boolean doCreate)
find the first ws-security header block |
static Element |
findWsseSecurityHeaderBlock(Document doc,
Element envelope,
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 Cipher |
getCipherInstance(String cipherAlgo)
|
static Node |
getDirectChild(Node fNode,
String localName,
String namespace)
Gets a direct child with specified localname and namespace. |
static Element |
getDirectChildElement(Node fNode,
String localName,
String namespace)
Gets a direct child with specified localname and namespace. |
static Element |
getElementByGenId(Document doc,
String id)
Search for an element given its generic id. |
static Element |
getElementByWsuId(Document doc,
String id)
Search for an element given its wsu:id. |
static QName |
getFullQNameFromString(String str,
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 String |
getIDfromReference(String ref)
Deprecated. use getIDFromReference instead |
static String |
getIDFromReference(String ref)
Turn a reference (eg "#5") into an ID (eg "5"). |
static int |
getKeyLength(String algorithm)
Returns the length of the key in # of bytes |
static String |
getNamespace(String prefix,
Node e)
|
static String |
getPrefixNS(String uri,
Node e)
|
static QName |
getQNameFromString(String str,
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 Element |
getSecurityHeader(Document doc,
String actor,
SOAPConstants sc)
Returns the first WS-Security header element for a given actor. |
static SOAPConstants |
getSOAPConstants(Element startElement)
|
static String |
getStringForQName(QName qname,
Element e)
Return a string for a particular QName, mapping a new prefix if necessary. |
static boolean |
isActorEqual(String actor,
String hActor)
Compares two actor strings and returns true if these are equal. |
static SecretKey |
prepareSecretKey(String symEncAlgo,
byte[] rawKey)
|
static Element |
prependChildElement(Document doc,
Element parent,
Element child,
boolean addWhitespace)
Deprecated. use prependChildElement(Element, Element)
instead |
static Element |
prependChildElement(Element parent,
Element child)
prepend a child element |
static SecureRandom |
resolveSecureRandom()
|
static SecureRandom |
resolveSecureRandom(String algorithm)
|
static String |
setNamespace(Element element,
String namespace,
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 Element getSecurityHeader(Document doc,
String actor,
SOAPConstants sc)
doc - actor -
wsse:Security element or null
if not such element found
public static boolean isActorEqual(String actor,
String hActor)
actor - hActor -
public static Node getDirectChild(Node fNode,
String localName,
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 found
public static Element getDirectChildElement(Node fNode,
String localName,
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 found
public static Element findBodyElement(Document doc,
SOAPConstants sc)
doc -
null if document does not
contain a SOAP body
public static Node findElement(Node startNode,
String name,
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 Element findSAMLAssertionElementById(Node startNode,
String value)
startNode - Where to start the searchvalue - Value of the AssertionID/ID attribute
null otherwise
public static Element findElementById(Node startNode,
String value,
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 otherwise
public static String setNamespace(Element element,
String namespace,
String prefix)
element - namespace - prefix -
public static String getPrefixNS(String uri,
Node e)
public static String getNamespace(String prefix,
Node e)
public static QName getQNameFromString(String str,
Node e)
public static QName getFullQNameFromString(String str,
Node e)
public static String getStringForQName(QName qname,
Element e)
public static Element getElementByWsuId(Document doc,
String id)
doc - the DOM document (SOAP request)id - the Id of the element
public static String getIDFromReference(String ref)
ref -
public static String getIDfromReference(String ref)
ref -
public static Element getElementByGenId(Document doc,
String id)
doc - the DOM document (SOAP request)id - the Id of the element
public static Element appendChildElement(Document doc,
Element parent,
Element child)
Node.appendChild(Node) instead
doc - the DOM document (SOAP request)parent - element of this child elementchild - the element to append
public static Element prependChildElement(Element parent,
Element child)
parent - element of this child elementchild - the element to append
public static Element prependChildElement(Document doc,
Element parent,
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 Element findWsseSecurityHeaderBlock(Document doc,
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 Element findWsseSecurityHeaderBlock(Document doc,
Element envelope,
String actor,
boolean doCreate)
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
public static Text createBase64EncodedTextNode(Document doc,
byte[] data)
doc - the DOM document (SOAP request)data - to encode
public static SecretKey prepareSecretKey(String symEncAlgo,
byte[] rawKey)
public static SOAPConstants getSOAPConstants(Element startElement)
public static Cipher getCipherInstance(String cipherAlgo)
throws WSSecurityException
WSSecurityException
public static WSSecurityEngineResult fetchActionResult(Vector wsResultVector,
int action)
wsResultVector - The result vector to fetch an action fromaction - The action to fetch
public static Vector fetchAllActionResults(Vector wsResultVector,
int action,
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(String action,
Vector actions)
throws WSSecurityException
WSSecurityException
public static int decodeAction(String action,
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(String algorithm)
throws WSSecurityException
algorithm -
WSSecurityException
public static byte[] generateNonce(int length)
throws WSSecurityException
Exception
WSSecurityException
public static X509Certificate ensureSignedTogether(Iterator results,
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
public static SecureRandom resolveSecureRandom()
throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static SecureRandom resolveSecureRandom(String algorithm)
throws NoSuchAlgorithmException
algorithm -
NoSuchAlgorithmException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||