# 22. Virtuoso Functions Guide - dsig_template_ext

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
dsig_template_ext
md5
md5_final
md5_init
md5_update
x509_certificate_ver...
xenc_x509_certificat...
xenc_decrypt_soap
xenc_delete_temp_key...
xenc_encrypt
xenc_get_key_algo
xenc_get_key_identif...
xenc_key_3des_create
xenc_key_3des_rand_c...
xenc_key_3des_read
xenc_key_aes_create
xenc_key_aes_rand_cr...
xenc_key_dsa_create
xenc_key_dsa_read
xenc_key_rsa_read
xenc_key_create_cert
xenc_key_exists
xenc_key_inst_create
xenc_key_remove
xenc_key_serialize
xenc_set_primary_key
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## dsig_template_ext

Generates a Digital signature template based on a XML document.
varchar dsig_template_ext (in xdoc any, in tmpl varchar, in wss_ver any, in ns-n varchar, in elm-n varchar, in ... varchar);
Description

The function is used to generate dynamically a digital signature template containing references to be signed.

Parameters
xdoc – input XML document
tmpl – a string containing base XML template
wss_ver – vector containing WS-Security and WS-Utility version URIs
ns-n – namespace to match
elm-n – element name to match
Return Types

On success the function will return a string containing a XML template suitable to pass to the xenc_encrypt. The elements matching listed in elm-n from namespace URIs in ns-n and having Id attribute will be included in the XML signature reference list.

Examples
Making a XML signature template

    create procedure XENC_TEMPLATE (in body varchar, in key_name varchar)
    {
      declare tmpl, algo varchar;
      declare ns any;

      -- OASIS WS-Security extensions
      ns := vector (
      	'wsse', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd',
    	'wsu', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
    	);

      algo := xenc_get_key_algo (key_name);
      if (algo is null)
        return NULL;

      -- base XML template
      tmpl := sprintf ('<?xml version="1.0" encoding="UTF-8"?>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#" >
      <SignedInfo>
        <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
        <SignatureMethod Algorithm="%s" />
      </SignedInfo>
      <SignatureValue></SignatureValue>
      <KeyInfo>
        <KeyName>%s</KeyName>
      </KeyInfo>
    </Signature>', algo, key_name);

      return dsig_template_ext (xtree_doc (body), tmpl, ns,
          'http://schemas.xmlsoap.org/soap/envelope/', 'Body',
           -- WS-Addressing
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'Action',
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'From',
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'To',
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'MessageID',
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'ReplyTo',
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'FaultTo',
          'http://schemas.xmlsoap.org/ws/2004/03/addressing', 'RelatesTo'
          );

    }
    ;

See Also