public class XMLSignatureManager extends Object
XMLSignatureManager
provides methods
to sign and verify XML signature.
Modifier and Type | Field and Description |
---|---|
protected static XMLSignatureManager |
instance |
Modifier | Constructor and Description |
---|---|
protected |
XMLSignatureManager()
Constructor
|
protected |
XMLSignatureManager(KeyProvider keyProvider,
SignatureProvider sigProvider)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static XMLSignatureManager |
getInstance()
Gets the singleton instance of
XMLSignatureManager with
default KeyProvider and SignatureProvider . |
static XMLSignatureManager |
getInstance(KeyProvider keyProvider,
SignatureProvider sigProvider)
Get an instance of
XMLSignatureManager with specified
KeyProvider and SignatureProvider . |
KeyProvider |
getKeyProvider()
Get
KeyProvider |
SignatureProvider |
getSignatureProvider()
Returns the SignatureProvider
|
Element |
signWithBinarySecurityToken(Document doc,
Certificate cert,
String algorithm,
List ids,
String refenceType)
Sign part of the XML document wth binary security token using
referred by the supplied a list of id attributes of nodes.
|
Element |
signWithKerberosToken(Document doc,
Key key,
String algorithm,
List ids) |
Element |
signWithSAMLToken(Document doc,
Certificate cert,
String assertionID,
String algorithm,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signWithSAMLToken(Document doc,
Key key,
boolean symmetricKey,
Certificate signingCert,
Certificate encryptCert,
String assertionID,
String algorithm,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes using SAML Token.
|
Element |
signWithUserNameToken(Document doc,
Certificate cert,
String algorithm,
List ids)
Sign part of the XML document wth UserName security token using
referred by the supplied a list of id attributes of nodes.
|
Element |
signWithWSSSAMLTokenProfile(Document doc,
Certificate cert,
String assertionID,
String algorithm,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signWithWSSSAMLTokenProfile(Document doc,
Certificate cert,
String assertionID,
String algorithm,
List ids,
String wsfVersion)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signWithWSSX509TokenProfile(Document doc,
Certificate cert,
String algorithm,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signWithWSSX509TokenProfile(Document doc,
Certificate cert,
String algorithm,
List ids,
String wsfVersion)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signXML(Document doc,
String certAlias)
Sign the XML document using enveloped signatures.
|
Element |
signXML(Document doc,
String certAlias,
String algorithm)
Sign the XML document using enveloped signatures.
|
Element |
signXML(Document doc,
String certAlias,
String algorithm,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signXML(Document doc,
String certAlias,
String algorithm,
String id)
Sign part of the XML document referred by the supplied id attribute using
enveloped signatures and use exclusive XML canonicalization.
|
Element |
signXML(Document doc,
String certAlias,
String algorithm,
String transformAlag,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
Element |
signXML(Document doc,
String certAlias,
String algorithm,
String id,
String xpath)
Sign part of the XML document referred by the supplied id attribute
using enveloped signatures and use exclusive XML canonicalization.
|
Element |
signXML(Document doc,
String certAlias,
String algorithm,
String idAttrName,
String id,
boolean includeCert)
Sign part of the XML document referred by the supplied id attribute
using enveloped signatures and use exclusive XML canonicalization.
|
Element |
signXML(Document doc,
String certAlias,
String algorithm,
String idAttrName,
String id,
boolean includeCert,
String xpath)
Sign part of the XML document referred by the supplied id attribute
using enveloped signatures and use exclusive XML canonicalization.
|
String |
signXML(String XML,
String certAlias)
Sign the XML string using enveloped signatures.
|
String |
signXML(String XML,
String certAlias,
String algorithm)
Sign the XML string using enveloped signatures.
|
String |
signXML(String xmlString,
String certAlias,
String algorithm,
List ids)
Sign part of the XML document referred by the supplied a list
of id attributes of nodes
|
String |
signXML(String xmlString,
String certAlias,
String algorithm,
String id)
Sign the XML string using enveloped signatures.
|
String |
signXML(String xmlString,
String certAlias,
String algorithm,
String idAttrName,
String id,
boolean includeCert)
Sign part of the XML document referred by the supplied id attribute
using enveloped signatures and use exclusive XML canonicalization.
|
Element |
signXMLUsingKeyPass(Document doc,
String certAlias,
String encryptedKeyPass,
String algorithm,
String idAttrName,
String id,
boolean includeCert,
String xpath)
Sign part of the XML document referred by the supplied id attribute
using enveloped signatures and use exclusive XML canonicalization.
|
boolean |
verifyWSSSignature(Document document,
Key key)
Verify web services message signature using specified key
|
boolean |
verifyWSSSignature(Document document,
Key key,
String certAlias,
String encryptAlias)
Verify web services message signature using specified key
|
boolean |
verifyWSSSignature(Document document,
String certAlias)
Verify all the signatures of the XML document for the
web services security.
|
boolean |
verifyXMLSignature(Document document)
Verify all the signatures of the XML document
|
boolean |
verifyXMLSignature(Document document,
Certificate cert)
Verify the signature of the XML document
|
boolean |
verifyXMLSignature(Document document,
String certAlias)
Verify all the signatures of the XML document
|
boolean |
verifyXMLSignature(Element element)
Verify the signature of the XML document
|
boolean |
verifyXMLSignature(Element element,
String certAlias)
Verify the signature of the XML document
|
boolean |
verifyXMLSignature(Element element,
String idAttrName,
String certAlias)
Verify the signature of the XML document
|
boolean |
verifyXMLSignature(String XML)
Verify the signature of the XML string
|
boolean |
verifyXMLSignature(String XML,
String certAlias)
Verify the signature of the XML string
|
boolean |
verifyXMLSignature(String wsfVersion,
String certAlias,
Document document)
Verify all the signatures of the XML document
|
boolean |
verifyXMLSignature(String xmlString,
String idAttrName,
String certAlias)
Verify the signature of the XML string
|
protected static XMLSignatureManager instance
protected XMLSignatureManager()
protected XMLSignatureManager(KeyProvider keyProvider, SignatureProvider sigProvider)
public static XMLSignatureManager getInstance()
XMLSignatureManager
with
default KeyProvider
and SignatureProvider
.XMLSignatureManager
public static XMLSignatureManager getInstance(KeyProvider keyProvider, SignatureProvider sigProvider)
XMLSignatureManager
with specified
KeyProvider
and SignatureProvider
.keyProvider
- KeyProvider
sigProvider
- SignatureProvider
.XMLSignatureManager
.public SignatureProvider getSignatureProvider()
public Element signXML(Document doc, String certAlias) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias nameXMLSignatureException
- if the document could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- signature algorithmXMLSignatureException
- if the document could not be signedpublic String signXML(String XML, String certAlias) throws XMLSignatureException
XML
- XML string to be signedcertAlias
- Signer's certificate alias nameXMLSignatureException
- if the XML string could not be signedpublic String signXML(String XML, String certAlias, String algorithm) throws XMLSignatureException
XML
- XML string to be signedcertAlias
- Signer's certificate alias namealgorithm
- signature algorithmXMLSignatureException
- if the XML string could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm, String id) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmid
- attribute value of the node to be signedXMLSignatureException
- if the document could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm, String id, String xpath) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmid
- id attribute value of the node to be signedxpath
- expression should uniquely identify a node before whichXMLSignatureException
- if the document could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm, String idAttrName, String id, boolean includeCert) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmidAttrName
- attribute name for the id attribute of the node to be
signed.id
- id attribute value of the node to be signedincludeCert
- if true, include the signing certificate in
KeyInfo
. if false, does not include the signing
certificate.XMLSignatureException
- if the document could not be signedpublic String signXML(String xmlString, String certAlias, String algorithm, String idAttrName, String id, boolean includeCert) throws XMLSignatureException
xmlString
- a string representing XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmidAttrName
- attribute name for the id attribute of the node to be
signed.id
- id attribute value of the node to be signedincludeCert
- if true, include the signing certificate in
KeyInfo
.
if false, does not include the signing certificate.XMLSignatureException
- if the document could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm, String idAttrName, String id, boolean includeCert, String xpath) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmidAttrName
- attribute name for the id attribute of the node to be
signed.id
- id attribute value of the node to be signedincludeCert
- if true, include the signing certificate in
KeyInfo
.
if false, does not include the signing certificate.xpath
- expression should uniquely identify a node before whichXMLSignatureException
- if the document could not be signedpublic Element signXMLUsingKeyPass(Document doc, String certAlias, String encryptedKeyPass, String algorithm, String idAttrName, String id, boolean includeCert, String xpath) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias nameencryptedKeyPass
- Use the supplied encrypted key password to get the private keyalgorithm
- XML signature algorithmidAttrName
- attribute name for the id attribute of the node to be
signed.id
- id attribute value of the node to be signedincludeCert
- if true, include the signing certificate in
KeyInfo
.
if false, does not include the signing certificate.xpath
- expression should uniquely identify a node before whichXMLSignatureException
- if the document could not be signedpublic String signXML(String xmlString, String certAlias, String algorithm, String id) throws XMLSignatureException
xmlString
- XML string to be signedcertAlias
- Signer's certificate alias namealgorithm
- XML Signature algorithmid
- id attribute value of the node to be signedXMLSignatureException
- if the XML string could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm, List ids) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic String signXML(String xmlString, String certAlias, String algorithm, List ids) throws XMLSignatureException
xmlString
- XML dom object's string formatcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signXML(Document doc, String certAlias, String algorithm, String transformAlag, List ids) throws XMLSignatureException
doc
- XML dom objectcertAlias
- Signer's certificate alias namealgorithm
- XML signature algorithmtransformAlag
- XML signature transform algorithm
Those transfer constants are defined as
SAMLConstants.TRANSFORM_XXX
.ids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signWithWSSSAMLTokenProfile(Document doc, Certificate cert, String assertionID, String algorithm, List ids) throws XMLSignatureException
doc
- XML dom objectcert
- signer's CertificateassertionID
- assertion ID for the SAML Security Tokenalgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signWithWSSSAMLTokenProfile(Document doc, Certificate cert, String assertionID, String algorithm, List ids, String wsfVersion) throws XMLSignatureException
doc
- XML dom objectcert
- signer's CertificateassertionID
- assertion ID for the SAML Security Tokenalgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedwsfVersion
- the web services framework that should be used.
For WSF1.1, the version must be "1.1" and for WSF1.0,
it must be "1.0"XMLSignatureException
- if the document could not be signedpublic Element signWithSAMLToken(Document doc, Certificate cert, String assertionID, String algorithm, List ids) throws XMLSignatureException
doc
- XML dom objectcert
- signer's CertificateassertionID
- assertion ID for the SAML Security Tokenalgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signWithSAMLToken(Document doc, Key key, boolean symmetricKey, Certificate signingCert, Certificate encryptCert, String assertionID, String algorithm, List ids) throws XMLSignatureException
doc
- XML dom objectkey
- the key that will be used to sign the document.symmetricKey
- true if the supplied key is a symmetric key type.signingCert
- signer's Certificate. If present, this certificate
will be added as part of signature KeyInfo
.encryptCert
- the certificate if present will be used to encrypt
the symmetric key and replay it as part of KeyInfo
assertionID
- assertion ID for the SAML Security Tokenalgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signWithKerberosToken(Document doc, Key key, String algorithm, List ids) throws XMLSignatureException
XMLSignatureException
public Element signWithBinarySecurityToken(Document doc, Certificate cert, String algorithm, List ids, String refenceType) throws XMLSignatureException
doc
- the XML DOM
document.cert
- Signer's certificatealgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedrefenceType
- signed element reference typeXMLSignatureException
- if the document could not be signedpublic Element signWithUserNameToken(Document doc, Certificate cert, String algorithm, List ids) throws XMLSignatureException
doc
- the XML DOM
document.cert
- Signer's certificatealgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signWithWSSX509TokenProfile(Document doc, Certificate cert, String algorithm, List ids) throws XMLSignatureException
doc
- XML dom objectcert
- Signer's certificatealgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedXMLSignatureException
- if the document could not be signedpublic Element signWithWSSX509TokenProfile(Document doc, Certificate cert, String algorithm, List ids, String wsfVersion) throws XMLSignatureException
doc
- XML dom objectcert
- Signer's certificatealgorithm
- XML signature algorithmids
- list of id attribute values of nodes to be signedwsfVersion
- the web services framework that should be used.
For WSF1.1, it should be "1.1" and for WSF1.0,
it should be "1.0"XMLSignatureException
- if the document could not be signedpublic boolean verifyXMLSignature(Document document) throws XMLSignatureException
document
- XML dom document whose signature to be verifiedXMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(Document document, String certAlias) throws XMLSignatureException
document
- XML dom document whose signature to be verifiedcertAlias
- alias for Signer's certificate, this is used to search
signer's public certificate if it is not presented in
ds:KeyInfo
.XMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(Document document, Certificate cert) throws XMLSignatureException
document
- XML dom document whose signature to be verifiedcert
- Signer's certificate, this is used to search signer's
public certificate if it is not presented in
ds:KeyInfo
.XMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(Element element) throws XMLSignatureException
element
- XML dom document whose signature to be verifiedXMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(Element element, String certAlias) throws XMLSignatureException
element
- XML dom document whose signature to be verifiedcertAlias
- alias for Signer's certificate, this is used to search
signer's public certificate if it is not presented in
ds:KeyInfo
XMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(Element element, String idAttrName, String certAlias) throws XMLSignatureException
element
- XML dom document whose signature to be verifiedidAttrName
- Attribute name for the id attributecertAlias
- alias for Signer's certificate, this is used to search
signer's public certificate if it is not presented in
ds:KeyInfo
.XMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(String XML) throws XMLSignatureException
XML
- XML string whose signature to be verifiedXMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(String XML, String certAlias) throws XMLSignatureException
XML
- XML string whose signature to be verifiedcertAlias
- alias for Signer's certificate, this is used to search
signer's public certificate if it is not presented in
ds:KeyInfo
/XMLSignatureException
- if problem occurs during verificationpublic boolean verifyXMLSignature(String xmlString, String idAttrName, String certAlias) throws XMLSignatureException
xmlString
- XML string whose signature to be verifiedidAttrName
- Attribute name for the id attributecertAlias
- certAlias
for Signer's certificate,
this is used to search signer's public certificate if it is not
presented in ds:KeyInfo
.XMLSignatureException
- if problem occurs during verification.public boolean verifyXMLSignature(String wsfVersion, String certAlias, Document document) throws XMLSignatureException
wsfVersion
- the web services version that should be used.certAlias
- alias for Signer's certificate, this is used to search
signer's public certificate if it is not presented in
ds:KeyInfo
.document
- XML dom document whose signature to be verifiedXMLSignatureException
- if problem occurs during verification.public boolean verifyWSSSignature(Document document, String certAlias) throws XMLSignatureException
document
- XML dom document whose signature to be verifiedcertAlias
- alias for Signer's certificate, this is used to search
signer's public certificate if it is not presented in
ds:KeyInfo
.XMLSignatureException
- if problem occurs during verificationpublic boolean verifyWSSSignature(Document document, Key key) throws XMLSignatureException
document
- the document to be validatedkey
- the secret key to be used for validating signatureXMLSignatureException
public boolean verifyWSSSignature(Document document, Key key, String certAlias, String encryptAlias) throws XMLSignatureException
document
- the document to be validatedkey
- the secret key to be used for validating signaturecertAlias
- the certificate alias used for validating the signature
if the key is not available.encryptAlias
- the certificate alias that may be used to decrypt
the symmetric key that may be part of KeyInfo
XMLSignatureException
public KeyProvider getKeyProvider()
KeyProvider
KeyProvider
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.