XML - Sign

Declaration

<AMXMLSIGN SIGNUSING="text [options]" KEYCONTAINERNAME="text" 
KEYCONTAINERLEVEL="text" KEYPAIRFILE="text" 
PASSWORD="text"/>

Description: Signs an XML file with the specified key. Signing an XML file provides a means of verification that the file has not been modified. Use the Verify XML Document action XML - Verify activity to verify a previously signed XML file. Signatures can be added using Key Container or Public/Private Key files generated using the Generate Key Files action.

IMPORTANT: Use of XML activities require a basic interpretation of XML schema and general knowledge of XML related terms, such as Nodes, XPath, DTD and XSLT.

Practical Usage

Used to verify if anyone has changed the original XML file.

Resource Parameters

Property

Type

Required

Default

Markup

Description

File/Session

 

 

 

 

Denotes where the XML data derives from. This is a visual mode parameter used only during design-time, therefore, contains no markup. The available options are:

  • File (default) - XML data will derive from a new file, existing file or specified text.

  • Session - XML data will derive from an existing session.

Session

Text

Yes if Resource is set to Session

XMLSession1

SESSIONNAME="myXMLSession"

The name of an existing session in which to associate this activity with. As a safety measure, when a session is created, the XML file bound by that session is saved in memory and the original file is locked. Any modifications by subsequent XML steps are performed on a copy of the XML data saved to memory. Linking several activities to a single session eliminates redundancy. Additionally, a single task supports simultaneous execution of multiple sessions, improving overall efficiency. Use the  XML - Save activity to output the in-memory representation of the XML session to a file or variable. To end the session, use the XML - End session activity. 

Create XML session from

Text (options)

Yes if Resource is set to File

Existing File

  1. XMLDOCUMENTFROM="existingfile"

  2. XMLDOCUMENTFROM="newfile"

  3. XMLDOCUMENTFROM="text"

Specifies where the XML data should derive from to start the new session. The XML data will be saved into memory. Different parameters become active depending on which option is selected. The available options are:

  • Existing file (default) - The XML data originates from an existing file. This option allows you to browse for an existing XML file to use.

  • New file - Creates a new XML file to use.

  • Text -  The XML data originates from specific text.

File

Text

Yes if XML session derives from a new or existing file

(Empty)

FILE="c:\foldername\file.XML"

The path and filename of the new or existing XML file. This parameter is active only if the Create XML session from parameter is set to Existing file or New file.

Overwrite if file exists

Yes/No

Yes if XML session derives from a new file

No

OVERWRITEFILE="YES"

If set to YES, specifies that if an XML file with the same name already exists at the specified location, it will be overwritten with the new file. If set to NO (default), the step fails if the file already exists. This parameter is active only if the Create XML session from parameter is set to New file.

Root node name

Text

Yes if XML session derives from a new file

(Empty)

ROOTNODENAME="Automate"

The root node name for new XML file. This parameter is active only if the Create XML session from parameter is set to New file.

Root node value (optional)

Text

No

(Empty)

NEWVALUE="Value"

The root node value for the new XML file. This parameter is active only if the Create XML session from parameter is set to New file.

Default namespace prefix (optional)

Text

No

(Empty)

DEFAULTNSPREFIX="edi"

The prefix of the default namespace for the new XML file. A namespace prefix is a text string assigned as an element name prefix to a namespace. When an element name is preceded by the prefix and a colon, then that element is in that assigned namespace. This parameter is active only if the Create XML session from parameter is set to New file.

Default namespace URI (optional)

Text

No

(Empty)

DEFAULTNAMESPACE=

"http://net.com/schema"

The default namespace URI for the new XML file. An XML namespace is a collection of element type and attribute names that are uniquely identified by the name of the unique XML namespace of which they are a part. This parameter is active only if the Create XML session from parameter is set to New file.

Text

Text

Yes if XML session derives from text

(Empty)

XMLTEXT="theText"

The text that the XML data should originate from. This parameter is active only if the Start XML session from parameter is set to Text.

Attribute Name

Text

No

(Empty)

Name="AttribName"

The name portion of the attribute name value pair to insert. Use this parameter to insert attributes into the new node. To enter a new row of values select Click here to add new row... To delete an existing row, click the red "X". This parameter supports insertion of multiple attribute name value pairs.

Attribute Value

Text

No

(Empty)

Value="AttribValue"

The value portion of the attribute name value pair to insert. Use this parameter to insert attributes into the new node. To enter a new row of values select Click here to add new row... To delete an existing row, click the red "X". This parameter supports insertion of multiple attribute name value pairs.

Sign Parameters

Property

Type

Required

Default

Markup

Description

Sign using

Text (options)

No

Key container

SIGNUSING="keycontainer"

SIGNUSING="keyfile"

The method in which to sign the XML document. The available options are:

  • Key container (default) - Signing will be performed using a key container.  

  • Key file - Signing will be performed using a key file (normally a pri or .pfx file). You can generate a key file using the Cryptography - Generate key file(s) activity.

Key container name

Text

Yes if signing method is key container

(Empty)

KEYCONTAINERNAME="Automate"

The name of the key container to identify which private or public key to use. Click the Load button to load available key containers. Thereafter, click the down arrow and select the desired key container from the drop-down list. This parameter is available only if the Sign using parameter is set to Key container.

Key container level

Text

Yes if signing method is key container

User

KEYCONTAINERLEVEL="Machine"

Specifies the level in which the keys are stored. This parameter is available only if the Sign using parameter is set to Key container. The available options are:

  • User (default) - Key container is user level.

  • Machine - Key container is machine level.

NOTE: For more details regarding key container levels, see Comparing Machine-Level and User-Level RSA Key Containers below.

Keypair file

Text

Yes if signing method is key file

(Empty)

KEYPAIRFILE="c:\temp\secret.pri"

The path and filename of the public key (.pfx or .pri) file on your system in which to sign the document with. This parameter is available only if the Sign using parameter is set to Key file.

Passphrase

Text

Yes if signing method is key file

(Empty)

PASSWORD="encrypted"

The passphrase used to authenticate the public key. This is normally required during creation of the private key (usually used for .pfx file). This parameter is available only if the Sign using parameter is set to Key file.

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Comparing Machine-Level and User-Level RSA Key Containers

User-level RSA key containers are stored with the Windows user profile for a particular user and can be used to encrypt and decrypt information for applications that run under that specific user identity. User-level RSA key containers can be useful if you want to ensure that the RSA key information is removed when the Windows user profile is removed. However, because you must be logged in with the specific user account that makes use of the user-level RSA key container to encrypt or decrypt protected configuration sections, they are inconvenient to use.

Machine-level RSA key containers are available to all users that can log in to a computer, by default, and are the most useful as you can use them to encrypt or decrypt protected configuration sections while logged in with an administrator account. A machine-level RSA key container can be used to protect information for a single application, all the applications on a server, or a group of applications on a server that run under the same user identity. Although machine-level RSA key containers are available to all users, they can be secured with NTFS Access Control Lists (ACLs) so that only required users can access them.

Examples

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Example 1: Sign XML document using key container (level USER).

<AMXMLSIGN SIGNUSING="KEYCONTAINER" 
KEYCONTAINERNAME="myContainer" KEYCONTAINERLEVEL="USER" 
SESSION="myXMLSession" />

Example 2: Sign XML file using a public/private key pair file.

<AMXMLSIGN SIGNUSING="KEYFILE" 
KEYPAIRFILE="C:\Temp\myKey.pri" 
PASSWORD="AM2h7iOD6MfRFWVuJkPsR9EVea4/Q/CHyVVaME" 
SESSION="myXMLSession" />