---
product: Chilkat
product_version: 11.7.0
language: ckjava
language_label: Java
class: XmlDSigGen
class_name: CkXmlDSigGen
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/javaCkXmlDSigGenRef.html
---
# Chilkat XmlDSigGen — Java — v11.7.0

> Chilkat 11.7.0 · language=ckjava · class=XmlDSigGen (CkXmlDSigGen)
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/XmlDSigGen.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/guide.md`.

## Purpose

**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](https://www.chilkatsoft.com/xmldsiggen_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

```java
CkXmlDSigGen obj = new CkXmlDSigGen();
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Java.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `void get_DebugLogFilePath(CkString str); String debugLogFilePath(); void put_DebugLogFilePath(String newVal);` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `void get_LastErrorHtml(CkString str); String lastErrorHtml();` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void get_LastErrorText(CkString str); String lastErrorText();` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void get_LastErrorXml(CkString str); String lastErrorXml();` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `boolean get_LastMethodSuccess(); void put_LastMethodSuccess(boolean newVal);` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `boolean get_VerboseLogging(); void put_VerboseLogging(boolean newVal);` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void get_Version(CkString str); String version();` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Behaviors` | property, read/write | `void get_Behaviors(CkString str); String behaviors(); void put_Behaviors(String newVal);` |
| `CustomKeyInfoXml` | property, read/write | `void get_CustomKeyInfoXml(CkString str); String customKeyInfoXml(); void put_CustomKeyInfoXml(String newVal);` |
| `IncNamespacePrefix` | property, read/write | `void get_IncNamespacePrefix(CkString str); String incNamespacePrefix(); void put_IncNamespacePrefix(String newVal);` |
| `IncNamespaceUri` | property, read/write | `void get_IncNamespaceUri(CkString str); String incNamespaceUri(); void put_IncNamespaceUri(String newVal);` |
| `KeyInfoId` | property, read/write | `void get_KeyInfoId(CkString str); String keyInfoId(); void put_KeyInfoId(String newVal);` |
| `KeyInfoKeyName` | property, read/write | `void get_KeyInfoKeyName(CkString str); String keyInfoKeyName(); void put_KeyInfoKeyName(String newVal);` |
| `KeyInfoType` | property, read/write | `void get_KeyInfoType(CkString str); String keyInfoType(); void put_KeyInfoType(String newVal);` |
| `SigId` | property, read/write | `void get_SigId(CkString str); String sigId(); void put_SigId(String newVal);` |
| `SigLocation` | property, read/write | `void get_SigLocation(CkString str); String sigLocation(); void put_SigLocation(String newVal);` |
| `SigLocationIdx` | property, read/write | `int get_SigLocationIdx(); void put_SigLocationIdx(int newVal);` |
| `SigLocationMod` | property, read/write | `int get_SigLocationMod(); void put_SigLocationMod(int newVal);` |
| `SigNamespacePrefix` | property, read/write | `void get_SigNamespacePrefix(CkString str); String sigNamespacePrefix(); void put_SigNamespacePrefix(String newVal);` |
| `SigNamespaceUri` | property, read/write | `void get_SigNamespaceUri(CkString str); String sigNamespaceUri(); void put_SigNamespaceUri(String newVal);` |
| `SignedInfoCanonAlg` | property, read/write | `void get_SignedInfoCanonAlg(CkString str); String signedInfoCanonAlg(); void put_SignedInfoCanonAlg(String newVal);` |
| `SignedInfoDigestMethod` | property, read/write | `void get_SignedInfoDigestMethod(CkString str); String signedInfoDigestMethod(); void put_SignedInfoDigestMethod(String newVal);` |
| `SignedInfoId` | property, read/write | `void get_SignedInfoId(CkString str); String signedInfoId(); void put_SignedInfoId(String newVal);` |
| `SignedInfoPrefixList` | property, read/write | `void get_SignedInfoPrefixList(CkString str); String signedInfoPrefixList(); void put_SignedInfoPrefixList(String newVal);` |
| `SigningAlg` | property, read/write | `void get_SigningAlg(CkString str); String signingAlg(); void put_SigningAlg(String newVal);` |
| `SigValueId` | property, read/write | `void get_SigValueId(CkString str); String sigValueId(); void put_SigValueId(String newVal);` |
| `UncommonOptions` | property, read/write | `void get_UncommonOptions(CkString str); String uncommonOptions(); void put_UncommonOptions(String newVal);` |
| `X509Type` | property, read/write | `void get_X509Type(CkString str); String x509Type(); void put_X509Type(String newVal);` |
| `AddEnvelopedRef` | method | `boolean AddEnvelopedRef(String id, CkStringBuilder content, String digestMethod, String canonMethod, String refType);` |
| `AddExternalBinaryRef` | method | `boolean AddExternalBinaryRef(String uri, CkBinData content, String digestMethod, String refType);` |
| `AddExternalFileRef` | method | `boolean AddExternalFileRef(String uri, String localFilePath, String digestMethod, String refType);` |
| `AddExternalTextRef` | method | `boolean AddExternalTextRef(String uri, CkStringBuilder content, String charset, boolean includeBom, String digestMethod, String refType);` |
| `AddExternalXmlRef` | method | `boolean AddExternalXmlRef(String uri, CkStringBuilder content, String digestMethod, String canonMethod, String refType);` |
| `AddObject` | method | `boolean AddObject(String id, String content, String mimeType, String encoding);` |
| `AddObjectRef` | method | `boolean AddObjectRef(String id, String digestMethod, String canonMethod, String prefixList, String refType);` |
| `AddObjectRef2` | method | `boolean AddObjectRef2(String id, String digestMethod, CkXml transforms, String refType);` |
| `AddSameDocRef` | method | `boolean AddSameDocRef(String id, String digestMethod, String canonMethod, String prefixList, String refType);` |
| `AddSameDocRef2` | method | `boolean AddSameDocRef2(String id, String digestMethod, CkXml transforms, String refType);` |
| `AddSignatureNamespace` | method | `boolean AddSignatureNamespace(String nsPrefix, String nsUri);` |
| `ConstructSignedInfo` | method | `boolean ConstructSignedInfo(CkStringBuilder sbXml, CkString outStr); String constructSignedInfo(CkStringBuilder sbXml);` |
| `CreateXmlDSig` | method | `boolean CreateXmlDSig(String inXml, CkString outStr); String createXmlDSig(String inXml);` |
| `CreateXmlDSigSb` | method | `boolean CreateXmlDSigSb(CkStringBuilder sbXml);` |
| `SetHmacKey` | method | `boolean SetHmacKey(String key, String encoding);` |
| `SetHttpObj` | method | `void SetHttpObj(CkHttp http);` |
| `SetPrivateKey` | method | `boolean SetPrivateKey(CkPrivateKey privKey);` |
| `SetRefIdAttr` | method | `boolean SetRefIdAttr(String uri_or_id, String value);` |
| `SetTsa` | method | `boolean SetTsa(CkJsonObject json);` |
| `SetX509Cert` | method | `boolean SetX509Cert(CkCert cert, boolean usePrivateKey);` |

## Properties

### XmlDSigGen.Behaviors

`Chilkat 11.7.0 · ckjava · XmlDSigGen · Behaviors · property · read/write · since 9.5.0.70`

```java
void get_Behaviors(CkString str);

String behaviors();

void put_Behaviors(String newVal);
```

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](http://cknotes.com/xml-signature-canonicalization-bug-in-widely-used-software/) 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&#xD;
  BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG&#xD;
  A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl&#xD;
  ...
  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&#13;
  BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG&#13;
  A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl&#13;
  ...
  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 `<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 `<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:

  ```
  <Transform Algorithm=http://www.w3.org/TR/1999/REC-xpath-19991116>
      <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])</XPath>
  </Transform>
  ```

- **TransformSignatureXPath** (introduced in v9.5.0.75) Causes the following tranform to be added:

  ```
  <ds:Transform Algorithm=http://www.w3.org/TR/1999/REC-xpath-19991116>
     <ds:XPath>not(ancestor-or-self::ds:Signature)</ds:XPath>
  </ds:Transform>
  ```

- **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 `.nnn` is 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:00` rather than `Z` to 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 as `CN=..., O=..., OU=..., C=...`, whereas normal order ends with `CN`, such as `C=..., 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-\<numSeconds>** (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-60` will generate a signing time 60 seconds prior to the current time.

- **SigningTimeAdjust+\<numSeconds>** (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+60` will generate a signing time 60 seconds past the current time.

- **UBLDocumentSignatures** Causes an XPath `ancestor-or-self` Transform to be added for the 1st reference. See the example at [UBL XAdES Enveloped Signature](https://www.example-code.com/csharp/ubl_xades_enveloped_signature.asp)

- **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.

### XmlDSigGen.CustomKeyInfoXml

`Chilkat 11.7.0 · ckjava · XmlDSigGen · CustomKeyInfoXml · property · read/write · since 9.5.0.69`

```java
void get_CustomKeyInfoXml(CkString str);

String customKeyInfoXml();

void put_CustomKeyInfoXml(String newVal);
```

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.

### XmlDSigGen.IncNamespacePrefix

`Chilkat 11.7.0 · ckjava · XmlDSigGen · IncNamespacePrefix · property · read/write · since 9.5.0.70`

```java
void get_IncNamespacePrefix(CkString str);

String incNamespacePrefix();

void put_IncNamespacePrefix(String newVal);
```

The namespace prefix to use for InclusiveNamespaces elements. The default value is `ec`. 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>
```

### XmlDSigGen.IncNamespaceUri

`Chilkat 11.7.0 · ckjava · XmlDSigGen · IncNamespaceUri · property · read/write · since 9.5.0.70`

```java
void get_IncNamespaceUri(CkString str);

String incNamespaceUri();

void put_IncNamespaceUri(String newVal);
```

The namespace URI for any InclusiveNamespaces elements that are created. The default value is `http://www.w3.org/2001/10/xml-exc-c14n#`. For example, if the IncNamespacePrefix equals `ec` and 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>
```

### XmlDSigGen.KeyInfoId

`Chilkat 11.7.0 · ckjava · XmlDSigGen · KeyInfoId · property · read/write · since 9.5.0.75`

```java
void get_KeyInfoId(CkString str);

String keyInfoId();

void put_KeyInfoId(String newVal);
```

If set, causes the generated KeyInfo element to include an Id attribute with this value. For example:

```
...
   <ds:KeyInfo Id="KeyInfo">
      <ds:X509Data>
         <ds:X509SubjectName>CERTIFICADO DE ABC</ds:X509SubjectName>
         <ds:X509Certificate>MIIITTCC....fIsIZeZOeQ=</ds:X509Certificate>
      </ds:X509Data>
   </ds:KeyInfo>
...
```

### XmlDSigGen.KeyInfoKeyName

`Chilkat 11.7.0 · ckjava · XmlDSigGen · KeyInfoKeyName · property · read/write · since 9.5.0.69`

```java
void get_KeyInfoKeyName(CkString str);

String keyInfoKeyName();

void put_KeyInfoKeyName(String newVal);
```

Specifies the KeyName to be inserted in the KeyInfo element of the Signature if the KeyInfoType equals `KeyName`.

### XmlDSigGen.KeyInfoType

`Chilkat 11.7.0 · ckjava · XmlDSigGen · KeyInfoType · property · read/write · since 9.5.0.69`

```java
void get_KeyInfoType(CkString str);

String keyInfoType();

void put_KeyInfoType(String newVal);
```

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`. The `X509Data+KeyValue` option 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.

### XmlDSigGen.SigId

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigId · property · read/write · since 9.5.0.69`

```java
void get_SigId(CkString str);

String sigId();

void put_SigId(String newVal);
```

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">
```

### XmlDSigGen.SigLocation

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigLocation · property · read/write · since 9.5.0.69`

```java
void get_SigLocation(CkString str);

String sigLocation();

void put_SigLocation(String newVal);
```

**Full documentation for this property (same in every language):** [Common Error: The location of where to insert the Signature was not found.](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/xmldsiggen_location_insert_signature_not_found.md)

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>
```

See also:

- [Online Tool to Generate XML Signature Based on Sample Signed XML](http://tools.chilkat.io/xmlDsigGen.cshtml)

### XmlDSigGen.SigLocationIdx

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigLocationIdx · property · read/write · since 11.1.0`

```java
int get_SigLocationIdx();

void put_SigLocationIdx(int newVal);
```

Insert the signature at the Nth occurrence of the `SigLocation`. The default is `0`, which is to insert (according to `SigLocationMod` ) at the 1st occurrence. (An index value of 1 is for the 2nd occurrence, and so on.)

### XmlDSigGen.SigLocationMod

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigLocationMod · property · read/write · since 9.5.0.77`

```java
int get_SigLocationMod();

void put_SigLocationMod(int newVal);
```

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.

### XmlDSigGen.SigNamespacePrefix

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigNamespacePrefix · property · read/write · since 9.5.0.69`

```java
void get_SigNamespacePrefix(CkString str);

String sigNamespacePrefix();

void put_SigNamespacePrefix(String newVal);
```

The namespace prefix of the Signature that is to be created. The default value is `ds`. 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>
```

### XmlDSigGen.SigNamespaceUri

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigNamespaceUri · property · read/write · since 9.5.0.69`

```java
void get_SigNamespaceUri(CkString str);

String sigNamespaceUri();

void put_SigNamespaceUri(String newVal);
```

The namespace URI of the Signature that is to be created. The default value is `http://www.w3.org/2000/09/xmldsig#`. For example, if the SigNamespacePrefix equals `ds` and 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>
```

### XmlDSigGen.SignedInfoCanonAlg

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SignedInfoCanonAlg · property · read/write · since 9.5.0.69`

```java
void get_SignedInfoCanonAlg(CkString str);

String signedInfoCanonAlg();

void put_SignedInfoCanonAlg(String newVal);
```

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`.

### XmlDSigGen.SignedInfoDigestMethod

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SignedInfoDigestMethod · property · read/write · since 9.5.0.69`

```java
void get_SignedInfoDigestMethod(CkString str);

String signedInfoDigestMethod();

void put_SignedInfoDigestMethod(String newVal);
```

The digest method to be used for signing the SignedInfo part of the Signature. Possible values are `sha1`, `sha256`, `sha384`, and `sha512`. The default is `sha256`.

### XmlDSigGen.SignedInfoId

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SignedInfoId · property · read/write · since 9.5.0.75`

```java
void get_SignedInfoId(CkString str);

String signedInfoId();

void put_SignedInfoId(String newVal);
```

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.

### XmlDSigGen.SignedInfoPrefixList

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SignedInfoPrefixList · property · read/write · since 9.5.0.69`

```java
void get_SignedInfoPrefixList(CkString str);

String signedInfoPrefixList();

void put_SignedInfoPrefixList(String newVal);
```

The inclusive namespace prefix list to be added, if any, when the SignedInfoCanonAlg is equal to `EXCL_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>
```

### XmlDSigGen.SigningAlg

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigningAlg · property · read/write · since 9.5.0.69`

```java
void get_SigningAlg(CkString str);

String signingAlg();

void put_SigningAlg(String newVal);
```

Selects the signature algorithm to be used when using an RSA key to sign. The default value is `PKCS1-v1_5`. This can be set to `RSASSA-PSS` (or simply `pss`) 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.

### XmlDSigGen.SigValueId

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SigValueId · property · read/write · since 9.5.0.75`

```java
void get_SigValueId(CkString str);

String sigValueId();

void put_SigValueId(String newVal);
```

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:

```
<ds:SignatureValue>
```

If this property is set to "value-id-7d4a", then the Signature element would be generated like this:

```
<ds:SignatureValue  Id="value-id-7d4a">
```

### XmlDSigGen.UncommonOptions

`Chilkat 11.7.0 · ckjava · XmlDSigGen · UncommonOptions · property · read/write · since 9.5.0.87`

```java
void get_UncommonOptions(CkString str);

String uncommonOptions();

void put_UncommonOptions(String newVal);
```

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string, and should typically remain empty.

### XmlDSigGen.X509Type

`Chilkat 11.7.0 · ckjava · XmlDSigGen · X509Type · property · read/write · since 9.5.0.69`

```java
void get_X509Type(CkString str);

String x509Type();

void put_X509Type(String newVal);
```

Specifies the kind of X.509 certificate information is provided in the KeyInfo element when the KeyInfoType equals `X509Data`. 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.

## Methods

### XmlDSigGen.AddEnvelopedRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddEnvelopedRef · method · since 9.5.0.69`

```java
boolean AddEnvelopedRef(String id, CkStringBuilder 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 `id` is the value of the **Id** attribute of the **Object** element that is to be contained within the generated Signature. The `content` is the text content to be contained in the Object. Binary data can be signed by passing the bytes in `content` in an encoded format (such as base64 or hex).

The `digestMethod` is the digest method and can be one of the following: `sha1`, `sha256`, `sha384`, `sha512`, `ripemd160`, or `md5`.

The `canonMethod` is 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 `refType` is 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.

Returns true for success, false for failure.

### XmlDSigGen.AddExternalBinaryRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddExternalBinaryRef · method · since 9.5.0.69`

```java
boolean AddExternalBinaryRef(String uri, CkBinData content, String digestMethod, String refType);
```

Specifies an external non-XML binary data Reference to be added to the Signature when generated.

The `uri` is the value of the **URI** attribute of the Reference.

The `content` contains the binary data to be digested according to the `digestMethod`.

The `digestMethod` is the digest method and can be one of the following: `sha1`, `sha256`, `sha384`, `sha512`, `ripemd160`, or `md5`.

The `refType` is 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.

Returns true for success, false for failure.

### XmlDSigGen.AddExternalFileRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddExternalFileRef · method · since 9.5.0.69`

```java
boolean AddExternalFileRef(String uri, String localFilePath, String digestMethod, String refType);
```

Specifies an external file Reference to be added to the Signature when generated.

The `uri` is the value of the **URI** attribute of the Reference. It can (and likely will) be different than the `localFilePath` which 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 `digestMethod` is the digest method and can be one of the following: `sha1`, `sha256`, `sha384`, `sha512`, `ripemd160`, or `md5`.

The `refType` is 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.

Returns true for success, false for failure.

### XmlDSigGen.AddExternalTextRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddExternalTextRef · method · since 9.5.0.69`

```java
boolean AddExternalTextRef(String uri, CkStringBuilder 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 `uri` is the value of the **URI** attribute of the Reference.

The `content` contains the non-XML data to be digested according to the `charset`. The `charset` specifies the charset (such as `utf-8`, `windows-1252`, etc.) for the byte reprsentation of the text to be digested. The `includeBom` indicates whether the BOM (Byte Order Mark, also known as the preamble) is included in the byte representation that is digested.

The `digestMethod` is the digest method and can be one of the following: `sha1`, `sha256`, `sha384`, `sha512`, `ripemd160`, or `md5`.

The `refType` is 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.

Returns true for success, false for failure.

### XmlDSigGen.AddExternalXmlRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddExternalXmlRef · method · since 9.5.0.69`

```java
boolean AddExternalXmlRef(String uri, CkStringBuilder content, String digestMethod, String canonMethod, String refType);
```

Specifies an external XML Reference to be added to the Signature when generated.

The `uri` is the value of the **URI** attribute of the Reference.

The `content` contains the XML document to be referenced.

The `digestMethod` is the digest method and can be one of the following: `sha1`, `sha256`, `sha384`, `sha512`, `ripemd160`, or `md5`.

The `canonMethod` is 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 `refType` is 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.

Returns true for success, false for failure.

### XmlDSigGen.AddObject

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddObject · method · since 9.5.0.75`

```java
boolean AddObject(String id, String content, String mimeType, String encoding);
```

Specifies an Object to be added to the Signature.

1. The `id` is the value of the Object element's Id attribute.
2. The `content` contains the content of the Object element, which may be XML or plain text.
3. The `mimeType` is the value of the Object element's MimeType attribute
4. The `encoding` is the value of the Object element's Encoding attribute

In most cases, the `mimeType` and `encoding` are empty strings which cause the MimeType and Encoding attributes to be omitted.

Returns true for success, false for failure.

### XmlDSigGen.AddObjectRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddObjectRef · method · since 9.5.0.75`

```java
boolean 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. The `id` must be an Id equal to the Id attribute of an Object, or the Id attribute of an element within the Object.

Note: The `canonMethod` can be set to `Base64` to use the http://www.w3.org/2000/09/xmldsig#base64 transform.

Returns true for success, false for failure.

### XmlDSigGen.AddObjectRef2

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddObjectRef2 · method · since 9.5.0.90`

```java
boolean AddObjectRef2(String id, String digestMethod, CkXml transforms, String refType);
```

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.

Returns true for success, false for failure.

### XmlDSigGen.AddSameDocRef

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddSameDocRef · method · since 9.5.0.69`

```java
boolean 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 `id` can 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 `digestMethod` is the digest method and can be one of the following: `sha1`, `sha256`, `sha384`, `sha512`, `ripemd160`, or `md5`.

The `canonMethod` is 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 `prefixList` can 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 `prefixList` can 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 `refType` is 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.

Returns true for success, false for failure.

### XmlDSigGen.AddSameDocRef2

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddSameDocRef2 · method · since 9.5.0.90`

```java
boolean AddSameDocRef2(String id, String digestMethod, CkXml transforms, String refType);
```

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.

Returns true for success, false for failure.

### XmlDSigGen.AddSignatureNamespace

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AddSignatureNamespace · method · since 9.5.0.75`

```java
boolean AddSignatureNamespace(String nsPrefix, String nsUri);
```

Can be called one or more times to add additional namespaces to the Signature element.

Returns true for success, false for failure.

### XmlDSigGen.ConstructSignedInfo

`Chilkat 11.7.0 · ckjava · XmlDSigGen · ConstructSignedInfo · method · since 9.5.0.74`

```java
boolean ConstructSignedInfo(CkStringBuilder sbXml, CkString outStr);

String constructSignedInfo(CkStringBuilder sbXml);
```

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 `sbXml` is not signed by this method. It is not modified.

Returns true for success, false for failure.

### XmlDSigGen.CreateXmlDSig

`Chilkat 11.7.0 · ckjava · XmlDSigGen · CreateXmlDSig · method · since 9.5.0.69`

```java
boolean CreateXmlDSig(String inXml, CkString outStr);

String createXmlDSig(String inXml);
```

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 the `inXml` may be the empty string.

- Chilkat v9.5.0.76 or greater is required for XML signatures for www.csioz.gov.pl

Returns true for success, false for failure.

Async variant: `CreateXmlDSigAsync` — same arguments, returns a `Task` (see Async variants below).

See also:

- [Online Tool to Generate XML Signature Based on Sample Signed XML](http://tools.chilkat.io/xmlDsigGen.cshtml)

### XmlDSigGen.CreateXmlDSigSb

`Chilkat 11.7.0 · ckjava · XmlDSigGen · CreateXmlDSigSb · method · since 9.5.0.69`

```java
boolean CreateXmlDSigSb(CkStringBuilder sbXml);
```

Creates an XML Digital Signature. The application passes the XML to be signed in `sbXml`, and it is replaced with the signed XML if successful. (Thus, `sbXml` is 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-in `sbXml` may be empty.

Returns true for success, false for failure.

Async variant: `CreateXmlDSigSbAsync` — same arguments, returns a `Task` (see Async variants below).

See also:

- [Online Tool to Generate XML Signature Based on Sample Signed XML](http://tools.chilkat.io/xmlDsigGen.cshtml)

### XmlDSigGen.SetHmacKey

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SetHmacKey · method · since 9.5.0.69`

```java
boolean SetHmacKey(String key, String encoding);
```

**Full documentation for this method (same in every language):** [Binary Encodings Supported by Chilkat](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/binary_encodings.md)

Sets the HMAC key to be used if the Signature is to use an HMAC signing algorithm. The `encoding` specifies the encoding of `key`, and can be `hex`, `base64`, `ascii`, or any of the binary encodings supported by Chilkat in the link below.

Returns true for success, false for failure.

### XmlDSigGen.SetHttpObj

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SetHttpObj · method · since 9.5.0.90`

```java
void SetHttpObj(CkHttp http);
```

Sets the HTTP object to be used to communicate with OCSP responders, CRL distribution points, or timestamp authority (TSA) servers if needed. The `http` is 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 the `http`.

### XmlDSigGen.SetPrivateKey

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SetPrivateKey · method · since 9.5.0.69`

```java
boolean SetPrivateKey(CkPrivateKey privKey);
```

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.

Returns true for success, false for failure.

### XmlDSigGen.SetRefIdAttr

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SetRefIdAttr · method · since 9.5.0.75`

```java
boolean SetRefIdAttr(String uri_or_id, String value);
```

Sets the `Id` attribute for a Reference.

Returns true for success, false for failure.

### XmlDSigGen.SetTsa

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SetTsa · method · since 9.5.0.90`

```java
boolean SetTsa(CkJsonObject json);
```

Sets the TSA (Timestamp Authority) URL and other related settings for automatically adding an EncapsulatedTimestamp.

Returns true for success, false for failure.

### XmlDSigGen.SetX509Cert

`Chilkat 11.7.0 · ckjava · XmlDSigGen · SetX509Cert · method · since 9.5.0.69`

```java
boolean SetX509Cert(CkCert cert, boolean usePrivateKey);
```

Specifies the X.509 certificate to be used for the KeyInfo element when the KeyInfoType equals `X509Data`. If `usePrivateKey` is `true`, then the private key will also be set using the certificate's private key. Thus, the **SetPrivateKey** method does not need to be called. **If `usePrivateKey` is `true`, and the certificate does not have an associated private key available, then this method will return `false`.**

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.

Returns true for success, false for failure.

See also:

- [More information about .pfx, .cer, .pem](https://cknotes.com/generate-xades-bes-with-pem-cer-or-pfx/)

## Events and callbacks

To receive events, define your own class that extends CkBaseProgress and override just the methods you want to handle. The base class provides an empty implementation of every method, so anything you don't override is simply ignored.

Then create an instance of your class and pass it to the object's put_EventCallbackObject method. From that point on, the object calls your methods as the work proceeds.

**For example:**

```java
// Install an event callback handler to get progress events.
MyBaseProgress xmldsiggenProgress = new MyBaseProgress();
xmldsiggen.put_EventCallbackObject(xmldsiggenProgress);
```

**MyBaseProgress example:**

```java
import com.chilkatsoft.CkBaseProgress;
import com.chilkatsoft.CkTask;

public class MyBaseProgress extends CkBaseProgress 
{	
  public boolean AbortCheck()
  {
    System.out.println("AbortCheck");
    // Return true to abort, false to allow the method to continue.
    return false;
  }
  	
  // pctDone is a value from 0 to 100
  // (it is actually value from 0 to the PercentDoneScale property setting)
  public boolean PercentDone(int pctDone)
  {
    System.out.println(pctDone);
    // Return true to abort, false to allow the method to continue.
    // Note: A PercentDone event is the equivalent of an AbortCheck.  
    // When PercentDone events are frequently firing, AbortCheck events are suppressed.
    // AbortCheck events will fire when the time between PercentDone events is longer 
    // than the HeartbeatMs property setting.
    return false;
  }
  
  public void ProgressInfo(String name, String value)
  {
    System.out.println(name + ": " + value);
  }
  
  public void TaskCompleted(CkTask task)
  {
     System.out.println("task completed!");
  }
  
}
```

### XmlDSigGen.AbortCheck (event)

`Chilkat 11.7.0 · ckjava · XmlDSigGen · AbortCheck · event`

```java
public boolean AbortCheck();
```

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the `HeartbeatMs` property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second. Return `true` to abort; return `false` to continue (not abort)

### XmlDSigGen.PercentDone (event)

`Chilkat 11.7.0 · ckjava · XmlDSigGen · PercentDone · event`

```java
public boolean PercentDone(int pctDone);
```

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The `pctDone` argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have `pctDone` equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an `AbortCheck` event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

Return `true` to abort; return `false` to continue (not abort)

### XmlDSigGen.ProgressInfo (event)

`Chilkat 11.7.0 · ckjava · XmlDSigGen · ProgressInfo · event`

```java
public void ProgressInfo(String name, String value);
```

This event callback provides `tag name`/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

### XmlDSigGen.TaskCompleted (event)

`Chilkat 11.7.0 · ckjava · XmlDSigGen · TaskCompleted · event`

```java
public void TaskCompleted(CkTask task);
```

Called from the background thread when an asynchronous task completes.

## Async variants

Each returns a `Task` instead of the result and takes the same arguments as the synchronous method; run the task, wait for `Finished`, then read the result from the task. No new Async methods are added from 11.7.0 on.

```java
CkTask CreateXmlDSigAsync(String inXml);
CkTask CreateXmlDSigSbAsync(CkStringBuilder sbXml);
```

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/BinData.md), [`Cert`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/Cert.md), [`Http`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/Http.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/JsonObject.md), [`PrivateKey`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/PrivateKey.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/StringBuilder.md), [`Xml`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckjava/classes/Xml.md)

