diff options
| author | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-25 09:29:28 +0000 |
|---|---|---|
| committer | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-25 09:29:28 +0000 |
| commit | 890c5150e4e0ed3956d95d506ec391645a265090 (patch) | |
| tree | d51709f26bde777749ab7740d81c3aa863315e27 /python | |
| parent | 4b3094b60482030f773889d1395b17a2390c7473 (diff) | |
| download | lasso-890c5150e4e0ed3956d95d506ec391645a265090.tar.gz lasso-890c5150e4e0ed3956d95d506ec391645a265090.tar.xz lasso-890c5150e4e0ed3956d95d506ec391645a265090.zip | |
fix the problem of setting the user environ in SOAP method :
the problem : process_request_msg needs usr environ to verify federation
and authentication.
a solution :
first load the request msg
get the name identifier of the request
find the user dump from the name identifier and load it in logout object
process the request
see python/examples/logout.py for the methods.
Diffstat (limited to 'python')
| -rw-r--r-- | python/environs/py_logout.c | 66 | ||||
| -rw-r--r-- | python/environs/py_logout.h | 4 | ||||
| -rw-r--r-- | python/examples/logout.py | 13 |
3 files changed, 61 insertions, 22 deletions
diff --git a/python/environs/py_logout.c b/python/environs/py_logout.c index 35fa483e..44beca6a 100644 --- a/python/environs/py_logout.c +++ b/python/environs/py_logout.c @@ -56,13 +56,15 @@ PyObject *logout_getattr(PyObject *self, PyObject *args) { if (!strcmp(attr, "__members__")) return Py_BuildValue("[ssss]", "user", "msg_url", "msg_body", - "msg_relayState"); + "nameIdentifier", "msg_relayState"); if (!strcmp(attr, "user")) return (LassoUser_wrap(LASSO_PROFILE_CONTEXT(logout)->user)); if (!strcmp(attr, "msg_url")) return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(logout)->msg_url)); if (!strcmp(attr, "msg_body")) return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(logout)->msg_body)); + if (!strcmp(attr, "nameIdentifier")) + return (charPtrConst_wrap(logout->nameIdentifier)); if (!strcmp(attr, "msg_relayState")) return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(logout)->msg_relayState)); @@ -72,20 +74,20 @@ PyObject *logout_getattr(PyObject *self, PyObject *args) { PyObject *logout_new(PyObject *self, PyObject *args) { + gint provider_type; PyObject *server_obj, *user_obj; LassoLogout *logout; - gint provider_type; - if (CheckArgs(args, "OOI:logout_new")) { - if(!PyArg_ParseTuple(args, (char *) "OOi:logout_new", - &server_obj, &user_obj, &provider_type)) + if (CheckArgs(args, "IOo:logout_new")) { + if(!PyArg_ParseTuple(args, (char *) "IO|O:logout_new", + &provider_type, &server_obj, &user_obj)) return NULL; } else return NULL; - logout = lasso_logout_new(LassoServer_get(server_obj), - LassoUser_get(user_obj), - provider_type); + logout = lasso_logout_new(provider_type, + LassoServer_get(server_obj), + LassoUser_get(user_obj)); return (LassoLogout_wrap(logout)); } @@ -149,12 +151,8 @@ PyObject *logout_get_next_providerID(PyObject *self, PyObject *args) { else return NULL; remote_providerID = lasso_logout_get_next_providerID(LassoLogout_get(logout_obj)); - if(remote_providerID==NULL){ - Py_INCREF(Py_None); - return (Py_None); - } - return (charPtr_wrap(remote_providerID)); + return (charPtrConst_wrap(remote_providerID)); } PyObject *logout_init_request(PyObject *self, PyObject *args) { @@ -174,20 +172,54 @@ PyObject *logout_init_request(PyObject *self, PyObject *args) { return(int_wrap(codeError)); } -PyObject *logout_process_request_msg(PyObject *self, PyObject *args) { +PyObject *logout_load_request_msg(PyObject *self, PyObject *args){ PyObject *logout_obj; gchar *request_msg; gint request_method; gint codeError; - if (CheckArgs(args, "OSI:logout_process_request_msg")) { - if(!PyArg_ParseTuple(args, (char *) "Osi:logout_process_request_msg", + if (CheckArgs(args, "OSI:logout_load_request_msg")) { + if(!PyArg_ParseTuple(args, (char *) "Osi:logout_load_request_msg", &logout_obj, &request_msg, &request_method)) return NULL; } else return NULL; - codeError = lasso_logout_process_request_msg(LassoLogout_get(logout_obj), request_msg, request_method); + codeError = lasso_logout_load_request_msg(LassoLogout_get(logout_obj), request_msg, request_method); + + return(int_wrap(codeError)); +} + +PyObject *logout_load_user_dump(PyObject *self, PyObject *args){ + PyObject *logout_obj; + gchar *user_dump; + gint codeError; + + if (CheckArgs(args, "OS:logout_load_request_msg")) { + if(!PyArg_ParseTuple(args, (char *) "Os:logout_load_request_msg", + &logout_obj, &user_dump)) + return NULL; + } + else return NULL; + + codeError = lasso_logout_load_user_dump(LassoLogout_get(logout_obj), user_dump); + + return(int_wrap(codeError)); +} + + +PyObject *logout_process_request(PyObject *self, PyObject *args) { + PyObject *logout_obj; + gint codeError; + + if (CheckArgs(args, "O:logout_process_request_msg")) { + if(!PyArg_ParseTuple(args, (char *) "O:logout_process_request_msg", + &logout_obj)) + return NULL; + } + else return NULL; + + codeError = lasso_logout_process_request(LassoLogout_get(logout_obj)); return(int_wrap(codeError)); } diff --git a/python/environs/py_logout.h b/python/environs/py_logout.h index 773ec548..8e1f271a 100644 --- a/python/environs/py_logout.h +++ b/python/environs/py_logout.h @@ -46,8 +46,10 @@ PyObject *logout_build_response_msg(PyObject *self, PyObject *args); PyObject *logout_destroy(PyObject *self, PyObject *args); PyObject *logout_get_next_providerID(PyObject *self, PyObject *args); PyObject *logout_init_request(PyObject *self, PyObject *args); +PyObject *logout_load_request_msg(PyObject *self, PyObject *args); +PyObject *logout_load_user_dump(PyObject *self, PyObject *args); PyObject *logout_new(PyObject *self, PyObject *args); -PyObject *logout_process_request_msg(PyObject *self, PyObject *args); +PyObject *logout_process_request(PyObject *self, PyObject *args); PyObject *logout_process_response_msg(PyObject *self, PyObject *args); #endif /* __PYLASSO_PY_LOGOUT_H__ */ diff --git a/python/examples/logout.py b/python/examples/logout.py index c4f13254..60cafe4c 100644 --- a/python/examples/logout.py +++ b/python/examples/logout.py @@ -37,7 +37,7 @@ idpuser_dump = "<LassoUser><LassoAssertions><LassoAssertion RemoteProviderID=\"h # SP1 build a request : sp1user = lasso.User.new_from_dump(sp1user_dump) -sp1logout = lasso.Logout.new(sp1server, sp1user, lasso.providerTypeSp) +sp1logout = lasso.Logout.new(lasso.providerTypeSp, sp1server, sp1user) sp1logout.init_request() sp1logout.build_request_msg() @@ -48,8 +48,7 @@ sp1logout.destroy() # IDP process request and return a response : idpuser = lasso.User.new_from_dump(idpuser_dump) -idplogout = lasso.Logout.new(idpserver, idpuser, lasso.providerTypeIdp) - +idplogout = lasso.Logout.new(lasso.providerTypeIdp, idpserver) if lasso.get_request_type_from_soap_msg(msg_body)==lasso.requestTypeLogout: print "it's a logout request !" @@ -57,7 +56,12 @@ if lasso.get_request_type_from_soap_msg(msg_body)==lasso.requestTypeLogout: #fake response, only for test ! response_msg_body = "<Envelope><LogoutResponse><ProviderID>https://service-provider2:2003/liberty-alliance/metadata</ProviderID><Status><StatusCode Value=\"Samlp:Success\"></StatusCode></Status></LogoutResponse></Envelope>" -idplogout.process_request_msg(msg_body, lasso.httpMethodSoap) +idplogout.load_request_msg(msg_body, lasso.httpMethodSoap) +nameIdentifier = idplogout.nameIdentifier +print "get the user dump from NameIdentifier : ", nameIdentifier +idplogout.load_user_dump(idpuser_dump) +idplogout.process_request() + next_provider_id = idplogout.get_next_providerID() while next_provider_id: idplogout.init_request(next_provider_id) @@ -69,5 +73,6 @@ while next_provider_id: next_provider_id = idplogout.get_next_providerID() +idplogout.build_response_msg() print "End of logout" |
