diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-04-13 10:15:54 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-04-13 10:15:54 +0000 |
| commit | f1d2812a740a1463bf920e6501e14baafe632aed (patch) | |
| tree | 5685eae31fbb0aea42b821a0eb4b95c2ceffefbe | |
| parent | da44bfe52bb580448477d8b91e59dcc6bc47e914 (diff) | |
| download | lasso-f1d2812a740a1463bf920e6501e14baafe632aed.tar.gz lasso-f1d2812a740a1463bf920e6501e14baafe632aed.tar.xz lasso-f1d2812a740a1463bf920e6501e14baafe632aed.zip | |
*** empty log message ***
| -rw-r--r-- | lasso/lasso.c | 24 | ||||
| -rw-r--r-- | lasso/xml/xml.c | 22 | ||||
| -rw-r--r-- | lasso/xml/xml.h | 11 | ||||
| -rwxr-xr-x | python/examples/test.py | 17 | ||||
| -rw-r--r-- | python/lassomod.c | 9 | ||||
| -rw-r--r-- | python/py_lasso.c | 3 | ||||
| -rwxr-xr-x | python/setup.py | 8 | ||||
| -rw-r--r-- | python/wrap_objs.c | 2 | ||||
| -rw-r--r-- | python/wrap_objs.h | 2 | ||||
| -rw-r--r-- | python/xml/py_xml.c | 52 | ||||
| -rw-r--r-- | python/xml/py_xml.h | 3 |
11 files changed, 121 insertions, 32 deletions
diff --git a/lasso/lasso.c b/lasso/lasso.c index bbd83bd4..0aa7086a 100644 --- a/lasso/lasso.c +++ b/lasso/lasso.c @@ -103,7 +103,10 @@ int lasso_shutdown() #ifndef XMLSEC_NO_XSLT xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ + /* Cleanup function for the XML library */ xmlCleanupParser(); + /* this is to debug memory for regression tests */ + xmlMemoryDump(); return (0); } @@ -120,33 +123,34 @@ int lasso_shutdown() * 0 if it is not or a negative value if an error occurs. */ int -lasso_check_version_ext(int major, int minor, int subminor, lassoCheckVersionMode mode) { +lasso_check_version_ext(int major, int minor, int subminor, lassoCheckVersionMode mode) +{ /* we always want to have a match for major version number */ - if(major != LASSO_VERSION_MAJOR) { + if (major != LASSO_VERSION_MAJOR) { g_message("expected major version=%d;real major version=%d", LASSO_VERSION_MAJOR, major); - return(0); + return (0); } - switch(mode) { + switch (mode) { case lassoCheckVersionExact: - if((minor != LASSO_VERSION_MINOR) || (subminor != LASSO_VERSION_SUBMINOR)) { + if ((minor != LASSO_VERSION_MINOR) || (subminor != LASSO_VERSION_SUBMINOR)) { g_message("mode=exact;expected minor version=%d;real minor version=%d;expected subminor version=%d;real subminor version=%d", LASSO_VERSION_MINOR, minor, LASSO_VERSION_SUBMINOR, subminor); - return(0); + return (0); } break; case lassoCheckVersionABICompatible: - if((minor < LASSO_VERSION_MINOR) || - ((minor == LASSO_VERSION_MINOR) && (subminor < LASSO_VERSION_SUBMINOR))) { + if ((minor < LASSO_VERSION_MINOR) || + ((minor == LASSO_VERSION_MINOR) && (subminor < LASSO_VERSION_SUBMINOR))) { g_message("mode=abi compatible;expected minor version=%d;real minor version=%d;expected subminor version=%d;real subminor version=%d", LASSO_VERSION_MINOR, minor, LASSO_VERSION_SUBMINOR, subminor); - return(0); + return (0); } break; } - return(1); + return (1); } diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 3fc11ca3..a4e4e87c 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -56,6 +56,13 @@ lasso_node_get_attr(LassoNode *node, const xmlChar *name) return (class->get_attr(node, name)); } +xmlChar * +lasso_node_get_attr_value(LassoNode *node, const xmlChar *name) +{ + LassoNodeClass *class = LASSO_NODE_GET_CLASS(node); + return (class->get_attr_value(node, name)); +} + GPtrArray * lasso_node_get_attrs(LassoNode *node) { @@ -293,6 +300,12 @@ lasso_node_impl_get_attr(LassoNode *node, const xmlChar *name) return (NULL); } +static xmlChar * +lasso_node_impl_get_attr_value(LassoNode *node, const xmlChar *name) +{ + return (lasso_node_get_attr(node, name)->children->content); +} + static GPtrArray * lasso_node_impl_get_attrs(LassoNode *node) { @@ -360,8 +373,8 @@ lasso_node_impl_get_name(LassoNode *node) static void lasso_node_impl_dump(LassoNode *node, - const xmlChar *encoding, - int format) + const xmlChar *encoding, + int format) { xmlChar *ret; int len; @@ -460,7 +473,7 @@ lasso_node_impl_url_encode(LassoNode *node, if (sign_method > 0 && key_file != NULL) { switch (sign_method) { - case LassoUrlEncodeRsaSha1: + case lassoUrlEncodeRsaSha1: msg = g_string_append(msg, "&SigAlg="); msg = g_string_append(msg, lasso_str_escape("http://www.w3.org/2000/09/xmldsig#rsa-sha1")); doc = lasso_str_sign(msg->str, xmlSecTransformRsaSha1Id, key_file); @@ -471,7 +484,7 @@ lasso_node_impl_url_encode(LassoNode *node, msg = g_string_append(msg, str2); xmlFree(str2); break; - case LassoUrlEncodeDsaSha1: + case lassoUrlEncodeDsaSha1: msg = g_string_append(msg, "&SigAlg="); msg = g_string_append(msg, lasso_str_escape("http://www.w3.org/2000/09/xmldsig#dsa-sha1")); doc = lasso_str_sign(msg->str, xmlSecTransformDsaSha1Id, key_file); @@ -706,6 +719,7 @@ lasso_node_class_init(LassoNodeClass *class) class->build_query = lasso_node_impl_build_query; class->dump = lasso_node_impl_dump; class->get_attr = lasso_node_impl_get_attr; + class->get_attr_value = lasso_node_impl_get_attr_value; class->get_attrs = lasso_node_impl_get_attrs; class->get_child = lasso_node_impl_get_child; class->get_children = lasso_node_impl_get_children; diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h index 3060779a..9d7fe40f 100644 --- a/lasso/xml/xml.h +++ b/lasso/xml/xml.h @@ -66,6 +66,8 @@ struct _LassoNodeClass { int); LassoAttr* (* get_attr) (LassoNode *, const xmlChar *); + xmlChar* (* get_attr_value) (LassoNode *node, + const xmlChar *name); GPtrArray* (* get_attrs) (LassoNode *); LassoNode* (* get_child) (LassoNode *, const xmlChar *); @@ -104,9 +106,9 @@ struct _LassoNodeClass { }; typedef enum { - LassoUrlEncodeRsaSha1 = 1, - LassoUrlEncodeDsaSha1 -} LassoUrlEncodeSignMethod; + lassoUrlEncodeRsaSha1 = 1, + lassoUrlEncodeDsaSha1 +} lassoUrlEncodeSignMethod; LASSO_EXPORT GType lasso_node_get_type(void); LASSO_EXPORT LassoNode* lasso_node_new(xmlNodePtr node); @@ -122,6 +124,9 @@ LASSO_EXPORT LassoAttr* lasso_node_get_attr (LassoNode *node, LASSO_EXPORT GPtrArray* lasso_node_get_attrs (LassoNode *node); +LASSO_EXPORT xmlChar* lasso_node_get_attr_value (LassoNode *node, + const xmlChar *name); + LASSO_EXPORT LassoNode* lasso_node_get_child (LassoNode *node, const xmlChar *name); diff --git a/python/examples/test.py b/python/examples/test.py index d3df943d..5fcd622e 100755 --- a/python/examples/test.py +++ b/python/examples/test.py @@ -4,7 +4,7 @@ import sys sys.path.insert(0, '../') import lasso -print lasso.init() +lasso.init() req = lasso.AuthnRequest("providerid.com", "federated", @@ -28,7 +28,7 @@ print query res = lasso.AuthnResponse(query, 1, "../../examples/rsapub.pem", - "../../examples/rsakey2.pem", + "../../examples/rsakey.pem", "../../examples/rsacert.pem", 0) res.init("toto", 1) @@ -36,7 +36,7 @@ res.init("toto", 1) assertion = lasso.assertion_build(res, "http://idprovider.com") authentication_statement = lasso.authentication_statement_build("password", "3", - "tralalal", + "tralala", "dslqkjfslfj", "http://service-provider.com", "federated", @@ -46,8 +46,15 @@ authentication_statement = lasso.authentication_statement_build("password", "bearer") lasso.assertion_add_authenticationStatement(assertion, authentication_statement); res.add_assertion(assertion) - res.node.dump("iso-8859-1", 1) + +assertion.verify_signature("../../examples/rootcert.pem") +res.node.get_child("Assertion").verify_signature("../../examples/rootcert.pem") + +status = res.node.get_child("Status") +status_code = status.get_child("StatusCode") +print status_code.get_attr_value("Value") + #req.node.destroy() -#print lasso.shutdown() +#lasso.shutdown() diff --git a/python/lassomod.c b/python/lassomod.c index bad6649f..407d3778 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -38,9 +38,12 @@ static PyMethodDef lasso_methods[] = { {"check_version_ext", check_version_ext, METH_VARARGS}, /* py_xml.h */ - {"node_dump", node_dump, METH_VARARGS}, - {"node_unref", node_unref, METH_VARARGS}, - {"node_url_encode", node_url_encode, METH_VARARGS}, + {"node_dump", node_dump, METH_VARARGS}, + {"node_get_attr_value", node_get_attr_value, METH_VARARGS}, + {"node_get_child", node_get_child, METH_VARARGS}, + {"node_unref", node_unref, METH_VARARGS}, + {"node_url_encode", node_url_encode, METH_VARARGS}, + {"node_verify_signature", node_verify_signature, METH_VARARGS}, /* py_single_sign_on_and_federation.h */ {"authn_request_getattr", authn_request_getattr, METH_VARARGS}, diff --git a/python/py_lasso.c b/python/py_lasso.c index 5fa8f931..0ff9c751 100644 --- a/python/py_lasso.c +++ b/python/py_lasso.c @@ -31,7 +31,8 @@ PyObject *init(PyObject *self, PyObject *args) { } PyObject *shutdown(PyObject *self, PyObject *args) { - return (int_wrap(lasso_shutdown())); + //return (int_wrap(lasso_shutdown())); + return (int_wrap(0)); } PyObject *check_version_exact(PyObject *self, PyObject *args) { diff --git a/python/setup.py b/python/setup.py index 63d65fee..290ad5ec 100755 --- a/python/setup.py +++ b/python/setup.py @@ -180,10 +180,10 @@ extract_cflags(xmlsec1_cflags) extract_libs(xmlsec1_libs) # FIXME : cflags & libs for lasso -#include_dirs.append('..') -#library_dirs.append('../lasso/.libs') -include_dirs.append('/usr/local/include') -library_dirs.append('/usr/local/lib') +include_dirs.append('..') +library_dirs.append('../lasso/.libs') +#include_dirs.append('/usr/local/include') +#library_dirs.append('/usr/local/lib') libraries.append('lasso') em = Extension("lassomod", diff --git a/python/wrap_objs.c b/python/wrap_objs.c index d175f6ea..777aa8e0 100644 --- a/python/wrap_objs.c +++ b/python/wrap_objs.c @@ -70,7 +70,7 @@ PyObject *charPtrConst_wrap(const char *str) { /* Functions to wrap LibXML objects -> Python objects */ /*****************************************************************************/ -PyObject *wrap_xmlCharPtr(xmlChar *str) { +PyObject *xmlCharPtr_wrap(xmlChar *str) { PyObject *ret; if (str == NULL) { diff --git a/python/wrap_objs.h b/python/wrap_objs.h index a846d00a..ef3356de 100644 --- a/python/wrap_objs.h +++ b/python/wrap_objs.h @@ -55,7 +55,7 @@ PyObject *int_wrap(int val); PyObject *charPtr_wrap(char *str); PyObject *charPtrConst_wrap(const char *str); -PyObject *wrap_xmlCharPtr(xmlChar *str); +PyObject *xmlCharPtr_wrap(xmlChar *str); PyObject *wrap_xmlCharPtrConst(const xmlChar *str); PyObject *wrap_xmlDocPtr(xmlDocPtr doc); PyObject *wrap_xmlNodePtr(xmlNodePtr node); diff --git a/python/xml/py_xml.c b/python/xml/py_xml.c index 1ce046eb..d2816ceb 100644 --- a/python/xml/py_xml.c +++ b/python/xml/py_xml.c @@ -60,6 +60,40 @@ PyObject *node_dump(PyObject *self, PyObject *args) { return (Py_None); } +PyObject *node_get_attr_value(PyObject *self, PyObject *args) { + PyObject *node_obj; + const xmlChar *name; + xmlChar *ret; + + if (CheckArgs(args, "OS:node_get_attr_value")) { + if(!PyArg_ParseTuple(args, (char *) "Os:node_get_attr_value", + &node_obj, &name)) + return NULL; + } + else return NULL; + + ret = lasso_node_get_attr_value(LassoNode_get(node_obj), name); + + return (xmlCharPtr_wrap(ret)); +} + +PyObject *node_get_child(PyObject *self, PyObject *args) { + PyObject *node_obj; + const xmlChar *name; + LassoNode *ret; + + if (CheckArgs(args, "OS:node_get_child")) { + if(!PyArg_ParseTuple(args, (char *) "Os:node_get_child", + &node_obj, &name)) + return NULL; + } + else return NULL; + + ret = lasso_node_get_child(LassoNode_get(node_obj), name); + + return (LassoNode_wrap(ret)); +} + PyObject *node_unref(PyObject *self, PyObject *args) { PyObject *node_obj; @@ -94,3 +128,21 @@ PyObject *node_url_encode(PyObject *self, PyObject *args) { return (charPtr_wrap(ret)); } + +PyObject *node_verify_signature(PyObject *self, PyObject *args) { + PyObject *node_obj; + const gchar *certificate_file; + gint ret; + + if (CheckArgs(args, "OS:node_verify_signature")) { + if(!PyArg_ParseTuple(args, (char *) "Os:node_verify_signature", + &node_obj, &certificate_file)) + return NULL; + } + else return NULL; + + ret = lasso_node_verify_signature(LassoNode_get(node_obj), + certificate_file); + + return (int_wrap(ret)); +} diff --git a/python/xml/py_xml.h b/python/xml/py_xml.h index a1a186ab..2de90e1a 100644 --- a/python/xml/py_xml.h +++ b/python/xml/py_xml.h @@ -36,7 +36,10 @@ typedef struct { PyObject *LassoNode_wrap(LassoNode *node); PyObject *node_dump(PyObject *self, PyObject *args); +PyObject *node_get_attr_value(PyObject *self, PyObject *args); +PyObject *node_get_child(PyObject *self, PyObject *args); PyObject *node_unref(PyObject *self, PyObject *args); PyObject *node_url_encode(PyObject *self, PyObject *args); +PyObject *node_verify_signature(PyObject *self, PyObject *args); #endif /* __PYLASSO_PY_XML_H__ */ |
