diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/environs/Makefile.am | 4 | ||||
-rw-r--r-- | python/environs/py_lecp.c | 199 | ||||
-rw-r--r-- | python/environs/py_lecp.h | 58 | ||||
-rw-r--r-- | python/lasso.py | 61 | ||||
-rw-r--r-- | python/lassomod.c | 14 |
5 files changed, 329 insertions, 7 deletions
diff --git a/python/environs/Makefile.am b/python/environs/Makefile.am index 72a98510..1d12ea3c 100644 --- a/python/environs/Makefile.am +++ b/python/environs/Makefile.am @@ -8,12 +8,12 @@ INCLUDES = \ $(NULL) -ENVSOURCES = py_federation_termination.c py_login.c py_logout.c py_profile_context.c py_register_name_identifier.c py_server.c py_user.c +ENVSOURCES = py_federation_termination.c py_lecp.c py_login.c py_logout.c py_profile_context.c py_register_name_identifier.c py_server.c py_user.c if WITH_PYTHON noinst_LIBRARIES = libenvirons.a libenvirons_a_SOURCES = $(ENVSOURCES) endif -EXTRA_DIST = $(ENVSOURCES) py_federation_termination.h py_login.h py_logout.h py_profile_context.h py_register_name_identifier.h py_server.h py_user.h +EXTRA_DIST = $(ENVSOURCES) py_federation_termination.h py_lecp.h py_login.h py_logout.h py_profile_context.h py_register_name_identifier.h py_server.h py_user.h diff --git a/python/environs/py_lecp.c b/python/environs/py_lecp.c new file mode 100644 index 00000000..2859bd3c --- /dev/null +++ b/python/environs/py_lecp.c @@ -0,0 +1,199 @@ +/* $Id$ + * + * PyLasso -- Python bindings for Lasso library + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Nicolas Clapies <nclapies@entrouvert.com> + * Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "../lassomod.h" + +#include "py_lecp.h" + +PyObject *LassoLecp_wrap(LassoLecp *lecp) { + PyObject *ret; + + if (lecp == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = PyCObject_FromVoidPtrAndDesc((void *) lecp, + (char *) "LassoLecp *", NULL); + return (ret); +} + +/******************************************************************************/ + +PyObject *lecp_getattr(PyObject *self, PyObject *args) { + PyObject *lecp_obj; + LassoLecp *lecp; + const char *attr; + + if (CheckArgs(args, "OS:lecp_get_attr")) { + if (!PyArg_ParseTuple(args, "Os:lecp_get_attr", &lecp_obj, &attr)) + return NULL; + } + else return NULL; + + lecp = LassoLecp_get(lecp_obj); + + if (!strcmp(attr, "__members__")) + return Py_BuildValue("[ssss]", "user", "msg_url", "msg_body", + "msg_relayState"); + if (!strcmp(attr, "msg_url")) + return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(lecp)->msg_url)); + if (!strcmp(attr, "msg_body")) + return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(lecp)->msg_body)); + + Py_INCREF(Py_None); + return (Py_None); +} + +PyObject *lecp_new(PyObject *self, PyObject *args) { + LassoLecp *lecp; + + if (CheckArgs(args, ":lecp_new")) { + if(!PyArg_ParseTuple(args, (char *) ":lecp_new")) + return NULL; + } + else return NULL; + + lecp = lasso_lecp_new(); + + return (LassoLecp_wrap(lecp)); +} + +PyObject *lecp_build_authn_request_envelope_msg(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + gint codeError; + + if (CheckArgs(args, "O:lecp_build_authn_request_envelope_msg")) { + if(!PyArg_ParseTuple(args, (char *) "O:lecp_build_authn_request_envelope_msg", + &lecp_obj)) + return NULL; + } + else return NULL; + +/* codeError = lasso_lecp_build_authn_request_envelope_msg(LassoLecp_get(lecp_obj)); */ + + return(int_wrap(codeError)); +} + +PyObject *lecp_build_authn_response_envelope_msg(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + gint codeError; + + if (CheckArgs(args, "O:lecp_build_authn_response_envelope_msg")) { + if(!PyArg_ParseTuple(args, (char *) "O:lecp_build_authn_response_envelope_msg", + &lecp_obj)) + return NULL; + } + else return NULL; + +/* codeError = lecp_build_authn_response_envelope_msg(LassoLecp_get(lecp_obj)); */ + + return(int_wrap(codeError)); +} + +PyObject *lecp_destroy(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + + if (CheckArgs(args, "O:lecp_destroy")) { + if(!PyArg_ParseTuple(args, (char *) "O:lecp_destroy", + &lecp_obj)) + return NULL; + } + else return NULL; + + lasso_lecp_destroy(LassoLecp_get(lecp_obj)); + + Py_INCREF(Py_None); + return(Py_None); +} + +PyObject *lecp_init_authn_request_envelope(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + gchar *remote_providerID; + gint codeError; + + if (CheckArgs(args, "Os:lecp_init_authn_request_envelope")) { + if(!PyArg_ParseTuple(args, (char *) "Oz:lecp_init_authn_request_envelope", + &lecp_obj, &remote_providerID)) + return NULL; + } + else return NULL; + +/* codeError = lecp_init_authn_request_envelope(LassoLecp_get(lecp_obj), remote_providerID); */ + + return(int_wrap(codeError)); +} + +PyObject *lecp_init_authn_response_envelope(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + gchar *remote_providerID; + gint codeError; + + if (CheckArgs(args, "Os:lecp_init_authn_response_envelope")) { + if(!PyArg_ParseTuple(args, (char *) "Oz:lecp_init_authn_response_envelope", + &lecp_obj, &remote_providerID)) + return NULL; + } + else return NULL; + +/* codeError = lecp_init_authn_request_envelope(LassoLecp_get(lecp_obj), remote_providerID); */ + + return(int_wrap(codeError)); +} + +PyObject *lecp_process_authn_request_envelope_msg(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + gchar *request_msg; + gint request_method; + gint codeError; + + if (CheckArgs(args, "OSI:lecp_process_authn_request_envelope_msg")) { + if(!PyArg_ParseTuple(args, (char *) "Osi:lecp_process_authn_request_envelope_msg", + &lecp_obj, &request_msg, &request_method)) + return NULL; + } + else return NULL; + +/* codeError = lasso_lecp_process_authn_request_envelope_msg(LassoLecp_get(lecp_obj), request_msg, request_method); */ + + return(int_wrap(codeError)); +} + +PyObject *lecp_process_authn_response_envelope_msg(PyObject *self, PyObject *args){ + PyObject *lecp_obj; + gchar *response_msg; + gint response_method; + gint codeError; + + if (CheckArgs(args, "OSI:lecp_process_authn_response_envelope_msg")) { + if(!PyArg_ParseTuple(args, (char *) "Osi:lecp_process_authn_response_envelope_msg", + &lecp_obj, &response_msg, &response_method)) + return NULL; + } + else return NULL; + +/* codeError = lasso_lecp_process_authn_response_envelope_msg(LassoLecp_get(lecp_obj), response_msg, response_method); */ + + return(int_wrap(codeError)); +} diff --git a/python/environs/py_lecp.h b/python/environs/py_lecp.h new file mode 100644 index 00000000..bcf2cd50 --- /dev/null +++ b/python/environs/py_lecp.h @@ -0,0 +1,58 @@ +/* $Id$ + * + * PyLasso -- Python bindings for Lasso library + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Nicolas Clapies <nclapies@entrouvert.com> + * Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __PYLASSO_PY_LECP_H__ +#define __PYLASSO_PY_LECP_H__ + +#include <lasso/environs/lecp.h> + +typedef struct { + PyObject_HEAD + LassoLecp *obj; +} LassoLecp_object; + +#define LassoLecp_get(v) (((v) == Py_None) ? NULL : (((LassoLecp_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj)) +PyObject *LassoLecp_wrap(LassoLecp *lecp); + +PyObject *lecp_getattr(PyObject *self, PyObject *args); + +PyObject *lecp_new(PyObject *self, PyObject *args); + + +PyObject *lecp_build_authn_request_envelope_msg(PyObject *self, PyObject *args); + +PyObject *lecp_build_authn_response_envelope_msg(PyObject *self, PyObject *args); + +PyObject *lecp_destroy(PyObject *self, PyObject *args); + +PyObject *lecp_init_authn_request_envelope(PyObject *self, PyObject *args); + +PyObject *lecp_init_authn_response_envelope(PyObject *self, PyObject *args); + +PyObject *lecp_process_authn_request_envelope_msg(PyObject *self, PyObject *args); + +PyObject *lecp_process_authn_response_envelope_msg(PyObject *self, PyObject *args); + +#endif /* __PYLASSO_PY_LECP_H__ */ diff --git a/python/lasso.py b/python/lasso.py index df9e57ce..bcb86cb3 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -1008,8 +1008,8 @@ class Logout: ret = User(_obj=ret) return ret - def new(cls, server, user, provider_type): - obj = lassomod.logout_new(server, user, provider_type) + def new(cls, provider_type, server, user = None): + obj = lassomod.logout_new(provider_type, server, user) return Logout(obj) new = classmethod(new) @@ -1028,8 +1028,14 @@ class Logout: def init_request(self, remote_providerID = None): return lassomod.logout_init_request(self, remote_providerID); - def process_request_msg(self, request_msg, request_method): - return lassomod.logout_process_request_msg(self, request_msg, request_method); + def load_request_msg(self, request_msg, request_method): + return lassomod.logout_load_request_msg(self, request_msg, request_method); + + def load_user_dump(self, user_dump): + return lassomod.logout_load_user_dump(self, user_dump); + + def process_request(self): + return lassomod.logout_process_request(self); def process_response_msg(self, response_msg, response_method): return lassomod.logout_process_response_msg(self, response_msg, response_method); @@ -1126,3 +1132,50 @@ class RegisterNameIdentifier: def process_response_msg(self, response_msg, response_method): return lassomod.register_name_identifier_process_response_msg(self, response_msg, response_method); + +class Lecp: + """\brief Short desc + + Long desc + """ + + def __isprivate(self, name): + return name == '_o' + + def __init__(self, _obj): + """ + The constructor + """ + self._o = _obj + + def __getattr__(self, name): + if self.__isprivate(name): + return self.__dict__[name] + if name[:2] == "__" and name[-2:] == "__" and name != "__members__": + raise AttributeError, name + ret = lassomod.lecp_getattr(self, name) + return ret + + def new(cls): + obj = lassomod.lecp_new() + return Lecp(obj) + new = classmethod(new) + + def build_authn_request_envelope_msg(self): + pass + + def build_authn_response_envelope_msg(self): + pass + + def destroy(self): + pass + + def init_authn_request_envelope(self): + pass + + def process_authn_request_envelope_msg(self): + pass + + def process_authn_response_envelope_msg(self): + pass + diff --git a/python/lassomod.c b/python/lassomod.c index 75478717..376aaf7f 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -55,6 +55,7 @@ #include "protocols/elements/py_authentication_statement.h" #include "environs/py_federation_termination.h" +#include "environs/py_lecp.h" #include "environs/py_login.h" #include "environs/py_logout.h" #include "environs/py_profile_context.h" @@ -212,6 +213,15 @@ static PyMethodDef lasso_methods[] = { {"federation_termination_init_notification", federation_termination_init_notification, METH_VARARGS}, {"federation_termination_process_notification_msg", federation_termination_process_notification_msg, METH_VARARGS}, + /* py_lecp.h */ + {"lecp_new", lecp_new, METH_VARARGS}, + {"lecp_build_authn_request_envelope_msg", lecp_build_authn_request_envelope_msg, METH_VARARGS}, + {"lecp_build_authn_response_envelope_msg", lecp_build_authn_response_envelope_msg, METH_VARARGS}, + {"lecp_destroy", lecp_destroy, METH_VARARGS}, + {"lecp_init_authn_request_envelope", lecp_init_authn_request_envelope, METH_VARARGS}, + {"lecp_process_authn_request_envelope_msg", lecp_process_authn_request_envelope_msg, METH_VARARGS}, + {"lecp_process_authn_response_envelope_msg", lecp_process_authn_response_envelope_msg, METH_VARARGS}, + /* py_login.h */ {"login_getattr", login_getattr, METH_VARARGS}, {"login_new", login_new, METH_VARARGS}, @@ -239,7 +249,9 @@ static PyMethodDef lasso_methods[] = { {"logout_destroy", logout_destroy, METH_VARARGS}, {"logout_get_next_providerID", logout_get_next_providerID, METH_VARARGS}, {"logout_init_request", logout_init_request, METH_VARARGS}, - {"logout_process_request_msg", logout_process_request_msg, METH_VARARGS}, + {"logout_load_request_msg", logout_load_request_msg, METH_VARARGS}, + {"logout_load_user_dump", logout_load_user_dump, METH_VARARGS}, + {"logout_process_request", logout_process_request, METH_VARARGS}, {"logout_process_response_msg", logout_process_response_msg, METH_VARARGS}, /* py_register_name_identifier.h */ |