xmlsec.template

Xml Templates processing

xmlsec.template.add_encrypted_key()

Adds <enc:EncryptedKey/> node with given attributes to the <dsig:KeyInfo/> node of node.

Parameters:
  • node – the pointer to <dsig:KeyInfo/> node
  • method – the encryption method (optional)
  • id – the Id attribute (optional)
  • type – the Type attribute (optional)
  • recipient – the Recipient attribute (optional)
Returns:

the pointer to the newly created <enc:EncryptedKey/> node

xmlsec.template.add_key_name()

Adds <dsig:KeyName/> node to the <dsig:KeyInfo/> node of node.

Parameters:
  • node – the pointer to <dsig:KeyInfo/> node
  • name – the key name (optional)
Returns:

the pointer to the newly created <dsig:KeyName/> node

xmlsec.template.add_key_value()

Adds <dsig:KeyValue/> node to the <dsig:KeyInfo/> node of node.

Parameters:node – the pointer to <dsig:KeyInfo/> node
Returns:the pointer to the newly created <dsig:KeyValue/> node
xmlsec.template.add_reference()

Adds <dsig:Reference/> node with given URI (uri ) Id (id ) and Type (type ) attributes and the required children <dsig:DigestMethod/> and <dsig:DigestValue/> to the <dsig:SignedInfo/> child of node.

Parameters:
  • node – the pointer to <dsig:Signature/> node
  • digest_method – the reference digest method
  • id – the node id (optional)
  • uri – the reference node uri (optional)
  • type – the reference node type (optional)
Returns:

the pointer to newly created <dsig:Reference/> node

xmlsec.template.add_transform()

Adds <dsig:Transform/> node to the <dsig:Reference/> node of node.

Parameters:
  • node – the pointer to <dsig:Reference/> node
  • transform – the transform method id
Returns:

the pointer to newly created <dsig:Transform/> node

xmlsec.template.add_x509_data()

Adds <dsig:X509Data/> node to the <dsig:KeyInfo/> node of node.

Parameters:node – the pointer to <dsig:KeyInfo/> node
Returns:the pointer to the newly created <dsig:X509Data/> node
xmlsec.template.create()

Creates new <dsig:Signature/> node with the mandatory <dsig:SignedInfo/>, <dsig:CanonicalizationMethod/>,<dsig:SignatureMethod/> and <dsig:SignatureValue/> children and sub-children.

Parameters:
  • node – the signature node
  • c14n_method – the signature canonicalization method
  • sign_method – the signature method
  • name – the node id (optional)
  • ns – the namespace prefix for the signature element (e.g. “dsig”) (optional)
Returns:

the pointer to newly created <dsig:Signature/> node

xmlsec.template.encrypted_data_create()

Creates new <{ns}:EncryptedData /> node for encryption template.

Parameters:
  • node – the pointer to signature node
  • method – the encryption method (optional)
  • id – the Id attribute (optional)
  • type – the Type attribute (optional)
  • mime_type – the Recipient attribute (optional)
  • encoding – the MimeType attribute (optional)
  • ns – the namespace prefix (optional)
Returns:

the pointer newly created <enc:EncryptedData/> node

xmlsec.template.encrypted_data_ensure_cipher_value()

Adds <CipherValue/> to the <enc:EncryptedData/> node of node.

Parameters:node – the pointer to <enc:EncryptedData/> node
Returns:the pointer to newly created <enc:CipherValue/> node
xmlsec.template.encrypted_data_ensure_key_info()

Adds <{ns}:KeyInfo/> to the <enc:EncryptedData/> node of node.

Parameters:
  • node – the pointer to <enc:EncryptedData/> node
  • id – the Id attribute (optional)
  • ns – the namespace prefix (optional)
Returns:

the pointer to newly created <dsig:KeyInfo/> node

xmlsec.template.ensure_key_info()

Adds (if necessary) <dsig:KeyInfo/> node to the <dsig:Signature/> node of node.

Parameters:
  • node – the pointer to <dsig:Signature/> node
  • id – the node id (optional)
Returns:

the pointer to newly created <dsig:KeyInfo/> node

xmlsec.template.transform_add_c14n_inclusive_namespaces()

Adds ‘inclusive’ namespaces to the ExcC14N transform node node.

Parameters:
  • node – the pointer to <dsig:Transform/> node.
  • prefixList – the list of namespace prefixes, where ‘default’ indicates the default namespace (optional).
xmlsec.template.x509_data_add_certificate()

Adds <dsig:X509Certificate/> node to the given <dsig:X509Data/> node of node.

Parameters:node – the pointer to <dsig:X509Data/> node
Returns:the pointer to the newly created <dsig:X509Certificate/> node
xmlsec.template.x509_data_add_crl()

Adds <dsig:X509CRL/> node to the given <dsig:X509Data/> node of node.

Parameters:node – the pointer to <dsig:X509Data/> node
Returns:the pointer to the newly created <dsig:X509CRL/> node
xmlsec.template.x509_data_add_issuer_serial()

Adds <dsig:X509IssuerSerial/> node to the given <dsig:X509Data/> node of node.

Parameters:node – the pointer to <dsig:X509Data/> node
Returns:the pointer to the newly created <dsig:X509IssuerSerial/> node
xmlsec.template.x509_data_add_ski()

Adds <dsig:X509SKI/> node to the given <dsig:X509Data/> node of node.

Parameters:node – the pointer to <dsig:X509Data/> node
Returns:the pointer to the newly created <dsig:X509SKI/> node
xmlsec.template.x509_data_add_subject_name()

Adds <dsig:X509SubjectName/> node to the given <dsig:X509Data/> node of node.

Parameters:node – the pointer to <dsig:X509Data/> node
Returns:the pointer to the newly created <dsig:X509SubjectName/> node
xmlsec.template.x509_issuer_serial_add_issuer_name()

Adds <dsig:X509IssuerName/> node to the <dsig:X509IssuerSerial/> node of node.

Parameters:
  • node – the pointer to <dsig:X509IssuerSerial/> node
  • name – the issuer name (optional)
Returns:

the pointer to the newly created <dsig:X509IssuerName/> node

xmlsec.template.x509_issuer_serial_add_serial_number()

Adds <dsig:X509SerialNumber/> node to the <dsig:X509IssuerSerial/> node of node.

Parameters:
  • node – the pointer to <dsig:X509IssuerSerial/> node
  • serial – the serial number (optional)
Returns:

the pointer to the newly created <dsig:X509SerialNumber/> node

Table of contents