![]() |
|
SignDoc SDK (.NET with exceptions)
5.0.3.5
|
Parameters for signing a document. More...
Public Member Functions | |
| ~SignDocSignatureParameters () | |
| Destructor. More... | |
| SignDocSignatureParameters () | |
| Constructor. More... | |
| SignDocSignatureParameters | clone (bool aStartKeyGenerator) |
| Clone this object. More... | |
| void | loadFromMemory (byte[] aBlob, ParametersLoadFlags aFlags) |
| Load a SignDocSignatureParameters object from a blob (deserialize). More... | |
| byte[] | saveToMemory (ParametersSaveFlags aFlags) |
| Serialize this object to a blob. More... | |
| void | setBoolean (string aName, bool aValue) |
| Set a boolean parameter. More... | |
| void | setString (string aName, string aValue) |
| Set a string parameter. More... | |
| void | setInteger (string aName, int aValue) |
| Set an integer parameter. More... | |
| void | setBlob (string aName, byte[] aValue) |
| Set a blob parameter. More... | |
| void | setLength (string aName, LengthType aType, double aValue) |
| Set a length parameter. More... | |
| void | setColor (string aName, SignDocColor aValue) |
| Set a color parameter. More... | |
| void | addTextItem (string aItem, TextGroup aGroup) |
| Add another string to be displayed, top down. More... | |
| void | addTextItem2 (string aItem, TextGroup aGroup, SignatureParametersHAlignment aHAlignment, TextItemDirection aDirection) |
| Add another string to be displayed, top down, with paragraph direction. More... | |
| void | clearTextItems () |
| Remove all strings that were to be displayed. More... | |
| void | setTextItemDirection (string aItem, SignatureParametersHAlignment aHAlignment, TextItemDirection aDirection) |
| Set the paragraph direction of text items. More... | |
| void | setPKCS7 (SignPKCS7 aPKCS7) |
| Set an object which will create a PKCS #7 or CAdES signature. More... | |
| void | setRSA (SignRSA aRSA) |
| Set an object which will compute an RSA signature. More... | |
| void | setECDSA (SignECDSA aECDSA) |
| Set an object which will compute an ECDSA signature. More... | |
| void | setDSA (SignDSA aDSA) |
| Set an object which will compute a DSA signature. More... | |
| void | setTimeStamper (UserTimeStamper aTimeStamper) |
| Set an object which will create an RFC 3161 time stamp. More... | |
| void | setCertificatePicker (CertificatePicker aCertificatePicker) |
| Set an object which will let the user select a certificate. More... | |
| void | setPasswordProvider (PasswordProvider aPasswordProvider) |
| Set an object which asks the user for a password. More... | |
| SigningMethodFlags | getAvailableMethods () |
| Get a bitset indicating which signing methods are available for this signature field. More... | |
| byte[] | getTemplate () |
| Get an XML document specifying the current layout. More... | |
| bool? | getBoolean (string aName) |
| Get the value of a boolean parameter. More... | |
| int? | getInteger (string aName) |
| Get the value of an integer parameter. More... | |
| string | getString (string aName) |
| Get the value of a string parameter. More... | |
| string | getString (string aName, int aIndex) |
| Get the value of a string parameter with index. More... | |
| double? | getLength (string aName) |
| Get the value of a length parameter. More... | |
| LengthType | getLengthType (string aName) |
| Get the length type of a length parameter. More... | |
| SignDocColor | getColor (string aName) |
| Get the value of a color parameter. More... | |
| byte[] | getBlob (string aName) |
| Get the value of a blob parameter. More... | |
| byte[] | getBlob (string aName, int aIndex) |
| Get the value of a blob parameter with index. More... | |
| SignDocTextItem | getTextItem (int aIndex) |
| Get a text item. More... | |
| bool | hasCallback (string aName) |
| Check if setDSA(), setECDSA(), setPKCS7(), setRSA(), or setTimeStamper() has been called with a non-null parameter. More... | |
| string | getErrorMessage () |
| Get an error message for the last function call. More... | |
| void | destroy () |
| Destroy this object, overwriting sensitive data. More... | |
Static Public Member Functions | |
| static SignatureParameterType | getType (string aName) |
| Get the type of a parameter. More... | |
Parameters for signing a document.
Use SignDocDocument.createSignatureParameters() or SignDocDocument.createSignatureParametersForTimeStamp() to create objects of this type. Alternatively, use the default constructor and loadFromMemory().
Use getErrorMessage() to get more information after a function call failed.
The available parameters depend both on the document type and on the signature field for which the SignDocSignatureParameters object has been created.
SignDocDocument.addSignature() may fail due to invalid parameters even if all setters reported success as the setters do not check if there are conflicts between parameters.
Which certificates are acceptable may be restricted by the application (by using CertificateSelectionFlags.Software and CertificateSelectionFlags.Hardware of integer parameter "SelectCertificate", blob parameters "FilterCertificatesByIssuerCertificate" and "FilterCertificatesBySubjectCertificate", and string parameters "FilterCertificatesByPolicy" and "FilterCertificatesBySubjectDN") and by the PDF document (certificate seed value dictionary). If no matching certificate is available (for instance, because integer parameter "SelectCertificate" is zero), SignDocDocument.addSignature() will fail with exception SignDocNoCertificateException. If more than one matching certificate is available but CertificateSelectionFlags.NeverAsk is specified in integer parameter "SelectCertificate"), SignDocDocument.addSignature() will fail with exception SignDocAmbiguousCertificateException.
To make the signature maximally meaningful, integer parameter "AddCertificates" should be AddCertificates.All (which is the default value) and integer parameter "AddRevocationInfo" should include AddRevocationInfo.Add.
Unless you need a specific signing method, you should leave integer parameter "Method" at its default value SigningMethod.Default. Use SigningMethod.DigSigCadesDetached for LTV. If you select a specific signing method and that method is not allowed by the signature field's seed values, signing will fail.
Unless you need a specific digest algorithm, you should leave string parameter "DetachedHashAlgorithm" at its default value "default". If you select a specific digest algorithm and that algorithm is not allowed by the signature field's seed values, signing will fail.
The interaction between some parameters is quite complex; the following section tries to summarize the signing methods for PDF documents.
Additionally:
For TIFF documents, an additional, simplified signing method is available:
If the signing certificate has a key usage extension, at least one of the following key purposes must be present in the key usage extension:
If the signing certificate has an extended key usage extension, at least one of the following extended key purposes must be present in the extended key usage extension:
The following parameters control the signing method and related aspects of the signature:
The following parameters control the certificate and the private key used for signing:
The following parameters control rendering of the signature image from biometric data:
The following parameters put additional data into the signature:
The following parameters provide texts for the appearance of a signature in PDF documents:
The following parameters control how a signed signature field in a PDF document will look like (parameters marked with * can be overridden with blob parameter "Template"):
The following parameters are used with PKCS #11 tokens:
The following parameters are used for generating a self-signed certificate on the fly (you also need to set at least one parameter for the private key):
The following parameters are used for putting biometric data (handwritten signature) into the signature:
The following parameters control the certificate selection dialog:
The following parameters control RFC 3161 timestamps:
The following parameters control certification signatures:
The following parameters put additional certificates and revocation information into the signature:
The following parameters are used for multi-phase signing:
The following parameters do not fall into the above categories:
The following parameters can be set by SignDocDocument.addSignature():
Destructor.
Constructor.
Use SignDocDocument.createSignatureParameters() or SignDocDocument.createSignatureParametersForTimeStamp() to create objects of this type. Alternatively, use this constructor and loadFromMemory().
| void addTextItem | ( | string | aItem, |
| TextGroup | aGroup | ||
| ) |
Add another string to be displayed, top down.
For DigSig signature fields, this function adds another string to the appearance stream of PDF documents. The first call clears any default strings. The default values depend on the profile passed to SignDocDocument.createSignatureParameters():
| Profile | Value |
|---|---|
| "" | "Signer"/TextGroup.Primary, "SignTime"/TextGroup.Primary |
| "image" | (empty) |
The paragraph direction is 0 which is treated like TextItemDirection.LTR.
See also blob parameter "Template".
| [in] | aItem | Select the string to be added:
|
| [in] | aGroup | The string's group for font size computation. |
| void addTextItem2 | ( | string | aItem, |
| TextGroup | aGroup, | ||
| SignatureParametersHAlignment | aHAlignment, | ||
| TextItemDirection | aDirection | ||
| ) |
Add another string to be displayed, top down, with paragraph direction.
For DigSig signature fields, this function adds another string to the appearance stream of PDF documents. The first call clears any default strings. The default values depend on the profile passed to SignDocDocument.createSignatureParameters():
| Profile | Value |
|---|---|
| "" | #"Signer"/TextGroup.Primary, "SignTime"/TextGroup.Primary |
| "image" | (empty) |
See also blob parameter "Template".
| [in] | aItem | Select the string to be added:
|
| [in] | aGroup | The string's group for font size computation. |
| [in] | aHAlignment | Horizontal alignment. This value overrides integer parameter "TextHAlignment" unless it is SignatureParametersHAlignment.Default. |
| [in] | aDirection | The paragraph direction, see enum TextItemDirection. 0 is treated like TextItemDirection.LTR. |
| void clearTextItems | ( | ) |
Remove all strings that were to be displayed.
addTextItem() cannot remove the default strings without adding a new string. This function does.
See also blob parameter "Template".
| SignDocSignatureParameters clone | ( | bool | aStartKeyGenerator | ) |
Clone this object.
| [in] | aStartKeyGenerator | true to start the key generator in the copied object. This is needed if integer parameter "GenerateKeyPair" or string parameter "GenerateECCKeyPair" is set and you want to pass the copy to SignDocDocument.addSignature(). false to not start the key generator. If integer parameter "GenerateKeyPair" or string parameter "GenerateECCKeyPair" is set, SignDocDocument.addSignature() will fail. |
| void destroy | ( | ) |
Destroy this object, overwriting sensitive data.
After calling this method, all methods of this object will fail.
| SigningMethodFlags getAvailableMethods | ( | ) |
Get a bitset indicating which signing methods are available for this signature field.
| byte [] getBlob | ( | string | aName | ) |
Get the value of a blob parameter.
getBlob(name) is equivalent to getBlob(name,0).
This function does not support blob parameters "FilterCertificatesByIssuerCertificate", "FilterCertificatesBySubjectCertificate", and "IntermediateCertificate".
Certificates passed to setBlob() in PEM format may be returned by this function as individual DER-encoded certificates.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| byte [] getBlob | ( | string | aName, |
| int | aIndex | ||
| ) |
Get the value of a blob parameter with index.
getBlob(name,0) is equivalent to getBlob(name).
This function supports blob parameters "FilterCertificatesByIssuerCertificate", "FilterCertificatesBySubjectCertificate", and "IntermediateCertificate".
Certificates passed to setBlob() in PEM format may be returned by this function as individual DER-encoded certificates.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aIndex | The zero-based index of the blob to get. |
| bool? getBoolean | ( | string | aName | ) |
Get the value of a boolean parameter.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| SignDocColor getColor | ( | string | aName | ) |
Get the value of a color parameter.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| string getErrorMessage | ( | ) |
Get an error message for the last function call.
| int? getInteger | ( | string | aName | ) |
Get the value of an integer parameter.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| double? getLength | ( | string | aName | ) |
Get the value of a length parameter.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| LengthType getLengthType | ( | string | aName | ) |
Get the length type of a length parameter.
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| string getString | ( | string | aName | ) |
Get the value of a string parameter.
getString(name) is equivalent to getString(name,0).
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| string getString | ( | string | aName, |
| int | aIndex | ||
| ) |
Get the value of a string parameter with index.
getString(name,0) is equivalent to getString(name).
This function does not set an error message.
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aIndex | The zero-based index of the string to get. |
| byte [] getTemplate | ( | ) |
Get an XML document specifying the current layout.
This function can be used for debugging and for reporting bugs. This function will fail if the "Template" blob parameter is invalid.
| SignDocTextItem getTextItem | ( | int | aIndex | ) |
Get a text item.
| [in] | aIndex | Zero based index of the text item. |
|
static |
Get the type of a parameter.
| [in] | aName | The name of the parameter (case-sensitive). |
| bool hasCallback | ( | string | aName | ) |
Check if setDSA(), setECDSA(), setPKCS7(), setRSA(), or setTimeStamper() has been called with a non-null parameter.
This function does not set an error message.
| [in] | aName | "CertificatePicker" for setCertificatePicker(), "DSA" for setDSA(), "ECDSA" for setECDSA(), "PasswordProvider" for setPasswordProvider(), "PKCS7" for setPKCS7(), "RSA" for setRSA(), or "TimeStamper" for setTimeStamper(). |
| void loadFromMemory | ( | byte[] | aBlob, |
| ParametersLoadFlags | aFlags | ||
| ) |
Load a SignDocSignatureParameters object from a blob (deserialize).
Parameters set in this object but not set in the blob won't be overwritten.
| [in] | aBlob | A blob containing a serialized SignDocSignatureParameters object, see saveToMemory(). If the blob contains an XML document, it must conform to SignDocParameters.dtd, which see for details. |
| [in] | aFlags | Must be ParametersLoadFlags.Zero. |
| byte [] saveToMemory | ( | ParametersSaveFlags | aFlags | ) |
Serialize this object to a blob.
Secret values won't be saved unless ParametersSaveFlags.Secret or ParametersSaveFlags.Debug is set in aFlags.
SignDocDocument.addSignature() may change the SignDocSignatureParameters object passed to it. If you want to serialize the SignDocSignatureParameters object, please do so before calling SignDocDocument.addSignature().
| [in] | aFlags | Set of flags. Pass ParametersSaveFlags.Zero for no flags (binary format). |
| void setBlob | ( | string | aName, |
| byte[] | aValue | ||
| ) |
Set a blob parameter.
Available blob parameters are:
Additionally, you can store your own blobs in the signature by using a name starting with "Prop_", except for "Prop_AuthTime", "Prop_AuthType", "Prop_Build", and any name starting with "Prop_BiometricData", see SignDocVerificationResult.getSignatureBlob(). The name shall contain the following characters only: 0-9, a-z, A-Z, '-', and '_'.
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aValue | The value. |
| void setBoolean | ( | string | aName, |
| bool | aValue | ||
| ) |
Set a boolean parameter.
The following boolean parameters are available:
This function throws SignDocUnkownParameterException if aName is not the name of a boolean parameter.
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aValue | The value of the parameter. |
| void setCertificatePicker | ( | CertificatePicker | aCertificatePicker | ) |
Set an object which will let the user select a certificate.
By default, SignDoc SDK uses a wxWidgets-based dialog for letting the user select a certificate for CertificateSelectionFlags.Software and CertificateSelectionFlags.Hardware (without CertificateSelectionFlags.NeverAsk). You can use your own dialog by calling this method.
See de.softpro.doc.CertificatePicker for details. See also string parameter "CertificatePicker".
| [in] | aCertificatePicker | The object that will let the user select a certificate. |
| void setColor | ( | string | aName, |
| SignDocColor | aValue | ||
| ) |
Set a color parameter.
Available color parameters are:
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aValue | The value of the parameter. |
| void setDSA | ( | SignDSA | aDSA | ) |
Set an object which will compute a DSA signature.
By default, DSA signatures are computed internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setRSA() and setPKCS7() must not have been called
| [in] | aDSA | The object that will compute the DSA signature. |
| void setECDSA | ( | SignECDSA | aECDSA | ) |
Set an object which will compute an ECDSA signature.
By default, ECDSA signatures are computed internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setRSA() and setPKCS7() must not have been called
| [in] | aECDSA | The object that will compute the ECDSA signature. |
| void setInteger | ( | string | aName, |
| int | aValue | ||
| ) |
Set an integer parameter.
Available integer parameters are:
| Profile | Value |
|---|---|
| "" | SignatureParametersHAlignment.Center |
| "image" | SignatureParametersHAlignment.Center |
| Profile | Value |
|---|---|
| "" | SignatureParametersVAlignment.Top |
| "image" | SignatureParametersHAlignment.Center |
| Profile | Value |
|---|---|
| "" | SignatureParametersHAlignment.Center |
| "image" | SignatureParametersHAlignment.Center |
| Profile | Value |
|---|---|
| "" | TextPosition.Below |
| "image" | TextPosition.Overlay |
| Profile | Value |
|---|---|
| "" | SignatureParametersVAlignment.Bottom |
| "image" | SignatureParametersHAlignment.Center |
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aValue | The value of the parameter. |
| void setLength | ( | string | aName, |
| LengthType | aType, | ||
| double | aValue | ||
| ) |
Set a length parameter.
Available length parameters are:
| Profile | Value |
|---|---|
| "" | LengthType.FieldHeight and 0.1 |
| "image" | LengthType.FieldHeight and 0.1 |
| Profile | Value |
|---|---|
| "" | LengthType.Abs and 1.0 |
| "image" | LengthType.Abs and 1.0 |
| Profile | Value |
|---|---|
| "" | LengthType.FieldHeight and 0.1 |
| "image" | LengthType.FieldHeight and 0.1 |
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aType | Define how the length is specified. |
| [in] | aValue | The value of the parameter. |
| void setPasswordProvider | ( | PasswordProvider | aPasswordProvider | ) |
Set an object which asks the user for a password.
By default, SignDoc SDK uses the method specified by string parameter "PasswordProvider" for asking the user for a password. You can use your own dialog by calling this function.
See de.softpro.doc.PasswordProvider for details. See also string parameter "PasswordProvider".
| [in] | aPasswordProvider | The object that will let the user select a certificate. |
| void setPKCS7 | ( | SignPKCS7 | aPKCS7 | ) |
Set an object which will create a PKCS #7 or CAdES signature.
By default, PKCS #7 and CAdES signatures are handled internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setRSA(), setECDSA(), and setDSA() must not have been called
The SignPKCS7 interface is quite hard to use, please use setRSA() and the SignRSA interface or setECDSA() and the SignECDSA interface or setDSA() and the SignDSA interface instead.
| [in] | aPKCS7 | The object that will create the PKCS #7 or CAdES signature. |
| void setRSA | ( | SignRSA | aRSA | ) |
Set an object which will compute an RSA signature.
By default, RSA signatures are computed internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setDSA(), setECDSA(), and setPKCS7() must not have been called
| [in] | aRSA | The object that will compute the RSA signature. |
| void setString | ( | string | aName, |
| string | aValue | ||
| ) |
Set a string parameter.
Available string parameters are:
Additionally, you can store your own strings in the signature by using a name starting with "Prop_", except for "Prop_AuthTime", "Prop_AuthType", "Prop_Build", and any name starting with "Prop_BiometricData", see SignDocVerificationResult.getSignatureString(). The name shall contain the following characters only: 0-9, a-z, A-Z, '-', and '_'. The length of the value is restricted for PDF documents and depends on the characters being used; the value encoded as PDF text string shall not exceed 32767 octets.
| [in] | aName | The name of the parameter (case-sensitive). |
| [in] | aValue | The value of the parameter. |
| void setTextItemDirection | ( | string | aItem, |
| SignatureParametersHAlignment | aHAlignment, | ||
| TextItemDirection | aDirection | ||
| ) |
Set the paragraph direction of text items.
This function sets the paragraph direction of all existing text items matching aItem.
See also blob parameter "Template".
| [in] | aItem | Select the text items:
|
| [in] | aHAlignment | Horizontal alignment. This value overrides integer parameter "TextHAlignment" unless it is SignatureParametersHAlignment.Default. |
| [in] | aDirection | The paragraph direction, see enum TextItemDirection. 0 is treated like TextItemDirection.LTR. |
| void setTimeStamper | ( | UserTimeStamper | aTimeStamper | ) |
Set an object which will create an RFC 3161 time stamp.
By default, RFC 3161 time stamps are created by asking the TSA configured in string parameter TimeStampServerURL.
See UserTimeStamper for details.
| [in] | aTimeStamper | The object that will create the RFC 3161 time stamp. |