Class XmlDSigGen
- All Implemented Interfaces:
AutoCloseable
Create XML Digital Signatures with precise control over references, transforms, keys, and placement.
Chilkat.XmlDSigGen creates XML Digital Signatures for
same-document XML, external XML, text, binary, file, and
Object-based references. It supports enveloped, enveloping, and
detached-style signing workflows; X.509 certificate KeyInfo;
custom KeyInfo XML; RSA, DSA, and ECDSA private keys; HMAC
signatures; canonicalization options; reference transforms; signature
insertion placement; timestamp authority settings; and compatibility options
for systems with strict or unusual XML signature requirements.
Same-document signatures
Sign XML already present in the document, including enveloped signatures where the signature is inserted into the signed XML.
External references
Add references to external XML, text, binary data, files, or custom application-provided content.
Object and enveloping signatures
Build signatures that include signed data inside XML
Object elements or produce enveloping signature structures.
Keys and KeyInfo
Sign with private keys or HMAC secrets and include certificate-based,
public-key, or fully custom KeyInfo XML.
Canonicalization and transforms
Configure canonicalization, digest algorithms, signature algorithms, and reference transforms required by the receiving system.
Placement and compatibility
Control where the signature is inserted and enable compatibility behaviors for XML signature profiles with special formatting rules.
Common pattern:
Configure the signature algorithm, canonicalization method, signing key or
certificate, and KeyInfo style; add one or more references with
the required transforms and digest methods; choose where the signature should
be placed; then generate the signed XML. Use
Chilkat.XmlDSigGen to create signatures and
Chilkat.XmlDSig to inspect or verify them.
For an extended overview, see XmlDSigGen Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEnvelopedRef(String id, StringBuilder content, String digestMethod, String canonMethod, String refType)Specifies an enveloped Reference to be added to the Signature when generated.voidaddExternalBinaryRef(String uri, BinData content, String digestMethod, String refType)Specifies an external non-XML binary data Reference to be added to the Signature when generated.voidaddExternalFileRef(String uri, String localFilePath, String digestMethod, String refType)Specifies an external file Reference to be added to the Signature when generated.voidaddExternalTextRef(String uri, StringBuilder content, String charset, boolean includeBom, String digestMethod, String refType)Specifies an external non-XML text data Reference to be added to the Signature when generated.voidaddExternalXmlRef(String uri, StringBuilder content, String digestMethod, String canonMethod, String refType)Specifies an external XML Reference to be added to the Signature when generated.voidSpecifies an Object to be added to the Signature.voidaddObjectRef(String id, String digestMethod, String canonMethod, String prefixList, String refType)This is the same as the AddSameDocRef method, except the reference is to content within an Object previously added via the AddObject method.voidaddObjectRef2(String id, String digestMethod, Xml transforms, String refType)This method is the same as AddObjectRef, except it allows the Transforms to be specified exactly with a fragment of XML.voidaddSameDocRef(String id, String digestMethod, String canonMethod, String prefixList, String refType)Specifies a same document Reference to be added to the Signature when generated.voidaddSameDocRef2(String id, String digestMethod, Xml transforms, String refType)This method is the same as AddSameDocRef, except it allows the Transforms to be specified exactly with a fragment of XML.voidaddSignatureNamespace(String nsPrefix, String nsUri)Can be called one or more times to add additional namespaces to the Signature element.constructSignedInfo(StringBuilder sbXml)This method will construct and return the canonicalized SignedInfo XML.createXmlDSig(String inXml)Creates an XML Digital Signature.voidcreateXmlDSigSb(StringBuilder sbXml)Creates an XML Digital Signature.A comma-separated list of keywords to specify special behaviors to work around potential oddities or special requirements needed for providing signatures to particular systems.Specifies custom XML to be inserted in the KeyInfo element of the Signature.The namespace prefix to use for InclusiveNamespaces elements.The namespace URI for any InclusiveNamespaces elements that are created.If set, causes the generated KeyInfo element to include an Id attribute with this value.Specifies the KeyName to be inserted in the KeyInfo element of the Signature if the KeyInfoType equalsKeyName.Specifies the type of information that will be included in the optional KeyInfo element of the Signature.Returns the installed listener, ornull.getSigId()An option Id attribute value for the Signature element.Indicates where the Signature is to be located within the XML that is signed.intInsert the signature at the Nth occurrence of the.getSigLocation()intModifies the placement of the signature at the location specified by SigLocation.The namespace prefix of the Signature that is to be created.The namespace URI of the Signature that is to be created.The canonicalization method to be used for the SignedInfo when creating the XML signature.The digest method to be used for signing the SignedInfo part of the Signature.Optional Id attribute to be added to the SignedInfo element.The inclusive namespace prefix list to be added, if any, when the SignedInfoCanonAlg is equal toEXCL_C14N.Selects the signature algorithm to be used when using an RSA key to sign.An option Id attribute value for the SignatureValue element.This is a catch-all property to be used for uncommon needs.Specifies the kind of X.509 certificate information is provided in the KeyInfo element when the KeyInfoType equalsX509Data.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.voidsetBehaviors(String value)Sets theBehaviorsproperty; seegetBehaviors().voidsetCustomKeyInfoXml(String value)Sets theCustomKeyInfoXmlproperty; seegetCustomKeyInfoXml().voidsetHmacKey(String key, String encoding)Sets the HMAC key to be used if the Signature is to use an HMAC signing algorithm.voidsetHttpObj(Http http)Sets the HTTP object to be used to communicate with OCSP responders, CRL distribution points, or timestamp authority (TSA) servers if needed.voidsetIncNamespacePrefix(String value)Sets theIncNamespacePrefixproperty; seegetIncNamespacePrefix().voidsetIncNamespaceUri(String value)Sets theIncNamespaceUriproperty; seegetIncNamespaceUri().voidsetKeyInfoId(String value)Sets theKeyInfoIdproperty; seegetKeyInfoId().voidsetKeyInfoKeyName(String value)Sets theKeyInfoKeyNameproperty; seegetKeyInfoKeyName().voidsetKeyInfoType(String value)Sets theKeyInfoTypeproperty; seegetKeyInfoType().voidsetPrivateKey(PrivateKey privKey)Sets the private key to be used for creating the XML signature.voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidsetRefIdAttr(String uri_or_id, String value)Sets theIdattribute for a Reference.voidSets theSigIdproperty; seegetSigId().voidsetSigLocation(String value)Sets theSigLocationproperty; seegetSigLocation().voidsetSigLocationIdx(int value)Sets theSigLocationIdxproperty; seegetSigLocationIdx().voidsetSigLocationMod(int value)Sets theSigLocationModproperty; seegetSigLocationMod().voidsetSigNamespacePrefix(String value)Sets theSigNamespacePrefixproperty; seegetSigNamespacePrefix().voidsetSigNamespaceUri(String value)Sets theSigNamespaceUriproperty; seegetSigNamespaceUri().voidsetSignedInfoCanonAlg(String value)Sets theSignedInfoCanonAlgproperty; seegetSignedInfoCanonAlg().voidsetSignedInfoDigestMethod(String value)Sets theSignedInfoDigestMethodproperty; seegetSignedInfoDigestMethod().voidsetSignedInfoId(String value)Sets theSignedInfoIdproperty; seegetSignedInfoId().voidsetSignedInfoPrefixList(String value)Sets theSignedInfoPrefixListproperty; seegetSignedInfoPrefixList().voidsetSigningAlg(String value)Sets theSigningAlgproperty; seegetSigningAlg().voidsetSigValueId(String value)Sets theSigValueIdproperty; seegetSigValueId().voidsetTsa(JsonObject json)Sets the TSA (Timestamp Authority) URL and other related settings for automatically adding an EncapsulatedTimestamp.voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsetX509Cert(Cert cert, boolean usePrivateKey)Specifies the X.509 certificate to be used for the KeyInfo element when the KeyInfoType equalsX509Data.voidsetX509Type(String value)Sets theX509Typeproperty; seegetX509Type().Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
XmlDSigGen
public XmlDSigGen()Creates a newXmlDSigGenobject.
-
-
Method Details
-
getBehaviors
A comma-separated list of keywords to specify special behaviors to work around potential oddities or special requirements needed for providing signatures to particular systems. This is an open-ended property where new behaviors can be implemented depending on the needs encountered by Chilkat customers. The possible behaviors are listed below.- AttributeSortingBug (introduced in v9.5.0.79) Tells Chilkat to produce a signature that duplicates a common XML canonicalization attribute sorting bug found in some XML signature implementations (such as JPK VAT signed XML documents for Polish government, i.e. mf.gov.pl, csioz.gov.pl, crd.gov.pl, etc). See XML Signature Canonicalization Bug for details.
- Base64CrEntity Produce multi-line base64 for XML elements such as SignatureValue and
X509Certificate, with each line ending in a CR hex entity, except for the last line. For example:
<ds:X509Certificate>MIIFNTCCBB2gAwIBAgIQHozVnBl1lTsusAh26u6WZTANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UE
 BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
 A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl
 ... sp3FRlACVeb1Qlytr4vgc5FlCqn0rMtjlF4= </ds:X509Certificate>
- Base64Cr13Entity Produce multi-line base64 for XML elements such as SignatureValue and
X509Certificate, with each line ending in a CR decimal entity, except for the last line. For
example:
<ds:X509Certificate>MIIFNTCCBB2gAwIBAgIQHozVnBl1lTsusAh26u6WZTANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UE BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl ... sp3FRlACVeb1Qlytr4vgc5FlCqn0rMtjlF4= </ds:X509Certificate>
- Base64Multiline Produce multi-line base64 for XML elements such as SignatureValue and
X509Certificate. For example:
<ds:X509Certificate>MIIFNTCCBB2gAwIBAgIQHozVnBl1lTsusAh26u6WZTANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UE BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl ... sp3FRlACVeb1Qlytr4vgc5FlCqn0rMtjlF4= </ds:X509Certificate>
- ForceAddEnvelopedSignatureTransform The
_LT_Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />is normally only added when the Signature is contained within the XML fragment that is signed. The meaning of this tranformation is to tell the verifier to remove the Signature from the data prior to canonicalizing. If the Signature is not contained within the XML fragment that was signed, then the signature was not enveloped. There would be no need to remove the Signature because the Signature is not contained in the XML fragment being verified. However.. some brain-dead verifiying systems require this Transform to be present regardless of whether it makes sense. This behavior will cause Chilkat to add the Transform regardless. - NoEnvelopedSignatureTransform (introduced in v9.5.0.82) Prevents the
_LT_Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />from being added in all cases. - EnvelopedTransformFirst (introduced in v9.5.0.87) Forces the http://www.w3.org/2000/09/xmldsig#enveloped-signature to be listed first when there are multiple transforms for a reference.
- ebXmlTransform (introduced in v9.5.0.73) Causes the following tranform to be added for
ebXml messages:
_LT_Transform Algorithm=
http://www.w3.org/TR/1999/REC-xpath-19991116> _LT_XPath xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/>not(ancestor-or-self::node()[@SOAP-ENV:actor=urn:oasis:names:tc:ebxml-msg:actor:nextMSH] | ancestor-or-self::node()[@SOAP-ENV:actor=http://schemas.xmlsoap.org/soap/actor/next])_LT_/XPath> _LT_/Transform> - TransformSignatureXPath (introduced in v9.5.0.75) Causes the following tranform to be
added:
_LT_ds:Transform Algorithm=
http://www.w3.org/TR/1999/REC-xpath-19991116_GT_ _LT_ds:XPath_GT_not(ancestor-or-self::ds:Signature)_LT_/ds:XPath_GT_ _LT_/ds:Transform_GT_ - CompactSignedXml (introduced in v9.5.0.73) The passed-in XML to be signed is first reformatted to a compact representation by removing all CR's, LF's, and unnecessary whitespace so that the XML to be signed is on a single line. The resulting XML (with signature) is also entirely contained on a single line. (If an XML declarator is present, then it will remain on it's own line.)
- IndentedSignature (introduced in v9.5.0.73) Causes the XML Signature to be produced on multiple lines with indentation for easier human readability. The CompactSignedXml behavior takes precedence over this behavior.
- FullLocalSigningTime (introduced in v9.5.0.76) Causes the signing time to be formatted
like this: 2017-05-20T19:16:05.649+01:00.nnn, where the
.nnnis added to indicate milliseconds. - LocalSigningTime (introduced in v9.5.0.76) Causes the signing time to be formatted using
a local time (with a timezone offset such as
+01:00rather thanZto signify GMT). - NoReplaceSigningTime Don't replace the <SigningTime> content with a timestamp of the current date/time. Instead keep the current value provided by the application.
- NoTimestampBias Exclude the timestamp bias from the generated <SigningTime>
- DnReverseOrder (introduced in v9.5.0.77) Causes DN's (certificate Distinguished Names) to
be written in reverse order. Reverse order leads with
CN, such asCN=..., O=..., OU=..., C=..., whereas normal order ends withCN, such asC=..., OU=..., O=..., CN=... - IssuerSerialHex (introduced in v9.5.0.77) Causes the issuer serial number located in SignedProperties.SignedSignatureProperties.SigningCertificate to be emitted as uppercase hex instead of decimal. (Also, when signing XML for e-dokumenty.mf.gov.pl, Chilkat automatically recognizes it and uses IssuerSerialHex.)
- IssuerSerialHexLower (introduced in v9.5.0.77) Causes the issuer serial number located in SignedProperties.SignedSignatureProperties.SigningCertificate to be emitted as lowercase hex instead of decimal.
- SigningTimeAdjust-_LT_numSeconds_GT_ (introduced in v9.5.0.80) When Chilkat automatically
fills in the value for a SigningTime, it will use the current system date/time. This behavior can be
used to adjust the generate time to numSeconds in the past. For example:
SigningTimeAdjust-60will generate a signing time 60 seconds prior to the current time. - SigningTimeAdjust+_LT_numSeconds_GT_ (introduced in v9.5.0.88) When Chilkat automatically
fills in the value for a SigningTime, it will use the current system date/time. This behavior can be
used to adjust the generate time to numSeconds in the future. For example:
SigningTimeAdjust+60will generate a signing time 60 seconds past the current time. - UBLDocumentSignatures Causes an XPath
ancestor-or-selfTransform to be added for the 1st reference. See the example at UBL XAdES Enveloped Signature - SignExistingSignatures This keyword can be used when applying a 2nd or greater signature
and the new signature will encompass one or more existing signatures. The default behavior is that
existing signatures are not included in the canonicalization/digest before signing. Adding this
keyword will cause existing signatures to be included in the canonicalization/digest.
- Returns:
- the value of the
Behaviorsproperty
-
setBehaviors
Sets theBehaviorsproperty; seegetBehaviors().- Parameters:
value- the new value (notnull)
-
getCustomKeyInfoXml
Specifies custom XML to be inserted in the KeyInfo element of the Signature. A common use is to provide a wsse:SecurityTokenReference fragment of XML.- Returns:
- the value of the
CustomKeyInfoXmlproperty
-
setCustomKeyInfoXml
Sets theCustomKeyInfoXmlproperty; seegetCustomKeyInfoXml().- Parameters:
value- the new value (notnull)
-
getIncNamespacePrefix
The namespace prefix to use for InclusiveNamespaces elements. The default value isec. Set this property to the empty string to omit an InclusiveNamespaces prefix. For example, given the default values of IncNamespaceUri and IncNamespacePrefix, generated InclusiveNamespaces elements will appear like this:<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"> ... </ec:InclusiveNamespaces>
- Returns:
- the value of the
IncNamespacePrefixproperty
-
setIncNamespacePrefix
Sets theIncNamespacePrefixproperty; seegetIncNamespacePrefix().- Parameters:
value- the new value (notnull)
-
getIncNamespaceUri
The namespace URI for any InclusiveNamespaces elements that are created. The default value ishttp://www.w3.org/2001/10/xml-exc-c14n#. For example, if the IncNamespacePrefix equalsecand this property remains at the default value, then the generated Signature element will be:<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"> ... </ec:InclusiveNamespaces>
- Returns:
- the value of the
IncNamespaceUriproperty
-
setIncNamespaceUri
Sets theIncNamespaceUriproperty; seegetIncNamespaceUri().- Parameters:
value- the new value (notnull)
-
getKeyInfoId
If set, causes the generated KeyInfo element to include an Id attribute with this value. For example:... _LT_ds:KeyInfo Id="KeyInfo"_GT_ _LT_ds:X509Data_GT_ _LT_ds:X509SubjectName_GT_CERTIFICADO DE ABC_LT_/ds:X509SubjectName_GT_ _LT_ds:X509Certificate_GT_MIIITTCC....fIsIZeZOeQ=_LT_/ds:X509Certificate_GT_ _LT_/ds:X509Data_GT_ _LT_/ds:KeyInfo_GT_ ...- Returns:
- the value of the
KeyInfoIdproperty
-
setKeyInfoId
Sets theKeyInfoIdproperty; seegetKeyInfoId().- Parameters:
value- the new value (notnull)
-
getKeyInfoKeyName
Specifies the KeyName to be inserted in the KeyInfo element of the Signature if the KeyInfoType equalsKeyName.- Returns:
- the value of the
KeyInfoKeyNameproperty
-
setKeyInfoKeyName
Sets theKeyInfoKeyNameproperty; seegetKeyInfoKeyName().- Parameters:
value- the new value (notnull)
-
getKeyInfoType
Specifies the type of information that will be included in the optional KeyInfo element of the Signature. Possible values are:- None
- KeyName
- KeyValue
- X509Data
- X509Data+KeyValue
- Custom
The default value is
KeyValue. TheX509Data+KeyValueoption was added in Chilkat v9.5.0.73.If None, then no KeyInfo element is added to the Signature when generated.
If KeyValue, then the KeyInfo will contain the public key (RSA, DSA, or ECDSA).
If X509Data, then the KeyInfo will contain information about an X.509 certificate as specified by the X509Type property.
If Custom, then the KeyInfo will contain the custom XML contained in the CustomKeyInfoXml property.
- Returns:
- the value of the
KeyInfoTypeproperty
-
setKeyInfoType
Sets theKeyInfoTypeproperty; seegetKeyInfoType().- Parameters:
value- the new value (notnull)
-
getSigId
An option Id attribute value for the Signature element. The default value is the empty string, which generates a Signature element with no Id attribute. For example:<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
If this property is set to "abc123", then the Signature element would be generated like this:
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="abc123">
- Returns:
- the value of the
SigIdproperty
-
setSigId
Sets theSigIdproperty; seegetSigId().- Parameters:
value- the new value (notnull)
-
getSigLocation
Indicates where the Signature is to be located within the XML that is signed. This is a path to the position in the XML where the Signature will be inserted, using Chilkat path syntax (using vertical bar characters to delimit tag names. If the Signature element is to be the root of XML document, then set this property equal to the empty string.For example, if we have the following SOAP XML and wish to insert the Signature at the indicated location, then the SigLocation property should be set to
SOAP-ENV:Envelope|SOAP-ENV:Header|wsse:Security.<?xml version="1.0" encoding="UTF-8" standalone="no"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1"> ** The XML Signature is to be inserted here ** </wsse:Security> </SOAP-ENV:Header> ... </SOAP-ENV:Envelope>- Returns:
- the value of the
SigLocationproperty
-
setSigLocation
Sets theSigLocationproperty; seegetSigLocation().- Parameters:
value- the new value (notnull)
-
getSigLocationIdx
public int getSigLocationIdx()Insert the signature at the Nth occurrence of the. The default isgetSigLocation()0, which is to insert (according to) at the 1st occurrence. (An index value of 1 is for the 2nd occurrence, and so on.)getSigLocationMod()- Returns:
- the value of the
SigLocationIdxproperty
-
setSigLocationIdx
public void setSigLocationIdx(int value)Sets theSigLocationIdxproperty; seegetSigLocationIdx().- Parameters:
value- the new value
-
getSigLocationMod
public int getSigLocationMod()Modifies the placement of the signature at the location specified by SigLocation. Possible values are:- 0: Insert the Signature as the last child of the element at SigLocation. This is the default.
- 1: Insert the Signature as a sibling directly after the element at SigLocation.
- 2: Insert the Signature as a sibling directly before the element at SigLocation.
- Returns:
- the value of the
SigLocationModproperty
-
setSigLocationMod
public void setSigLocationMod(int value)Sets theSigLocationModproperty; seegetSigLocationMod().- Parameters:
value- the new value
-
getSigNamespacePrefix
The namespace prefix of the Signature that is to be created. The default value isds. Set this property to the empty string to omit a Signature namespace URI and prefix. For example, given the default values of SigNamespaceUri and SigNamespacePrefix, the generated Signature element will be:<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> ... </ds:Signature>
- Returns:
- the value of the
SigNamespacePrefixproperty
-
setSigNamespacePrefix
Sets theSigNamespacePrefixproperty; seegetSigNamespacePrefix().- Parameters:
value- the new value (notnull)
-
getSigNamespaceUri
The namespace URI of the Signature that is to be created. The default value ishttp://www.w3.org/2000/09/xmldsig#. For example, if the SigNamespacePrefix equalsdsand this property remains at the default value, then the generated Signature element will be:<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> ... </ds:Signature>
- Returns:
- the value of the
SigNamespaceUriproperty
-
setSigNamespaceUri
Sets theSigNamespaceUriproperty; seegetSigNamespaceUri().- Parameters:
value- the new value (notnull)
-
getSigValueId
An option Id attribute value for the SignatureValue element. The default value is the empty string, which generates a SignatureValue element with no Id attribute. For example:_LT_ds:SignatureValue_GT_
If this property is set to "value-id-7d4a", then the Signature element would be generated like this:
_LT_ds:SignatureValue Id="value-id-7d4a"_GT_
- Returns:
- the value of the
SigValueIdproperty
-
setSigValueId
Sets theSigValueIdproperty; seegetSigValueId().- Parameters:
value- the new value (notnull)
-
getSignedInfoCanonAlg
The canonicalization method to be used for the SignedInfo when creating the XML signature.C14N-- for Inclusive Canonical XML (without comments)C14N_11-- for Inclusive Canonical XML 1.1 (without comments)EXCL_C14N-- for Exclusive Canonical XML (without comments)C14N_WithComments-- for Inclusive Canonical XML (with comments)C14N_11_WithComments-- for Inclusive Canonical XML 1.1 (with comments)EXCL_C14N_WithComments-- for Exclusive Canonical XML (with comments)- Note: The WithComments options are available in Chilkat v9.5.0.71 and later.
The default value is
EXCL_C14N.- Returns:
- the value of the
SignedInfoCanonAlgproperty
-
setSignedInfoCanonAlg
Sets theSignedInfoCanonAlgproperty; seegetSignedInfoCanonAlg().- Parameters:
value- the new value (notnull)
-
getSignedInfoDigestMethod
The digest method to be used for signing the SignedInfo part of the Signature. Possible values aresha1,sha256,sha384, andsha512. The default issha256.- Returns:
- the value of the
SignedInfoDigestMethodproperty
-
setSignedInfoDigestMethod
Sets theSignedInfoDigestMethodproperty; seegetSignedInfoDigestMethod().- Parameters:
value- the new value (notnull)
-
getSignedInfoId
Optional Id attribute to be added to the SignedInfo element. The default value is the empty string, meaning that the SignedInfo is generated without an Id attribute.- Returns:
- the value of the
SignedInfoIdproperty
-
setSignedInfoId
Sets theSignedInfoIdproperty; seegetSignedInfoId().- Parameters:
value- the new value (notnull)
-
getSignedInfoPrefixList
The inclusive namespace prefix list to be added, if any, when the SignedInfoCanonAlg is equal toEXCL_C14N. The defautl value is the empty string. If namespaces are listed, they are separated by space characters.If, for example, this property is set to
wsse SOAP-ENV, then the CanonicalizationMethod part of the SignedInfo that is generated would look like this:<ds:SignedInfo> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse SOAP-ENV" /> </ds:CanonicalizationMethod> ... </ds:SignedInfo>- Returns:
- the value of the
SignedInfoPrefixListproperty
-
setSignedInfoPrefixList
Sets theSignedInfoPrefixListproperty; seegetSignedInfoPrefixList().- Parameters:
value- the new value (notnull)
-
getSigningAlg
Selects the signature algorithm to be used when using an RSA key to sign. The default value isPKCS1-v1_5. This can be set toRSASSA-PSS(or simplypss) to use the RSASSA-PSS signature scheme.Note: This property only applies when signing with an RSA private key. It does not apply for ECC or DSA private keys.
- Returns:
- the value of the
SigningAlgproperty
-
setSigningAlg
Sets theSigningAlgproperty; seegetSigningAlg().- Parameters:
value- the new value (notnull)
-
getUncommonOptions
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string, and should typically remain empty.- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
getX509Type
Specifies the kind of X.509 certificate information is provided in the KeyInfo element when the KeyInfoType equalsX509Data. Possible values are:- Certificate
- CertChain
- IssuerSerial
- SubjectName
- SKI
The default value is
Certificate.Note: This property can be set to a comma-separated list of the keywords above. For example, If set to
SubjectName,Certificate, then both the X509SubjectName and X509Certificate parts will be added to the KeyInfo.If Certificate, then the KeyInfo will contain the base64 encoded X.509v3 certificate.
If CertChain, then the KeyInfo will contain the base64 encoded X.509v3 certificate as well as any certificates available in the chain of authentication to the root cert.
If IssuerSerial, then the KeyInfo will contain the X.509 issuer's distinguished name and the signing certificate's serial number.
If SubjectName, then the KeyInfo will contain the X.509 subject distinguished name.
If SKI, then the KeyInfo will contain the base64 encoded value of the cert's X.509 SubjectKeyIdentifier extension.
- Returns:
- the value of the
X509Typeproperty
-
setX509Type
Sets theX509Typeproperty; seegetX509Type().- Parameters:
value- the new value (notnull)
-
addEnvelopedRef
public void addEnvelopedRef(String id, StringBuilder content, String digestMethod, String canonMethod, String refType)Specifies an enveloped Reference to be added to the Signature when generated. An enveloped Reference is for data contained within the Signature. (The Signature is to be an enveloping signature, and the data is enveloped by the Signature.)The
idis the value of the Id attribute of the Object element that is to be contained within the generated Signature. Thecontentis the text content to be contained in the Object. Binary data can be signed by passing the bytes incontentin an encoded format (such as base64 or hex).The
digestMethodis the digest method and can be one of the following:sha1,sha256,sha384,sha512,ripemd160, ormd5.The
canonMethodis the canonicalization method, and can be one of the following.C14N-- for Inclusive Canonical XML (without comments)C14N_11-- for Inclusive Canonical XML 1.1 (without comments)EXCL_C14N-- for Exclusive Canonical XML (without comments)C14N_WithComments-- for Inclusive Canonical XML (with comments)C14N_11_WithComments-- for Inclusive Canonical XML 1.1 (with comments)EXCL_C14N_WithComments-- for Exclusive Canonical XML (with comments)- Note: The WithComments options are available in Chilkat v9.5.0.71 and later.
The
refTypeis optional and is usually not needed. Set this to the empty string unless it is desired to add a Type attribute to the Reference that is advisory only.- Parameters:
id- theidargument (notnull)content- thecontentargument (notnull)digestMethod- thedigestMethodargument (notnull)canonMethod- thecanonMethodargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addExternalBinaryRef
Specifies an external non-XML binary data Reference to be added to the Signature when generated.The
uriis the value of the URI attribute of the Reference.The
contentcontains the binary data to be digested according to thedigestMethod.The
digestMethodis the digest method and can be one of the following:sha1,sha256,sha384,sha512,ripemd160, ormd5.The
refTypeis optional and is usually not needed. Set this to the empty string unless it is desired to add a Type attribute to the Reference that is advisory only.- Parameters:
uri- theuriargument (notnull)content- thecontentargument (notnull)digestMethod- thedigestMethodargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addExternalFileRef
public void addExternalFileRef(String uri, String localFilePath, String digestMethod, String refType)Specifies an external file Reference to be added to the Signature when generated.The
uriis the value of the URI attribute of the Reference. It can (and likely will) be different than thelocalFilePathwhich is the path to the local file to be added. (The local file is not read until the XML digital signature is actually created.)The
digestMethodis the digest method and can be one of the following:sha1,sha256,sha384,sha512,ripemd160, ormd5.The
refTypeis optional and is usually not needed. Set this to the empty string unless it is desired to add a Type attribute to the Reference that is advisory only.- Parameters:
uri- theuriargument (notnull)localFilePath- thelocalFilePathargument (notnull)digestMethod- thedigestMethodargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addExternalTextRef
public void addExternalTextRef(String uri, StringBuilder content, String charset, boolean includeBom, String digestMethod, String refType)Specifies an external non-XML text data Reference to be added to the Signature when generated.The
uriis the value of the URI attribute of the Reference.The
contentcontains the non-XML data to be digested according to thecharset. Thecharsetspecifies the charset (such asutf-8,windows-1252, etc.) for the byte reprsentation of the text to be digested. TheincludeBomindicates whether the BOM (Byte Order Mark, also known as the preamble) is included in the byte representation that is digested.The
digestMethodis the digest method and can be one of the following:sha1,sha256,sha384,sha512,ripemd160, ormd5.The
refTypeis optional and is usually not needed. Set this to the empty string unless it is desired to add a Type attribute to the Reference that is advisory only.- Parameters:
uri- theuriargument (notnull)content- thecontentargument (notnull)charset- thecharsetargument (notnull)includeBom- theincludeBomargumentdigestMethod- thedigestMethodargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addExternalXmlRef
public void addExternalXmlRef(String uri, StringBuilder content, String digestMethod, String canonMethod, String refType)Specifies an external XML Reference to be added to the Signature when generated.The
uriis the value of the URI attribute of the Reference.The
contentcontains the XML document to be referenced.The
digestMethodis the digest method and can be one of the following:sha1,sha256,sha384,sha512,ripemd160, ormd5.The
canonMethodis the canonicalization method, and can be one of the following.C14N-- for Inclusive Canonical XML (without comments)C14N_11-- for Inclusive Canonical XML 1.1 (without comments)EXCL_C14N-- for Exclusive Canonical XML (without comments)C14N_WithComments-- for Inclusive Canonical XML (with comments)C14N_11_WithComments-- for Inclusive Canonical XML 1.1 (with comments)EXCL_C14N_WithComments-- for Exclusive Canonical XML (with comments)-- An empty string indicates that no transformation should be included / applied for this reference.- Note: The WithComments options are available in Chilkat v9.5.0.71 and later.
- Note: The empty-string canonMethod is available in Chilkat v9.5.0.75 and later.
The
refTypeis optional and is usually not needed. Set this to the empty string unless it is desired to add a Type attribute to the Reference that is advisory only.- Parameters:
uri- theuriargument (notnull)content- thecontentargument (notnull)digestMethod- thedigestMethodargument (notnull)canonMethod- thecanonMethodargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addObject
Specifies an Object to be added to the Signature.- The
idis the value of the Object element's Id attribute. - The
contentcontains the content of the Object element, which may be XML or plain text. - The
mimeTypeis the value of the Object element's MimeType attribute - The
encodingis the value of the Object element's Encoding attribute
In most cases, the
mimeTypeandencodingare empty strings which cause the MimeType and Encoding attributes to be omitted.- Parameters:
id- theidargument (notnull)content- thecontentargument (notnull)mimeType- themimeTypeargument (notnull)encoding- theencodingargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- The
-
addObjectRef
public void addObjectRef(String id, String digestMethod, String canonMethod, String prefixList, String refType)This is the same as the AddSameDocRef method, except the reference is to content within an Object previously added via the AddObject method. Theidmust be an Id equal to the Id attribute of an Object, or the Id attribute of an element within the Object.Note: The
canonMethodcan be set toBase64to use the http://www.w3.org/2000/09/xmldsig#base64 transform.- Parameters:
id- theidargument (notnull)digestMethod- thedigestMethodargument (notnull)canonMethod- thecanonMethodargument (notnull)prefixList- theprefixListargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addObjectRef2
This method is the same as AddObjectRef, except it allows the Transforms to be specified exactly with a fragment of XML. See the example below.- Parameters:
id- theidargument (notnull)digestMethod- thedigestMethodargument (notnull)transforms- thetransformsargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addSameDocRef
public void addSameDocRef(String id, String digestMethod, String canonMethod, String prefixList, String refType)Specifies a same document Reference to be added to the Signature when generated. A same document Reference can be the entire XML document, or a fragment of the XML document.The
idcan be the empty string to sign the entire XML document, or it can be the fragment identifier to sign a portion of the XML document.The
digestMethodis the digest method and can be one of the following:sha1,sha256,sha384,sha512,ripemd160, ormd5.The
canonMethodis the canonicalization method, and can be one of the following:C14N-- for Inclusive Canonical XML (without comments)C14N_11-- for Inclusive Canonical XML 1.1 (without comments)EXCL_C14N-- for Exclusive Canonical XML (without comments)C14N_WithComments-- for Inclusive Canonical XML (with comments)C14N_11_WithComments-- for Inclusive Canonical XML 1.1 (with comments)EXCL_C14N_WithComments-- for Exclusive Canonical XML (with comments)-- An empty string indicates that no transformation should be included / applied for this reference.- Note: The WithComments options are available in Chilkat v9.5.0.71 and later.
- Note: The empty-string canonMethod is available in Chilkat v9.5.0.75 and later.
If exclusive canonicalization is selected, then the
prefixListcan contain a space separated list of inclusive namespace prefixes. For inclusive canonicalization, this argument is ignored. In general, pass an empty string for this argument unless you have specific knowledge of namespace prefixes that need to be treated as inclusive when EXCL_C14N is used.Starting in Chilkat v9.5.0.70, the
prefixListcan be set to the keyword_EMPTY_to force the generation of an empty PrefixList under the Transform. For example:<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/> </ds:Transform>The
refTypeis optional and is usually not needed. Set this to the empty string unless it is desired to add a Type attribute to the Reference that is advisory only.- Parameters:
id- theidargument (notnull)digestMethod- thedigestMethodargument (notnull)canonMethod- thecanonMethodargument (notnull)prefixList- theprefixListargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addSameDocRef2
This method is the same as AddSameDocRef, except it allows the Transforms to be specified exactly with a fragment of XML. See the example below.- Parameters:
id- theidargument (notnull)digestMethod- thedigestMethodargument (notnull)transforms- thetransformsargument (notnull)refType- therefTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addSignatureNamespace
Can be called one or more times to add additional namespaces to the Signature element.- Parameters:
nsPrefix- thensPrefixargument (notnull)nsUri- thensUriargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
constructSignedInfo
This method will construct and return the canonicalized SignedInfo XML. The digests of each Reference are computed and included in the SignedInfo. This method is provided for certain special circumstances where one wants to get the exact canonicalized SignedInfo that would be signed using the private key.Note: Properties such as SigLocation, SigningAlg, etc. and references must be set exactly as if an XML signature was to be actually generated because they determine the content of the SignedInfo.
Note, the
sbXmlis not signed by this method. It is not modified.- Parameters:
sbXml- thesbXmlargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
createXmlDSig
Creates an XML Digital Signature. The application passes in the XML to be signed, and the signed XML is returned. If creating an enveloping signature where the Signature element is the root, then theinXmlmay be the empty string.- Chilkat v9.5.0.76 or greater is required for XML signatures for www.csioz.gov.pl
- Parameters:
inXml- theinXmlargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Chilkat v9.5.0.76 or greater is required for XML signatures for www.csioz.gov.pl
-
createXmlDSigSb
Creates an XML Digital Signature. The application passes the XML to be signed insbXml, and it is replaced with the signed XML if successful. (Thus,sbXmlis both an input and output argument.) Note: If creating an enveloping signature where the Signature element is to be the root element, then the passed-insbXmlmay be empty.- Parameters:
sbXml- thesbXmlargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setHmacKey
Sets the HMAC key to be used if the Signature is to use an HMAC signing algorithm. Theencodingspecifies the encoding ofkey, and can behex,base64,ascii, or any of the binary encodings supported by Chilkat in the link below.- Parameters:
key- thekeyargument (notnull)encoding- theencodingargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setHttpObj
Sets the HTTP object to be used to communicate with OCSP responders, CRL distribution points, or timestamp authority (TSA) servers if needed. Thehttpis used to send the requests, and it allows for connection related settings and timeouts to be set. For example, if HTTP or SOCKS proxies are required, these features can be specified on thehttp.- Parameters:
http- thehttpargument (notnull)
-
setPrivateKey
Sets the private key to be used for creating the XML signature. The private key may be an RSA key, a DSA key, or an ECDSA key.- Parameters:
privKey- theprivKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setRefIdAttr
Sets theIdattribute for a Reference.- Parameters:
uri_or_id- theuri_or_idargument (notnull)value- thevalueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setTsa
Sets the TSA (Timestamp Authority) URL and other related settings for automatically adding an EncapsulatedTimestamp.- Parameters:
json- thejsonargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setX509Cert
Specifies the X.509 certificate to be used for the KeyInfo element when the KeyInfoType equalsX509Data. IfusePrivateKeyistrue, then the private key will also be set using the certificate's private key. Thus, the SetPrivateKey method does not need to be called. IfusePrivateKeyistrue, and the certificate does not have an associated private key available, then this method will returnfalse.Note: A certificate's private key is not stored within a certificate itself. If the certificate (
cert) was obtained from a PFX, Java KeyStore, or other such source, which are containers for both certs and private keys, then Chilkat would have associated the cert with the private key when loading the PFX or JKS, and all is good. The same holds true if, on a Windows system, the certificate was obtained from a Windows-based registry certificate store where the private key was installed with the permission to export.If, however, the certificate was loaded from a .cer file, or another type of file that contains only the certificate and not the private key, then the associated private key needs to be obtained by the application and provided by calling SetPrivateKey.
- Parameters:
cert- thecertargument (notnull)usePrivateKey- theusePrivateKeyargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-