Skip navigation links

Oracle Fusion Middleware Web Services Security Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1.9)

E56326-01


oracle.security.xmlsec.wss
Class WSSecurity

java.lang.Object
  extended by oracle.security.xmlsec.util.XMLNode
      extended by oracle.security.xmlsec.util.XMLElement
          extended by oracle.security.xmlsec.wss.WSSecurity


public class WSSecurity
extends oracle.security.xmlsec.util.XMLElement

This class represents a wsse:Security header block in a SOAPEnvelope. It provides methods for signing and encrypting messages and security tokens.

Creating WSSecurity objects

Specifying keys and STRs

Whenever you encrypt or sign, you must provide the key that is to be used by OSDT to perform the encryption or signing. However you also need to provide a hint (which is typically a SecurityTokenReference) to the reciever, so that they do the corresponding decryption or verification.

There are a whole series of methods createSTR_foo to create these STRs. You need to use one of these methods to create an STR, and pass it as the KeyInfoData argument to the encrypt or sign methods. These methods will not try to dereference the STR, they will simply insert the STR into the document. But the verify and decrypt methods will try to dereference the STRs unless the key is provided.

Encryption

For encryption there are two main methods. All other encrypt methods are wrappers over these methods

Note: These methods take a list of objects to be encrypted, where each object can be either an XML Element , or any OSDT object that derives from OSDT XMLElement , or a SOAPHeader, or an AttachmentPart

Decryption

The simplest way to decrypt is to call decryptAll(SOAPMessage) which will go through all the top level ReferenceList and EncryptedKey elements and decrypt them. It will call the registered callbacks for obtaining the key to be used for decryption. The SOAPMessage parameter is only used for decrypting attachments, you can be null if you are not execting any attachments.

If you want to have more control over the decryption, you can call one of these methods

Signing

Use WSSignatureParams.WSSignatureParams(byte[], PrivateKey) to create a signature params object with the specified signing key, and then call some set methods to set the signing parameters and finally call
sign(String[], WSSecurityTokenReference[], WSSignatureParams) to sign a list of URIs which can be URIs to local elements, external uris, or cid references to attachments. You must set the WSSignatureParams.setSOAPMessage(SOAPMessage) if you have any cid references. Most of the other sign methods are deprecated.

Verification

The simplest way to decrypt is to call verifyAll(SOAPMessage) which will go through all the top level Signature elements and verify them. It will call the registered callbacks for obtaining the key to be used for verification.

If you want to have more control over the verification, you shoulcd at first search for all the signature elements inside the WSSecurity header, and verify them individually


Field Summary

 

Fields inherited from class oracle.security.xmlsec.util.XMLNode
node, systemId

 

Constructor Summary
WSSecurity(org.w3c.dom.Element element)
          Creates a new WSSecurity instance from the given Element node.
WSSecurity(org.w3c.dom.Element element, java.lang.String systemId)
          Creates a new WSSecurity instance from the given Element node.

 

Method Summary
 void addKerberosToken(KerberosBinarySecurityToken token)
          Add a Kerberos Token.
 void addSAML2AssertionToken(SAML2AssertionToken token)
          Add a SAML2 Assertion Token.
 void addSAMLAssertionToken(SAMLAssertionToken token)
          Add a SAML Assertion Token.
 void addSecurityToken(org.w3c.dom.Element token)
          Add a Security Token.
 void addSecurityTokenReference(WSSecurityTokenReference ref)
          Add a Security Token Reference.
 WSSignatureConfirmation addSignatureConfirmation(java.lang.String signatureValue)
          Create a SignatureConfirmation element and prepend it this WSSecurity element
 void addSignatureConfirmation(WSSignatureConfirmation sigConfirm)
          Prepend a SignatureConfirmation element to this WSSecurity element Does a simple insert into the DOM To insert at some other user regular DOM insert/append calls
 void addUsernameToken(UsernameToken token)
          Add a Username Token.
static void addWsuIdToElement(java.lang.String id, org.w3c.dom.Element element)
          Deprecated. replaced by WSSUtils.addWsuIdToElement(String, Element)
 void addX509CertificateToken(X509BinarySecurityToken token)
          Add a X.509 Certificate Token.
static byte[] computeEncKeySHA1(oracle.security.xmlsec.enc.XEEncryptedKey encKey)
          Utility method to compute the SHA1 of an EncryptedKey
 KerberosBinarySecurityToken createBST_Kerberos(byte[] ap_req, java.lang.String valueType)
          Create a BST from an Kerberos AP_REQ packet or a GSS wrapped AP_REQ packet
 X509BinarySecurityToken createBST_X509(java.security.cert.CertPath certpath)
          Create an BST from an X509Certificate CertPath
 X509BinarySecurityToken createBST_X509(java.security.cert.X509Certificate cert)
          Create an BST from an X509Certificate cert.
 oracle.security.xmlsec.enc.XEEncryptedData createEncryptedData(java.lang.String dataType)
          Creates a new XEEncryptedData element in this WSSecurity's document, but does not append it to the WSSecurity element.
 oracle.security.xmlsec.enc.XEEncryptedKey createEncryptedKey()
          Creates a new XEEncryptedKey element in this WSSecurity's document, but does not append it to the WSSecurity element.
 oracle.security.xmlsec.dsig.XSSignature createSignature()
          Creates a new XSSignature element in this WSSecurity's document, but does not append it to the WSSecurity element.
 oracle.security.xmlsec.dsig.XSSignature createSignature(java.lang.String id)
          Creates a new Signature element in this document, but does not append it to the WSSecurity element.
 java.util.List createSignatureConfirmations(org.w3c.dom.Document doc)
          Create a List of SignatureConfirmation elements correspnding to the Signature elements in this WSSecurity element.
 WSSecurityTokenReference createSTR_EncKeyRef(java.lang.String uri)
          Create an STR to an EncryptedKey that is in the document.
 WSSecurityTokenReference createSTR_EncKeySHA1(byte[] sha1)
          Create an STR to an EncryptedKey that is NOT in the document.
 WSSecurityTokenReference createSTR_KerberosKeyIdSHA1(byte[] ap_req, java.lang.String valueType)
          Create an STR to a Kerberos ap-req may not be in the document.
 WSSecurityTokenReference createSTR_KerberosKeyRef(java.lang.String uri, java.lang.String valueType)
          Create an STR to a Keberos BST that is in the document.
 WSSecurityTokenReference createSTR_SAML_Assertion_Ref20(java.lang.String uri)
          Create an STR to local or remote SAML v2.0 Assertion.
 WSSecurityTokenReference createSTR_SAML_AssertionIdv11(byte[] assertionId)
          Create an STR to local SAML v1.1 AssertionID.
 WSSecurityTokenReference createSTR_SAML_AssertionIdv11(byte[] assertionId, oracle.security.xmlsec.saml.AuthorityBinding authorityBinding)
          Create an STR to an external SAML v1.1 AssertionID.
 WSSecurityTokenReference createSTR_SAML_AssertionIdv20(byte[] assertionId)
          Create an STR to local SAML v2.0 AssertionID.
 WSSecurityTokenReference createSTR_Username_Ref(java.lang.String uri)
          Create an STR to an UsernameToken.
 WSSecurityTokenReference createSTR_X509_IssuerSerial(java.security.cert.X509Certificate cert)
          Create an STR to an X509Certificate cert.
 WSSecurityTokenReference createSTR_X509_Ref(java.lang.String uri)
          Create an STR to an X509Certificate cert.
 WSSecurityTokenReference createSTR_X509_SKI(java.security.cert.X509Certificate cert)
          Create an STR to an X509Certificate cert.
 WSSecurityTokenReference createSTR_X509_ThumbprintSHA1(java.security.cert.X509Certificate cert)
          Create an STR to an X509Certificate cert.
static java.lang.Object decrypt(oracle.security.xmlsec.enc.XEEncryptedData encData)
          Decrypts the EncrypedData element.
static java.lang.Object decrypt(oracle.security.xmlsec.enc.XEEncryptedData encData, javax.crypto.SecretKey dataDecKey)
          Decrypts the EncrypedData element with the given key
static java.lang.Object decrypt(oracle.security.xmlsec.enc.XEEncryptedData encData, javax.crypto.SecretKey dataDecKey, javax.xml.soap.SOAPMessage msg)
          Decrypts the EncrypedData element with the given key
static java.util.List decrypt(oracle.security.xmlsec.enc.XEEncryptedKey encKey)
          Decrypts all the EncrypedData elements referenced by the given EncryptedKey element
static java.util.List decrypt(oracle.security.xmlsec.enc.XEEncryptedKey encKey, java.security.PrivateKey keyDecKey)
          Decrypts all the EncrypedData elements referenced by the given EncryptedKey element
static java.util.List decrypt(oracle.security.xmlsec.enc.XEEncryptedKey encKey, java.security.PrivateKey keyDecKey, javax.xml.soap.SOAPMessage msg)
          Decrypts all the EncrypedData elements referenced by the given EncryptedKey element
static java.util.List decrypt(oracle.security.xmlsec.enc.XEEncryptedKey encKey, javax.crypto.SecretKey dataDecKey)
          Decrypts all the EncrypedData elements referenced by the given EncryptedKey element
static java.util.List decrypt(oracle.security.xmlsec.enc.XEEncryptedKey encKey, javax.crypto.SecretKey dataDecKey, javax.xml.soap.SOAPMessage msg)
          Decrypts all the EncrypedData elements referenced by the given EncryptedKey element
static java.util.List decrypt(oracle.security.xmlsec.enc.XEEncryptedKey encKey, javax.xml.soap.SOAPMessage msg)
          Decrypts all the EncrypedData elements referenced by the given EncryptedKey element
static java.util.List decrypt(oracle.security.xmlsec.enc.XEReferenceList refList)
          Decrypts the EncrypedData/EncryptedHeader elements referenced by the given ReferenceList element in this structure.
static java.util.List decrypt(oracle.security.xmlsec.enc.XEReferenceList refList, javax.crypto.SecretKey symKey)
          Decrypts the EncrypedData/EncryptedHeader elements referenced by the given ReferenceList element in this structure.
static java.util.List decrypt(oracle.security.xmlsec.enc.XEReferenceList refList, javax.crypto.SecretKey symKey, javax.xml.soap.SOAPMessage msg)
           
 void decryptAll()
          Decrypts all the EncryptedData child elements and replaces the EncrypteData element with the decrypted XML result.
 void decryptAll(javax.xml.soap.SOAPMessage msg)
           
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.security.PublicKey keyEncKey, java.lang.String keyEncAlg, java.lang.String keyEncKeyName, byte[] certId)
          Perform encryption of the Security Header content.
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.security.cert.X509Certificate keyEncCert, java.lang.String keyEncAlg)
          Perform encryption of the Security Header content.
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, java.lang.String dataEncAlg, java.lang.String usernameTokenURI, KeyDerivator keyDerivator)
          Deprecated.  
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, java.lang.String dataEncAlg, java.lang.String keyEncKeyURI, java.lang.String keyEncAlg)
          Perform encryption of the Security Header content.
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, java.lang.String dataEncAlg, java.lang.String certTokenURI, java.lang.String keyEncAlg, javax.crypto.SecretKey dataEncKey)
          Perform encryption of the Security Header content.
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, java.lang.String encDataId, WSSEncryptionParams encParam)
          Encrypt an element with a content key.
 void encrypt(org.w3c.dom.Element element, boolean contentOnly, WSSEncryptionParams encParams)
          Deprecated. Replaced by encrypt(Element, boolean, String, SecretKey, PublicKey, String, String, byte[])
 void encrypt(java.util.List elements, boolean[] contentOnlys, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.security.PublicKey keyEncKey, java.lang.String keyEncAlg, java.lang.String keyEncKeyName, byte[] certId)
          Perform encryption of a list of elements, all with the same content key.
 void encrypt(java.util.List elements, boolean[] contentOnlys, java.lang.String dataEncAlg, javax.crypto.SecretKey dataEncKey, java.security.cert.X509Certificate keyEncCert, java.lang.String keyEncAlg)
          Perform encryption of a list of elements, all with the same content key.
 void encrypt(java.util.List elements, boolean[] contentOnlys, java.lang.String dataEncAlgURI, java.lang.String usernameTokenURI, KeyDerivator keyDerivator)
          Deprecated.  
 void encrypt(java.util.List elements, boolean[] contentOnlys, java.lang.String dataEncAlg, java.lang.String keyEncKeyURI, java.lang.String keyEncAlg)
          Perform encryption of the Security Header content.
 void encrypt(java.util.List elements, boolean[] contentOnlys, java.lang.String dataEncAlg, java.lang.String certTokenURI, java.lang.String keyEncAlg, javax.crypto.SecretKey dataEncKey)
          Perform encryption of the Security Header content.
 void encrypt(java.util.List elements, boolean[] contentOnlys, WSSEncryptionParams encParams)
          Deprecated. Replaced by encrypt(List, boolean[], String, SecretKey, PublicKey, String, String, byte[])
 oracle.security.xmlsec.enc.XEReferenceList encryptNoEncKey(java.util.List elements, boolean[] contentOnlys, java.lang.String[] encDataIds, WSSEncryptionParams[] encParams)
          Encrypt a list of elements (or attachments), each with a different content key.
 oracle.security.xmlsec.enc.XEEncryptedKey encryptWithEncKey(java.util.List elements, boolean[] contentOnlys, java.lang.String[] encDataIds, WSSEncryptionParams encParam)
          Encrypt of a list of elements, all with the same content key and encrypt that content key with a public key.
static WSSecurity[] getAllSecurityHeaders(javax.xml.soap.SOAPEnvelope env)
          Get all the wsse:Security headers in this envelope.
 java.util.List getBinaryTokens()
          Returns the list of Binary Security Tokens.
 java.util.List getEncryptedAssertions()
          Returns the list of EncryptedAssertion (SAML2) Elements.
 java.util.List getEncryptedData()
          Returns all the EncryptedData elements in this WSSecurity block.
 java.util.List getEncryptedKeys()
          Returns all the EncryptedKey elements in this WSSecurity block.
static WSSecurity[] getMustUnderstandSecurityHeaders(javax.xml.soap.SOAPEnvelope env, java.lang.String actor)
          Get all the wsse:Security headers in this envelope.
 java.util.List getReferenceLists()
          Returns all the ReferenceList elements in this WSSecurity block.
 java.util.List getSAML2AssertionTokens()
          Returns the list of SAML2 Assertion Security Tokens.
 java.util.List getSAMLAssertionTokens()
          Returns the list of SAML Assertion Security Tokens.
static WSSecurity[] getSecurityHeaders(javax.xml.soap.SOAPEnvelope env, java.lang.String actor)
          Get all the wsse:Security headers in this envelope.
 WSSecurityToken getSecurityTokenByWsuID(java.lang.String id)
          Get the Security token corresponding to the WSU identifier.
 java.util.List getSignatures()
          Returns all the Signature elements in this WSSecurity header block.
 java.lang.String[] getSignatureValues()
          Return a list of Signature values of all the top level Signature elements in this WSSecurity element.
 WSUTimestamp getTimestamp()
          Get the token Timestamp.
 java.util.List getUsernameTokens()
          Returns the list of Username Security Tokens.
static WSSecurity newInstance(org.w3c.dom.Document owner)
          Creates a new WSSecurity instance using the given owner document, but does not append it to any element.
static WSSecurity newInstance(org.w3c.dom.Document owner, java.lang.String id)
          Creates a new WSSecurity instance using the given owner document, but does not append it to any element.
static WSSecurity newInstance(javax.xml.soap.SOAPEnvelope env)
          Create a new WSSecurity instance using the given SOAPEnvelope.
static WSSecurity newInstance(java.lang.String id)
          Creates a new WSSecurity instance in a new owner document, and makes it the root element of the document.
 void setTimestamp(WSUTimestamp timeStamp)
          Set the token Timestamp.
 void sign(java.lang.String[] uris, UsernameToken token, KeyDerivator keyDerivator, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, boolean usingDecryptionTransform)
          Deprecated. KeyDerivator was used before WSS 1.1, Instead use UsernameToken.deriveKey(char[], byte[], int) to derive the password, and call the regular sign method
 void sign(java.lang.String[] uris, UsernameToken token, KeyDerivator keyDerivator, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[] trans, boolean usingDecryptionTransform)
          Deprecated.  
 void sign(java.lang.String[] uris, WSSecurityTokenReference[] refs, WSSignatureParams sigParams)
          Deprecated. Combine the uris and the refs into one list of uris and call sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][])
 oracle.security.xmlsec.dsig.XSSignature sign(java.lang.String[] uris, WSSignatureParams sigParams, oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[][] trans)
          Signs a list of URIs using an HMAC key or a PrivateKey.
 void sign(java.lang.String[] uris, WSSKeyIdentifier keyId, java.security.PrivateKey privKey, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, boolean usingDecryptionTransform)
          Deprecated. Use sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][]) instead
 void sign(java.lang.String[] uris, WSSKeyIdentifier keyId, java.security.PrivateKey privKey, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[] trans, boolean usingDecryptionTransform)
          Deprecated. Use the createSTR_XXX methods to create a KeyIdentifier and then pass it to sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][])
 void sign(java.lang.String[] uris, X509BinarySecurityToken token, java.security.PrivateKey privKey, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, boolean usingDecryptionTransform)
          Deprecated. Use createSTR_X509_IssuerSerial(X509Certificate) to create an STR, and then send that to sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][])
 void sign(java.lang.String[] uris, X509BinarySecurityToken token, java.security.PrivateKey privKey, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[] trans, boolean usingDecryptionTransform)
          Deprecated. Use createSTR_X509_IssuerSerial(X509Certificate) to create an STR, and then send that to sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][])
 void sign(java.lang.String[] uris, X509IssuerSerial certIASN, java.security.PrivateKey privKey, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, boolean usingDecryptionTransform)
          Deprecated. Use createSTR_X509_IssuerSerial(X509Certificate) to create an STR, and then send that to sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][])
 void sign(java.lang.String[] uris, X509IssuerSerial certIASN, java.security.PrivateKey privKey, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[] trans, boolean usingDecryptionTransform)
          Deprecated. Use createSTR_X509_IssuerSerial(X509Certificate) to create an STR, and then send that to sign(String[], WSSignatureParams, XSAlgorithmIdentifier[][])
 void sign(java.lang.String uri, UsernameToken token, KeyDerivator keyDerivator, java.lang.String digestAlg, java.lang.String c14NAlg, java.lang.String signatureAlg, boolean usingDecryptionTransform)
          Deprecated. KeyDerivator was used before WSS 1.1, Instead use UsernameToken.deriveKey(char[], byte[], int) to derive the password, and call the regular sign method
 void sign(java.lang.String uri, WSSignatureParams sigParams)
          Sign a single URI.
 void sign(WSSecurityTokenReference ref, WSSignatureParams sigParams)
          Deprecated. Use sign(String, WSSignatureParams) which can sign both regular URIs and URIs to STRs.
 boolean verify(oracle.security.xmlsec.dsig.XSSignature sig)
          Verifies the given XSSignature, following the ds:Signature and ds:Reference validation process defined in [XML-SIG].
static boolean verify(oracle.security.xmlsec.dsig.XSSignature sig, boolean searchDocument)
          Verifies the given XSSignature, following the ds:Signature and ds:Reference validation process defined in [XML-SIG].
static boolean verify(oracle.security.xmlsec.dsig.XSSignature sig, boolean searchDocument, javax.xml.soap.SOAPMessage msg)
          Verifies the given XSSignature, following the ds:Signature and ds:Reference validation process defined in [XML-SIG].
static boolean verify(oracle.security.xmlsec.dsig.XSSignature sig, byte[] hmacKey, java.security.PublicKey pubKey, javax.xml.soap.SOAPMessage msg)
          Verifies the given XSSignature using either the hmacKey or the pubKey, following the ds:Signature and ds:Reference validation process defined in [XML-SIG].
 boolean verify(oracle.security.xmlsec.dsig.XSSignature sig, javax.xml.soap.SOAPMessage msg)
          Verifies the given XSSignature, following the ds:Signature and ds:Reference validation process defined in [XML-SIG].
 boolean verifyAll()
          Verifies all of the XSSignatures in this wsse:Security header in accordance with the ds:Signature and ds:Reference validation process defined in [XML-SIG].
 boolean verifyAll(javax.xml.soap.SOAPMessage msg)
          Verifies all of the XSSignatures in this wsse:Security header in accordance with the ds:Signature and ds:Reference validation process defined in [XML-SIG].
 boolean verifySignatureConfirmations(java.lang.String[] sigValues)
          Verify the signature confirmations in this WSSecurity following the response processing rules for Signature Confirmation in the WS SEcurity 1.1 spec.

 

Methods inherited from class oracle.security.xmlsec.util.XMLElement
addNSPrefixAttr, addNSPrefixAttr, addNSPrefixAttrDefault, addNSPrefixAttrDefault, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getChildElementsByTagName, getChildElementsByTagName, getChildElementsByTagNameNS, getChildElementsByTagNameNS, getDefaultNSPrefix, getElement, getElementsByTagName, getElementsByTagNameNS, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setDefaultNSPrefix

 

Methods inherited from class oracle.security.xmlsec.util.XMLNode
appendChild, appendChild, appendTo, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getSystemId, hasAttributes, hasChildNodes, insertBefore, insertBefore, isSupported, normalize, removeChild, removeChild, replaceChild, replaceChild, setNodeValue, setPrefix, setSystemId, toBytesXML, toStringXML

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

WSSecurity

public WSSecurity(org.w3c.dom.Element element)
Creates a new WSSecurity instance from the given Element node.
Parameters:
element - An org.w3c.dom.Element that conforms to the wsse:Security schema.

WSSecurity

public WSSecurity(org.w3c.dom.Element element,
                  java.lang.String systemId)
Creates a new WSSecurity instance from the given Element node.
Parameters:
element - An org.w3c.dom.Element that conforms to the wsse:WSSecurity schema.
systemId - The URI string system ID for this XSSignature.

Method Detail

newInstance

public static WSSecurity newInstance(java.lang.String id)
Creates a new WSSecurity instance in a new owner document, and makes it the root element of the document.
Parameters:
id - An optional string ID name for the wsse:Security element.
Returns:
The new WSSecurity instance.

newInstance

public static WSSecurity newInstance(org.w3c.dom.Document owner)
Creates a new WSSecurity instance using the given owner document, but does not append it to any element.
Parameters:
owner - The XML Document to be used as the owner document of this structure.
Returns:
The new WSSecurity instance.

newInstance

public static WSSecurity newInstance(javax.xml.soap.SOAPEnvelope env)
                              throws javax.xml.soap.SOAPException
Create a new WSSecurity instance using the given SOAPEnvelope. This method uses SOAPHeader.addHeaderElement(javax.xml.soap.Name) to create the WSSecurity header, so you can get the underlying WSSecurity element by casting WSSecurity.getElement() to a SOAPHeaderElement
  WSSecurity ws = WSSecurity.newInstance(env); 
  SOAPHeaderElement el = (SOAPHeaderElement)ws.getElement();
 
Parameters:
env -
Returns:
The new WSSecurity instance.
Throws:
javax.xml.soap.SOAPException

newInstance

public static WSSecurity newInstance(org.w3c.dom.Document owner,
                                     java.lang.String id)
Creates a new WSSecurity instance using the given owner document, but does not append it to any element.
Parameters:
owner - The XML Document to be used as the owner document of this structure.
id - An optional string ID name for the wsse:Security element.
Returns:
The new WSSecurity instance.

getAllSecurityHeaders

public static WSSecurity[] getAllSecurityHeaders(javax.xml.soap.SOAPEnvelope env)
                                          throws javax.xml.soap.SOAPException
Get all the wsse:Security headers in this envelope. Calls SOAPHeader.examineAllHeaderElements() to get a list of headers, and of them returns the ones that are wsse:Security
Parameters:
env -
Returns:
an array of WSSecurity headers
Throws:
javax.xml.soap.SOAPException

getSecurityHeaders

public static WSSecurity[] getSecurityHeaders(javax.xml.soap.SOAPEnvelope env,
                                              java.lang.String actor)
                                       throws javax.xml.soap.SOAPException
Get all the wsse:Security headers in this envelope. Calls SOAPHeader.examineHeaderElements(String) to get a list of headers for a specified actor(in SOAP 1.1) or role (in SOAP 1.2), and of them returns the ones that are wsse:Security
Parameters:
env -
Returns:
an array of WSSecurity headers
Throws:
javax.xml.soap.SOAPException

getMustUnderstandSecurityHeaders

public static WSSecurity[] getMustUnderstandSecurityHeaders(javax.xml.soap.SOAPEnvelope env,
                                                            java.lang.String actor)
                                                     throws javax.xml.soap.SOAPException
Get all the wsse:Security headers in this envelope. Calls SOAPHeader.examineMustUnderstandHeaderElements(String) to get a list of headers for a specified actor(in SOAP 1.1) or role (in SOAP 1.2), which have mustUnderstand=true and of them returns the ones that are wsse:Security
Parameters:
env -
Returns:
an array of WSSecurity headers
Throws:
javax.xml.soap.SOAPException

createSignature

public oracle.security.xmlsec.dsig.XSSignature createSignature(java.lang.String id)
Creates a new Signature element in this document, but does not append it to the WSSecurity element.
Parameters:
id - An optional string ID name for the Signature element.
Returns:
A new XSSignature instance.

addUsernameToken

public void addUsernameToken(UsernameToken token)
Add a Username Token.

The Username Token will be imported if it is in a different org.w3c.dom.Document.

Parameters:
token - The Security Token to add.

addX509CertificateToken

public void addX509CertificateToken(X509BinarySecurityToken token)
Add a X.509 Certificate Token.

The X.509 Certificate Token will be imported if it is in a different org.w3c.dom.Document.

Parameters:
token - The Security Token to add.

addKerberosToken

public void addKerberosToken(KerberosBinarySecurityToken token)
Add a Kerberos Token.

The Kerberos Token will be imported if it is in a different org.w3c.dom.Document.

Parameters:
token - The Security Token to add.

addSAMLAssertionToken

public void addSAMLAssertionToken(SAMLAssertionToken token)
Add a SAML Assertion Token.

The SAML Assertione Token will be imported if it is in a different org.w3c.dom.Document.

Parameters:
token - The Security Token to add.

addSAML2AssertionToken

public void addSAML2AssertionToken(SAML2AssertionToken token)
Add a SAML2 Assertion Token.

The SAML2 Assertione Token will be imported if it is in a different org.w3c.dom.Document.

Parameters:
token - The Security Token to add.

addSecurityToken

public void addSecurityToken(org.w3c.dom.Element token)
Add a Security Token.

The input token element is not schema validated.

The Security Token will be imported if it is in a different org.w3c.dom.Document.

Parameters:
token - The Security Token element to add.

addSecurityTokenReference

public void addSecurityTokenReference(WSSecurityTokenReference ref)
Add a Security Token Reference.
Parameters:
ref - The Security Token reference to add.

setTimestamp

public void setTimestamp(WSUTimestamp timeStamp)
Set the token Timestamp.
Parameters:
timeStamp - The timestamp.

getTimestamp

public WSUTimestamp getTimestamp()
Get the token Timestamp.
Returns:
The timestamp.

encrypt

public void encrypt(org.w3c.dom.Element element,
                    boolean contentOnly,
                    java.lang.String dataEncAlg,
                    java.lang.String usernameTokenURI,
                    KeyDerivator keyDerivator)
             throws WSSException
Deprecated. 
Perform encryption of the Security Header content.

The keyEncKeyURI must be a reference to a X.509 Token or a SAML Assertion token with a Holder of Key saml:ConfirmationMethod.

Parameters:
element - The element to encrypt.
contentOnly - If true only encrypt the children of the element else encrypt the whole element.
dataEncAlg - The content encryption algorithm.
usernameTokenURI - The UsernameToken URI.
keyDerivator - The key derivation interface to use.
Throws:
WSSException

encrypt

public void encrypt(java.util.List elements,
                    boolean[] contentOnlys,
                    java.lang.String dataEncAlgURI,
                    java.lang.String usernameTokenURI,
                    KeyDerivator keyDerivator)
             throws WSSException
Deprecated. 
Perform encryption of the Security Header content.

The usernameTokenURI must be a reference to an Username Token.

Parameters:
elements - The list of org.w3c.dom.Elements to encrypt.
contentOnlys - The List of boolean values for each List elements.If true only encrypt the children of the corresponding List element else encrypt the entire corresponding List element.
dataEncAlgURI - The content encryption algorithm.
usernameTokenURI - The UsernameToken URI.
keyDerivator - The key derivation interface to use.
Throws:
WSSException

encrypt

public void encrypt(org.w3c.dom.Element element,
                    boolean contentOnly,
                    java.lang.String dataEncAlg,
                    java.lang.String certTokenURI,
                    java.lang.String keyEncAlg,
                    javax.crypto.SecretKey dataEncKey)
             throws WSSException
Perform encryption of the Security Header content.

The keyEncKeyURI must be a reference to a X.509 Token or a SAML Assertion token with a Holder of Key saml:ConfirmationMethod.

Parameters:
element - The element to encrypt.
contentOnly - If true only encrypt the children of the element else encrypt the whole element.
dataEncAlg - The content encryption algorithm.
certTokenURI - The X.509 certificate token URI.
keyEncAlg - The key key encryption algorithm.
dataEncKey - The content encryption key.
Throws:
WSSException

encrypt

public void encrypt(java.util.List elements,
                    boolean[] contentOnlys,
                    java.lang.String dataEncAlg,
                    java.lang.String certTokenURI,
                    java.lang.String keyEncAlg,
                    javax.crypto.SecretKey dataEncKey)
             throws WSSException
Perform encryption of the Security Header content.

The keyEncKeyURI must be a reference to a X.509 Token or a SAML Assertion token with a Holder of Key saml:ConfirmationMethod.

Parameters:
elements - The list of org.w3c.dom.Elements to encrypt.
contentOnlys - The List of boolean values for each List elements.If true only encrypt the children of the corresponding List element else encrypt the entire corresponding List element.
dataEncAlg - The content encryption algorithm.
certTokenURI - The X.509 certificate token URI.
keyEncAlg - The key key encryption algorithm.
dataEncKey - The content encryption key.
Throws:
WSSException

encrypt

public void encrypt(org.w3c.dom.Element element,
                    boolean contentOnly,
                    java.lang.String dataEncAlg,
                    java.lang.String keyEncKeyURI,
                    java.lang.String keyEncAlg)
             throws WSSException
Perform encryption of the Security Header content.

The keyEncKeyURI must be a reference to a X.509 Token or a SAML Assertion token with a Holder of Key saml:ConfirmationMethod.

Parameters:
element - The element to encrypt.
contentOnly - If true only encrypt the children of the element else encrypt the whole element.
dataEncAlg - The content encryption algorithm.
keyEncKeyURI - The key encryption certificate URI.
keyEncAlg - The key encryption algorithm.
Throws:
WSSException

encrypt

public void encrypt(java.util.List elements,
                    boolean[] contentOnlys,
                    java.lang.String dataEncAlg,
                    java.lang.String keyEncKeyURI,
                    java.lang.String keyEncAlg)
             throws WSSException
Perform encryption of the Security Header content.

The keyEncKeyURI must be a reference to a X.509 Token or a SAML Assertion token with a Holder of Key saml:ConfirmationMethod.

Parameters:
elements - The list of org.w3c.dom.Elements to encrypt.
contentOnlys - The List of boolean values for each List elements.If true only encrypt the children of the corresponding List element else encrypt the entire corresponding List element.
dataEncAlg - The content encryption algorithm.
keyEncKeyURI - The key encryption certificate URI.
keyEncAlg - The key encryption algorithm.
Throws:
WSSException

sign

public void sign(java.lang.String uri,
                 UsernameToken token,
                 KeyDerivator keyDerivator,
                 java.lang.String digestAlg,
                 java.lang.String c14NAlg,
                 java.lang.String signatureAlg,
                 boolean usingDecryptionTransform)
          throws WSSException
Deprecated. KeyDerivator was used before WSS 1.1, Instead use UsernameToken.deriveKey(char[], byte[], int) to derive the password, and call the regular sign method
Perform signing of the Security Header content using an HMAC key that is derived from the Username security token..
Parameters:
uri - The URI of the element to encrypt.
token - The Username security token used to derive the signing HMAC key.
keyDerivator - The key derivation class.
digestAlg - The message digest algorithm.
c14NAlg - The canonicalization algorithm.
signatureAlg - The signature algorithm.
usingDecryptionTransform - Indicates the use of the decryption transform.
Throws:
WSSException

sign

public void sign(java.lang.String[] uris,
                 UsernameToken token,
                 KeyDerivator keyDerivator,
                 java.lang.String digestAlg,
                 java.lang.String c14NAlg,
                 java.lang.String signatureAlg,
                 boolean usingDecryptionTransform)
          throws WSSException
Deprecated. KeyDerivator was used before WSS 1.1, Instead use UsernameToken.deriveKey(char[], byte[], int) to derive the password, and call the regular sign method
Perform signing of the Security Header content using an HMAC key that is derived from the Username security token..
Parameters:
uris - The URI list of org.w3c.dom.Elements to encrypt.
token - The Username security token used to derive the signing HMAC key.
keyDerivator - The key derivation class.
digestAlg - The message digest algorithm.
c14NAlg - The canonicalization algorithm.
signatureAlg - The signature algorithm.
usingDecryptionTransform - Indicates the use of the decryption transform.
Throws:
WSSException

sign

public void sign(java.lang.String[] uris,
                 UsernameToken token,
                 KeyDerivator keyDerivator,
                 java.lang.String digestAlg,
                 java.lang.String c14NAlg,
                 java.lang.String signatureAlg,
                 oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[] trans,
                 boolean usingDecryptionTransform)
          throws WSSException
Deprecated. 
Perform signing of the Security Header content using an HMAC key that is derived from the Username security token..
Parameters:
uris - The URI list of org.w3c.dom.Elements to encrypt.
token - The Username security token used to derive the signing HMAC key.
keyDerivator - The key derivation class.
digestAlg - The message digest algorithm.
c14NAlg - The canonicalization algorithm.
signatureAlg - The signature algorithm.
trans - The list of ds:Reference transforms
usingDecryptionTransform - Indicates the use of the decryption transform.
Throws:
WSSException

sign

public oracle.security.xmlsec.dsig.XSSignature sign(java.lang.String[] uris,
                                                    WSSignatureParams sigParams,
                                                    oracle.security.xmlsec.dsig.XSAlgorithmIdentifier[][] trans)
                                             throws WSSException
Signs a list of URIs using an HMAC key or a PrivateKey. Creates a Signature element that includes all the passed in references in the order they are given. Prepends this Signature element to this WSSecurity header and returns the Signature element

Note

There are two ways of specifing the tranforms