@@ -651,6 +651,57 @@ static PyObject* PyXmlSec_TemplateEncryptedDataEnsureCipherValue(PyObject* self,
651
651
return NULL ;
652
652
}
653
653
654
+ static char PyXmlSec_TemplateTransformAddC14NInclNamespaces__doc__ [] = \
655
+ "Adds 'inclusive' namespaces to the ExcC14N transform node *node*.\n\n"
656
+ ":param node: the pointer to <dsig:Transform/> node.\n"
657
+ ":param prefixList: the list of namespace prefixes, where 'default' indicates the default namespace (optional)." ;
658
+ static PyObject * PyXmlSec_TemplateTransformAddC14NInclNamespaces (PyObject * self , PyObject * args , PyObject * kwargs ) {
659
+ static char * kwlist [] = { "node" , "prefixes" , NULL };
660
+
661
+ PyXmlSec_LxmlElementPtr node = NULL ;
662
+ PyObject * prefixes = NULL ;
663
+ // transform_add_c14n_inclusive_namespaces
664
+ PYXMLSEC_DEBUG ("template encrypted_data_ensure_cipher_value - start" );
665
+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "O&O:transform_add_c14n_inclusive_namespaces" , kwlist ,
666
+ PyXmlSec_LxmlElementConverter , & node , & prefixes ))
667
+ {
668
+ prefixes = NULL ;
669
+ goto ON_FAIL ;
670
+ }
671
+ if (PyList_Check (prefixes ) || PyTuple_Check (prefixes )) {
672
+ PyObject * sep = PyString_FromString (" " );
673
+ prefixes = PyObject_CallMethod (sep , "join" , "O" , prefixes );
674
+ Py_DECREF (sep );
675
+ } else if (PyString_Check (prefixes )) {
676
+ Py_INCREF (prefixes );
677
+ } else {
678
+ PyErr_SetString (PyExc_TypeError , "expected instance of str or list of str" );
679
+ prefixes = NULL ;
680
+ }
681
+
682
+ if (prefixes == NULL ) {
683
+ goto ON_FAIL ;
684
+ }
685
+
686
+ int res ;
687
+ const char * c_prefixes = PyString_AsString (prefixes );
688
+ Py_BEGIN_ALLOW_THREADS ;
689
+ res = xmlSecTmplTransformAddC14NInclNamespaces (node -> _c_node , XSTR (c_prefixes ));
690
+ Py_END_ALLOW_THREADS ;
691
+ if (res != 0 ) {
692
+ PyXmlSec_SetLastError ("cannot add 'inclusive' namespaces to the ExcC14N transform node" );
693
+ goto ON_FAIL ;
694
+ }
695
+
696
+ Py_DECREF (prefixes );
697
+ PYXMLSEC_DEBUG ("transform_add_c14n_inclusive_namespaces - ok" );
698
+ Py_RETURN_NONE ;
699
+
700
+ ON_FAIL :
701
+ PYXMLSEC_DEBUG ("transform_add_c14n_inclusive_namespaces - fail" );
702
+ Py_XDECREF (prefixes );
703
+ return NULL ;
704
+ }
654
705
655
706
static PyMethodDef PyXmlSec_TemplateMethods [] = {
656
707
{
@@ -761,6 +812,12 @@ static PyMethodDef PyXmlSec_TemplateMethods[] = {
761
812
METH_VARARGS |METH_KEYWORDS ,
762
813
PyXmlSec_TemplateEncryptedDataEnsureCipherValue__doc__
763
814
},
815
+ {
816
+ "transform_add_c14n_inclusive_namespaces" ,
817
+ (PyCFunction )PyXmlSec_TemplateTransformAddC14NInclNamespaces ,
818
+ METH_VARARGS |METH_KEYWORDS ,
819
+ PyXmlSec_TemplateTransformAddC14NInclNamespaces__doc__ ,
820
+ },
764
821
{NULL , NULL } /* sentinel */
765
822
};
766
823
0 commit comments