public abstract class SAMLMessage
extends oracle.security.xmlsec.util.XMLElement
Modifier | Constructor and Description |
---|---|
protected |
SAMLMessage(org.w3c.dom.Document owner,
java.lang.String uri,
java.lang.String localName)
Creates a new
SAMLMessage instance. |
protected |
SAMLMessage(org.w3c.dom.Element element)
Creates a new
SAMLMessage instance from the given Element node. |
protected |
SAMLMessage(org.w3c.dom.Element element,
java.lang.String systemId)
Creates a new
SAMLMessage instance from the given Element node. |
Modifier and Type | Method and Description |
---|---|
XSSignature |
addSignature(java.lang.String signatureMethod,
java.lang.String c14nMethod)
Creates a new XML-DSIG
Signature element and inserts it into this
message, replacing any exisiting XML-DSIG Signature element. |
XSSignature |
addSignature(java.lang.String signatureMethod,
java.lang.String c14nMethod,
java.lang.String digestMethod)
Creates a new XML-DSIG
Signature element and inserts it into this
message, replacing any exisiting XML-DSIG Signature element. |
protected void |
clearSignature()
Removes any exisiting XML-DSIG
Signature elements from this
message. |
protected abstract java.lang.String |
getID()
Returns the ID attribute if any of this SAML message to be used for the signature operations.
|
static SAMLMessage |
getInstance(org.w3c.dom.Element element,
java.lang.String ns)
Instantiates a concrete
SAMLMessage subclass
implementation to wrap the given Element . |
protected abstract java.lang.String[] |
getLocalNamesPrecedeDSig()
Obtains the ordered set of the local names of all the
preceding sibling child elements of this Signature child
element in the the Schema for the XML element that the
implementing subclass targets for.
|
int |
getMajorVersion()
Returns the major version number of this SAML Message or
-1 if the MajorVersion attribute
is missing.. |
int |
getMinorVersion()
Returns the minor version number of this SAML Message or
-1 if the MinorVersion attribute
is missing. |
protected abstract java.lang.String[] |
getNSURIsPrecedeDSig()
Obtains the ordered set of the the namespace URIs for all the
preceding sibling child elements of this Signature child element
in the the Schema for the XML element that the implementing subclass
targets for.
|
XSSignature |
getSignature()
Returns the XML Signature child element from this
SAMLMessage
element. |
boolean |
isSigned()
Indicates if this element was signed.
|
void |
setVersion(int major,
int minor)
Sets the
MajorVersion and MinorVersion
attributes for this message. |
void |
sign(java.security.PrivateKey privateKey,
java.security.cert.X509Certificate cert)
Signs this
SAMLMessage with the given private key, and includes
the given certificate in the KeyInfo child element of the resulting
XML-DSIG Signature element. |
void |
sign(java.security.PrivateKey privateKey,
java.security.cert.X509Certificate cert,
java.lang.String c14nMethod)
Signs this
SAMLMessage with the given private key, and includes
the given certificate in the KeyInfo child element of the resulting
XML-DSIG Signature element. |
void |
sign(java.lang.String signatureMethod,
java.security.PrivateKey privateKey,
java.security.cert.X509Certificate cert)
Signs this
SAMLMessage using given signature method, private key, and includes
the given certificate in the KeyInfo child element of the resulting
XML-DSIG Signature element. |
void |
sign(java.lang.String signatureMethod,
java.lang.String digestMethod,
java.security.PrivateKey privateKey,
java.security.cert.X509Certificate cert,
java.lang.String c14nMethod)
Signs this
SAMLMessage using the signature method, digest method, private key, and includes
the given certificate in the KeyInfo child element of the resulting
XML-DSIG Signature element. |
boolean |
verify()
Verifies the signature using a key obtained either from the KeyInfo element
(if any is present) or via the
oracle.security.xmlsec.keys.retrieval.KeyRetriever
mechanism. |
boolean |
verify(java.security.PublicKey publicKey)
Verifies the signature with the given public key.
|
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
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
protected SAMLMessage(org.w3c.dom.Element element) throws org.w3c.dom.DOMException
SAMLMessage
instance from the given Element node.element
- A SAMLMessage element.org.w3c.dom.DOMException
protected SAMLMessage(org.w3c.dom.Element element, java.lang.String systemId) throws org.w3c.dom.DOMException
SAMLMessage
instance from the given Element node.element
- A SAMLMessage element.systemId
- The URI string system ID for the Action
.org.w3c.dom.DOMException
protected SAMLMessage(org.w3c.dom.Document owner, java.lang.String uri, java.lang.String localName) throws org.w3c.dom.DOMException
SAMLMessage
instance.owner
- The owner document of the new SAMLMessage.uri
- The namespace URI in which the new SAMLMessage is to be created.localName
- The localName of the element represented by the class that extends
this class.org.w3c.dom.DOMException
public static SAMLMessage getInstance(org.w3c.dom.Element element, java.lang.String ns) throws org.w3c.dom.DOMException
SAMLMessage
subclass
implementation to wrap the given Element
.element
- An org.w3c.dom.Element
representing an
extension of one of the the following types:
samlp:RequestAbstractType
,
samlp:ResponseAbstractType
,
saml:Assertion
.ns
- The namespace URI for the element.SAMLMessage
, or null
if no appropriate implementation class could be found.org.w3c.dom.DOMException
public void setVersion(int major, int minor) throws org.w3c.dom.DOMException
MajorVersion
and MinorVersion
attributes for this message. Version 1.0 is the default.major
- The major component of the version number.minor
- The minor component of the version number.org.w3c.dom.DOMException
public int getMajorVersion()
-1
if the MajorVersion
attribute
is missing..public int getMinorVersion()
-1
if the MinorVersion
attribute
is missing.protected abstract java.lang.String[] getNSURIsPrecedeDSig()
protected abstract java.lang.String[] getLocalNamesPrecedeDSig()
public XSSignature getSignature()
SAMLMessage
element.XSSignature
object or null
if no signature
is present.public boolean isSigned()
true
if a signature is present, false
otherwise.public void sign(java.security.PrivateKey privateKey, java.security.cert.X509Certificate cert) throws SigningException
SAMLMessage
with the given private key, and includes
the given certificate in the KeyInfo
child element of the resulting
XML-DSIG Signature
element. The default canonicalization method is
XML-EXCLUSIVE-C14N.privateKey
- The private key to use for the signature computation.cert
- The X509
certificate corresponding to the private
key.SigningException
public void sign(java.lang.String signatureMethod, java.security.PrivateKey privateKey, java.security.cert.X509Certificate cert) throws SigningException
SAMLMessage
using given signature method, private key, and includes
the given certificate in the KeyInfo
child element of the resulting
XML-DSIG Signature
element. The default canonicalization method is
XML-EXCLUSIVE-C14N.signatureMethod
- The value of the algorithm attribute of the SignatureMethodprivateKey
- The private key to use for the signature computation.cert
- The X509
certificate corresponding to the private
key.SigningException
public void sign(java.lang.String signatureMethod, java.lang.String digestMethod, java.security.PrivateKey privateKey, java.security.cert.X509Certificate cert, java.lang.String c14nMethod) throws SigningException
SAMLMessage
using the signature method, digest method, private key, and includes
the given certificate in the KeyInfo
child element of the resulting
XML-DSIG Signature
element. The default canonicalization method is
XML-EXCLUSIVE-C14N.signatureMethod
- The value of the algorithm attribute of the SignatureMethoddigestMethod
- The value of the Algorithm attribute of the DigestMethodprivateKey
- The private key to use for the signature computation.cert
- The X509
certificate corresponding to the private
key.SigningException
public void sign(java.security.PrivateKey privateKey, java.security.cert.X509Certificate cert, java.lang.String c14nMethod) throws SigningException
SAMLMessage
with the given private key, and includes
the given certificate in the KeyInfo
child element of the resulting
XML-DSIG Signature
element.privateKey
- The private key to use for the signature computation.cert
- The X509
certificate corresponding to the private
key.c14nMethod
- The URI identifying the canonicalization method to be applied
to the SignedInfo structure.SigningException
public XSSignature addSignature(java.lang.String signatureMethod, java.lang.String c14nMethod)
Signature
element and inserts it into this
message, replacing any exisiting XML-DSIG Signature
element. The
default message digest algorithm is SHA-1.
Note: This method does not compute the SignatureValue
or create
a KeyInfo
child element for the Signature
element so,
at a minimum, one of the sign()
methods must be invoked on the
returned XSSignature
object.
This method is intended for use by developers who need to customize the
Signature
element (e.g., add custom Transform
elements)
the computation of the SignatureValue
(e.g., using an HMAC signature
algorithm) or the KeyInfo
element. For most developers, either the
#sign(PrivateKey, X509)
or #sign(PrivateKey, X509, String)
method
should be sufficient.
signatureMethod
- The value of the Algorithm
attribute of the
SignatureMethod
element contained within the
new Signature
element's SignedInfo
child element (e.g., oracle.security.xmlsec.util.XMLURI.alg_rsaWithSHA1
).c14nMethod
- The value of the Algorithm
attribute of the
CanonicalizationMethod
element contained within
the new Signature
element's SignedInfo
child element (e.g., oracle.security.xmlsec.util.XMLURI.alg_c14nWithComments
).oracle.security.xmlsec.dsig.XSSignature
object.public XSSignature addSignature(java.lang.String signatureMethod, java.lang.String c14nMethod, java.lang.String digestMethod)
Signature
element and inserts it into this
message, replacing any exisiting XML-DSIG Signature
element.
Note: This method does not compute the SignatureValue
or create
a KeyInfo
child element for the Signature
element so,
at a minimum, one of the sign()
methods must be invoked on the
returned XSSignature
object.
This method is intended for use by developers who need to customize the
Signature
element (e.g., add custom Transform
elements)
the computation of the SignatureValue
(e.g., using an HMAC signature
algorithm) or the KeyInfo
element. For most developers, either the
#sign(PrivateKey, X509)
or #sign(PrivateKey, X509, String)
method
should be sufficient.
signatureMethod
- The value of the Algorithm
attribute of the
SignatureMethod
element contained within the
new Signature
element's SignedInfo
child element (e.g., oracle.security.xmlsec.util.XMLURI.alg_rsaWithSHA1
).c14nMethod
- The value of the Algorithm
attribute of the
CanonicalizationMethod
element contained within
the new Signature
element's SignedInfo
child element (e.g., oracle.security.xmlsec.util.XMLURI.alg_c14nWithComments
).digestMethod
- The value of the Algorithm
attribute of the
DigestMethod
element contained within
the new Signature
element's Reference
child element (e.g., oracle.security.xmlsec.util.XMLURI.alg_sha1
).oracle.security.xmlsec.dsig.XSSignature
object.public boolean verify() throws VerifyException
oracle.security.xmlsec.keys.retrieval.KeyRetriever
mechanism. Any Manifests referenced by the signature will be validated.true
if the verification succeeded, or
false
if the verification failed.VerifyException
- If an error occurs while verifying the signature, or
if no signature is present in this message.public boolean verify(java.security.PublicKey publicKey) throws VerifyException
publicKey
- The public key used for verifying the signature.true
if the verification succeeded, or
false
if the verification failed.VerifyException
- If an error occurs while verifying the signature, or
if no signature is present in this message.protected void clearSignature()
Signature
elements from this
message.protected abstract java.lang.String getID()