From 2e5edf85b8c23ef73069dbd37e453c7e2d30545a Mon Sep 17 00:00:00 2001 From: Nicolas Clapies Date: Tue, 11 May 2004 16:47:33 +0000 Subject: name identifer mapping c and python binding updates --- python/lasso.py | 90 ++++++++++++++------ python/lassomod.c | 14 +++- .../protocols/py_name_identifier_mapping_request.c | 34 ++++++++ .../protocols/py_name_identifier_mapping_request.h | 2 + .../py_name_identifier_mapping_response.c | 95 +++++++++++++++++++--- .../py_name_identifier_mapping_response.h | 6 +- python/setup.py | 9 +- 7 files changed, 205 insertions(+), 45 deletions(-) (limited to 'python') diff --git a/python/lasso.py b/python/lasso.py index e89463b0..3bcfa3f4 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -226,6 +226,18 @@ class LibNameIdentifierMappingRequest(Node): def set_consent(self, consent): lassomod.lib_name_identifier_mapping_request_set_consent(self, consent) +class LibNameIdentifierMappingResponse(Node): + def __init__(self, _obj = None): + """ + """ + if _obj != None: + self._o = _obj + return + _obj = lassomod.lib_name_identifier_mapping_response_new() + if _obj is None: + raise Error('lasso_lib_name_identifier_mapping_response_new() failed') + Node.__init__(self, _obj=_obj) + class SamlNameIdentifier(Node): def __init__(self, _obj=None): @@ -346,10 +358,10 @@ class FederationTerminationNotification(LibFederationTerminationNotification): new_from_query = classmethod(new_from_query) class LogoutRequest(LibLogoutRequest): - def __init__(self, obj): + def __init__(self, _obj): """ """ - self._o = obj + self._o = _obj LibLogoutRequest.__init__(self, _obj = self._o) def new(cls, providerID, nameIdentifier, nameQualifier, format): @@ -369,10 +381,10 @@ class LogoutRequest(LibLogoutRequest): class LogoutResponse(LibLogoutResponse): - def __init__(self, obj): + def __init__(self, _obj): """ """ - self._o = obj + self._o = _obj LibLogoutResponse.__init__(self, _obj = self._o) def new_from_request_soap(cls, envelope, providerID, status_code_value): @@ -402,35 +414,59 @@ class LogoutResponse(LibLogoutResponse): class NameIdentifierMappingRequest(LibNameIdentifierMappingRequest): - def __init__(self, providerID, nameIdentifier, nameQualifier, format, - _obj=None): + def __init__(self, _obj): """ """ - if _obj != None: - self._o = _obj - return - _obj = lassomod.name_identifier_mapping_request_new(providerID, - nameIdentifier, - nameQualifier, - format) - if _obj is None: - raise Error('lasso_name_identifier_mapping_request_new() failed') - LibNameIdentifierMappingRequest.__init__(self, _obj=_obj) + self._o = _obj + LibNameIdentifierMappingRequest.__init__(self, _obj = self._o) + def new(cls, providerID, nameIdentifier, nameQualifier, format): + obj = lassomod.name_identifier_mapping_request_new(providerID, nameIdentifier, nameQualifier, format) + return NameIdentifierMappingRequest(obj) + new = classmethod(new) -class NameIdentifierMappingResponse(Node): - def __init__(self, providerID, statusCodeValue, request, _obj=None): + def new_from_soap(cls, envelope): + obj = lassomod.name_identifier_mapping_request_new_from_soap(envelope) + return NameIdentifierMappingRequest(obj) + new_from_soap = classmethod(new_from_soap) + + def new_from_query(cls, query): + obj = lassomod.name_identifier_mapping_request_new_from_query(query) + return NameIdentifierMappingRequest(obj) + new_from_query = classmethod(new_from_query) + + +class NameIdentifierMappingResponse(LibNameIdentifierMappingResponse): + def __init__(self, _obj): """ """ - if _obj != None: - self._o = _obj - return - _obj = lassomod.name_identifier_mapping_response_new(providerID, - statusCodeValue, - request) - if _obj is None: - raise Error('lasso_name_identifier_mapping_response_new() failed') - Node.__init__(self, _obj=_obj) + self._o = _obj + LibNameIdentifierMappingResponse.__init__(self, _obj = self._o) + + def new_from_request_soap(cls, envelope, providerID, status_code_value): + obj = lassomod.name_identifier_mapping_response_new_from_request_soap(envelope, providerID, status_code_value) + return NameIdentifierMappingResponse(obj) + new_from_request_soap = classmethod(new_from_request_soap) + + def new_from_soap(cls, envelope): + obj = lassomod.name_identifier_mapping_response_new_from_soap(envelope) + return NameIdentifierMappingResponse(obj) + new_from_soap = classmethod(new_from_soap) + + def new_from_dump(cls, dump): + obj = lassomod.name_identifier_mapping_response_new_from_dump(dump) + return NameIdentifierMappingResponse(obj) + new_from_dump = classmethod(new_from_dump) + + def new_from_request_query(cls, query, providerID, status_code_value): + obj = lassomod.name_identifier_mapping_response_new_from_request_query(query, providerID, status_code_value) + return NameIdentifierMappingResponse(obj); + new_from_request_query = classmethod(new_from_request_query) + + def new_from_query(cls, query): + obj = lassomod.name_identifier_mapping_response_new_from_query(query) + return NameIdentifierMappingResponse(obj); + new_from_query = classmethod(new_from_query) class RegisterNameIdentifierRequest(Node): diff --git a/python/lassomod.c b/python/lassomod.c index 30e048ca..fa9fae8e 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -33,6 +33,7 @@ #include "xml/py_lib_logout_request.h" #include "xml/py_lib_logout_response.h" #include "xml/py_lib_name_identifier_mapping_request.h" +#include "xml/py_lib_name_identifier_mapping_response.h" #include "xml/py_lib_register_name_identifier_request.h" #include "xml/py_saml_assertion.h" #include "xml/py_saml_authentication_statement.h" @@ -100,6 +101,9 @@ static PyMethodDef lasso_methods[] = { {"lib_name_identifier_mapping_request_new", lib_name_identifier_mapping_request_new, METH_VARARGS}, {"lib_name_identifier_mapping_request_set_consent", lib_name_identifier_mapping_request_set_consent, METH_VARARGS}, + /* py_lib_name_identifier_mapping_response.h */ + {"lib_name_identifier_mapping_response_new", lib_name_identifier_mapping_response_new, METH_VARARGS}, + /* py_lib_register_name_identifier_request.h */ {"lib_register_name_identifier_request_new", lib_register_name_identifier_request_new, METH_VARARGS}, {"lib_register_name_identifier_request_set_relayState", lib_register_name_identifier_request_set_relayState, METH_VARARGS}, @@ -150,10 +154,16 @@ static PyMethodDef lasso_methods[] = { {"logout_response_new_from_query", logout_response_new_from_query, METH_VARARGS}, /* py_name_identifier_mapping_request.h */ - {"name_identifier_mapping_request_new", name_identifier_mapping_request_new, METH_VARARGS}, + {"name_identifier_mapping_request_new", name_identifier_mapping_request_new, METH_VARARGS}, + {"name_identifier_mapping_request_new_from_soap", name_identifier_mapping_request_new_from_soap, METH_VARARGS}, + {"name_identifier_mapping_request_new_from_query", name_identifier_mapping_request_new_from_query, METH_VARARGS}, /* py_name_identifier_mapping_response.h */ - {"name_identifier_mapping_response_new", name_identifier_mapping_response_new, METH_VARARGS}, + {"name_identifier_mapping_response_new_from_request_soap", name_identifier_mapping_response_new_from_request_soap, METH_VARARGS}, + {"name_identifier_mapping_response_new_from_soap", name_identifier_mapping_response_new_from_soap, METH_VARARGS}, + {"name_identifier_mapping_response_new_from_dump", name_identifier_mapping_response_new_from_dump, METH_VARARGS}, + {"name_identifier_mapping_response_new_from_request_query", name_identifier_mapping_response_new_from_request_query, METH_VARARGS}, + {"name_identifier_mapping_response_new_from_query", name_identifier_mapping_response_new_from_query, METH_VARARGS}, /* py_register_name_identifier_request.h */ {"register_name_identifier_request_new", register_name_identifier_request_new, METH_VARARGS}, diff --git a/python/protocols/py_name_identifier_mapping_request.c b/python/protocols/py_name_identifier_mapping_request.c index 1d287fc8..975ac9b8 100644 --- a/python/protocols/py_name_identifier_mapping_request.c +++ b/python/protocols/py_name_identifier_mapping_request.c @@ -62,3 +62,37 @@ PyObject *name_identifier_mapping_request_new(PyObject *self, PyObject *args) { return (LassoNameIdentifierMappingRequest_wrap(LASSO_NAME_IDENTIFIER_MAPPING_REQUEST(request))); } + +PyObject *name_identifier_mapping_request_new_from_soap(PyObject *self, PyObject *args) { + const xmlChar *soap_buffer; + + LassoNode *request; + + if (CheckArgs(args, "S:name_identifier_mapping_request_new_from_soap")) { + if(!PyArg_ParseTuple(args, (char *) "s:name_identifier_mapping_request_new_from_soap", + &soap_buffer)) + return NULL; + } + else return NULL; + + request = lasso_name_identifier_mapping_request_new_from_soap(soap_buffer); + + return (LassoNameIdentifierMappingRequest_wrap(LASSO_NAME_IDENTIFIER_MAPPING_REQUEST(request))); +} + +PyObject *name_identifier_mapping_request_new_from_query(PyObject *self, PyObject *args) { + const xmlChar *query; + + LassoNode *request; + + if (CheckArgs(args, "S:name_identifier_mapping_request_new_from_query")) { + if(!PyArg_ParseTuple(args, (char *) "s:name_identifier_mapping_request_new_from_query", + &query)) + return NULL; + } + else return NULL; + + request = lasso_name_identifier_mapping_request_new_from_query(query); + + return (LassoNameIdentifierMappingRequest_wrap(LASSO_NAME_IDENTIFIER_MAPPING_REQUEST(request))); +} diff --git a/python/protocols/py_name_identifier_mapping_request.h b/python/protocols/py_name_identifier_mapping_request.h index f9e17f39..647e6e80 100644 --- a/python/protocols/py_name_identifier_mapping_request.h +++ b/python/protocols/py_name_identifier_mapping_request.h @@ -37,5 +37,7 @@ typedef struct { PyObject *LassoNameIdentifierMappingRequest_wrap(LassoNameIdentifierMappingRequest *request); PyObject *name_identifier_mapping_request_new(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_request_new_from_soap(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_request_new_from_query(PyObject *self, PyObject *args); #endif /* __PYLASSO_PY_NAME_IDENTIFIER_MAPPING_REQUEST_H__ */ diff --git a/python/protocols/py_name_identifier_mapping_response.c b/python/protocols/py_name_identifier_mapping_response.c index 6cd90c57..39d8798c 100644 --- a/python/protocols/py_name_identifier_mapping_response.c +++ b/python/protocols/py_name_identifier_mapping_response.c @@ -42,24 +42,97 @@ PyObject *LassoNameIdentifierMappingResponse_wrap(LassoNameIdentifierMappingResp /******************************************************************************/ -PyObject *name_identifier_mapping_response_new(PyObject *self, PyObject *args) { - const xmlChar *providerID; - const xmlChar *statusCodeValue; - PyObject *request_obj; +PyObject *name_identifier_mapping_response_new_from_request_soap(PyObject *self, PyObject *args) { + const xmlChar *request_soap_dump; + const xmlChar *providerID; + const xmlChar *status_code_value; - LassoNode *response; + LassoNode *response = NULL; - if (CheckArgs(args, "SSO:name_identifier_mapping_response_new")) { - if(!PyArg_ParseTuple(args, (char *) "ssO:name_identifier_mapping_response_new", + if (CheckArgs(args, "SSS:name_identifier_mapping_response_new_from_request_soap")) { + if(!PyArg_ParseTuple(args, (char *) "sss:name_identifier_mapping_response_new_from_request_soap", + &request_soap_dump, &providerID, - &statusCodeValue, &request_obj)) + &status_code_value)) return NULL; } else return NULL; - response = lasso_name_identifier_mapping_response_new(providerID, - statusCodeValue, - LassoNameIdentifierMappingRequest_get(request_obj)); + response = lasso_name_identifier_mapping_response_new_from_request_soap(request_soap_dump, + providerID, + status_code_value); + + return (LassoNameIdentifierMappingResponse_wrap(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(response))); +} + +PyObject *name_identifier_mapping_response_new_from_soap(PyObject *self, PyObject *args) { + const xmlChar *response_soap_dump; + + LassoNode *response = NULL; + + if (CheckArgs(args, "S:name_identifier_mapping_response_new_from_soap")) { + if(!PyArg_ParseTuple(args, (char *) "s:name_identifier_mapping_response_new_from_soap", + &response_soap_dump)) + return NULL; + } + else return NULL; + + response = lasso_name_identifier_mapping_response_new_from_soap(response_soap_dump); + + return (LassoNameIdentifierMappingResponse_wrap(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(response))); +} + +PyObject *name_identifier_mapping_response_new_from_dump(PyObject *self, PyObject *args) { + const xmlChar *dump; + + LassoNode *response = NULL; + + if (CheckArgs(args, "S:name_identifier_mapping_response_new_from_dump")) { + if(!PyArg_ParseTuple(args, (char *) "s:name_identifier_mapping_response_new_from_dump", + &dump)) + return NULL; + } + else return NULL; + + response = lasso_name_identifier_mapping_response_new_from_soap(dump); + + return (LassoNameIdentifierMappingResponse_wrap(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(response))); +} + +PyObject *name_identifier_mapping_response_new_from_request_query(PyObject *self, PyObject *args) { + const xmlChar *query; + const xmlChar *providerID; + const xmlChar *status_code_value; + + LassoNode *response = NULL; + + if (CheckArgs(args, "SSS:name_identifier_mapping_response_new_from_request_query")) { + if(!PyArg_ParseTuple(args, (char *) "sss:name_identifier_mapping_response_new_from_request_query", + &query, + &providerID, + &status_code_value)) + return NULL; + } + else return NULL; + + response = lasso_name_identifier_mapping_response_new_from_request_query(query, providerID, status_code_value); + + return (LassoNameIdentifierMappingResponse_wrap(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(response))); +} + +PyObject *name_identifier_mapping_response_new_from_query(PyObject *self, PyObject *args) { + const xmlChar *query; + + LassoNode *response = NULL; + + if (CheckArgs(args, "S:name_identifier_mapping_response_new_from_query")) { + if(!PyArg_ParseTuple(args, (char *) "s:name_identifier_mapping_response_new_from_query", + &query)) + return NULL; + } + else return NULL; + + response = lasso_name_identifier_mapping_response_new_from_query(query); return (LassoNameIdentifierMappingResponse_wrap(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(response))); } diff --git a/python/protocols/py_name_identifier_mapping_response.h b/python/protocols/py_name_identifier_mapping_response.h index 50ac6a42..f2fc0ef1 100644 --- a/python/protocols/py_name_identifier_mapping_response.h +++ b/python/protocols/py_name_identifier_mapping_response.h @@ -35,6 +35,10 @@ typedef struct { #define LassoNameIdentifierMappingResponse_get(v) (((v) == Py_None) ? NULL : (((LassoNameIdentifierMappingResponse_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj)) PyObject *LassoNameIdentifierMappingResponse_wrap(LassoNameIdentifierMappingResponse *response); -PyObject *name_identifier_mapping_response_new(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_response_new_from_request_soap(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_response_new_from_soap(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_response_new_from_dump(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_response_new_from_request_query(PyObject *self, PyObject *args); +PyObject *name_identifier_mapping_response_new_from_query(PyObject *self, PyObject *args); #endif /* __PYLASSO_PY_NAME_IDENTIFIER_MAPPING_RESPONSE_H__ */ diff --git a/python/setup.py b/python/setup.py index 49aadb6e..bd57b91a 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", @@ -195,6 +195,7 @@ em = Extension("lassomod", "xml/py_lib_logout_request.c", "xml/py_lib_logout_response.c", "xml/py_lib_name_identifier_mapping_request.c", + "xml/py_lib_name_identifier_mapping_response.c", "xml/py_lib_register_name_identifier_request.c", "xml/py_saml_assertion.c", "xml/py_saml_authentication_statement.c", -- cgit