diff options
Diffstat (limited to 'python/protocols')
| -rw-r--r-- | python/protocols/py_single_sign_on_and_federation.c | 111 | ||||
| -rw-r--r-- | python/protocols/py_single_sign_on_and_federation.h | 41 |
2 files changed, 152 insertions, 0 deletions
diff --git a/python/protocols/py_single_sign_on_and_federation.c b/python/protocols/py_single_sign_on_and_federation.c new file mode 100644 index 00000000..d44e6ac0 --- /dev/null +++ b/python/protocols/py_single_sign_on_and_federation.c @@ -0,0 +1,111 @@ +/* $Id$ + * + * PyLasso -- Python bindings for Lasso library + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.labs.libre-entreprise.org + * + * Author: 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_single_sign_on_and_federation.h" + +PyObject *wrap_LassoAuthnRequest(LassoAuthnRequest *request) { + PyObject *ret; + + if (request == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = PyCObject_FromVoidPtrAndDesc((void *) request, + (char *) "LassoAuthnRequest *", NULL); + return (ret); +} + +/******************************************************************************/ +/* LassoAuthnRequest */ +/******************************************************************************/ + +PyObject *authn_request_getattr(PyObject *self, PyObject *args) { + PyObject *lareq_obj; + LassoAuthnRequest *lareq; + const char *attr; + + if (CheckArgs(args, "OS:authn_request_get_attr")) { + if (!PyArg_ParseTuple(args, "Os:authn_request_get_attr", &lareq_obj, &attr)) + return NULL; + } + else return NULL; + + lareq = LassoAuthnRequest_get(lareq_obj); + + if (!strcmp(attr, "__members__")) + return Py_BuildValue("[s]", "request"); + if (!strcmp(attr, "request")) + return (wrap_LassoNode(lareq->request)); + + Py_INCREF(Py_None); + return (Py_None); +} + +/******************************************************************************/ + +PyObject *authn_request_build(PyObject *self, PyObject *args) { + PyObject *authnContextClassRefs_obj, *authnContextStatementRefs_obj; + PyObject *idpList_obj; + const xmlChar *providerID; + const xmlChar *nameIDPolicy; + const xmlChar *forceAuthn; + const xmlChar *isPassive; + const xmlChar *protocolProfile; + const xmlChar *assertionConsumerServiceID; + GPtrArray *authnContextClassRefs = NULL; + GPtrArray *authnContextStatementRefs = NULL; + const xmlChar *authnContextComparison; + const xmlChar *relayState; + gint proxyCount; + GPtrArray *idpList = NULL; + const xmlChar *consent; + + LassoAuthnRequest *request; + + if(!PyArg_ParseTuple(args, (char *) "ssssssOOssiOs:build_authn_request", + &providerID, &nameIDPolicy, &forceAuthn, &isPassive, + &protocolProfile, &assertionConsumerServiceID, + &authnContextClassRefs, &authnContextStatementRefs, + &authnContextComparison, &relayState, &proxyCount, + &idpList, &consent)) + return NULL; + + request = lasso_authn_request_build(providerID, + nameIDPolicy, + forceAuthn, + isPassive, + protocolProfile, + assertionConsumerServiceID, + NULL, + NULL, + authnContextComparison, + relayState, + proxyCount, + NULL, + consent); + + return (wrap_LassoAuthnRequest(request)); +} diff --git a/python/protocols/py_single_sign_on_and_federation.h b/python/protocols/py_single_sign_on_and_federation.h new file mode 100644 index 00000000..d8acb324 --- /dev/null +++ b/python/protocols/py_single_sign_on_and_federation.h @@ -0,0 +1,41 @@ +/* $Id$ + * + * PyLasso -- Python bindings for Lasso library + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.labs.libre-entreprise.org + * + * Author: 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_SINGLE_SIGN_ON_AND_FEDERATION_H__ +#define __PYLASSO_PY_SINGLE_SIGN_ON_AND_FEDERATION_H__ + +#include <lasso/protocols/single_sign_on_and_federation.h> + +typedef struct { + PyObject_HEAD + LassoAuthnRequest *obj; +} LassoAuthnRequest_object; + +#define LassoAuthnRequest_get(v) (((v) == Py_None) ? NULL : (((LassoAuthnRequest_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj)) +PyObject *LassoAuthnRequest_wrap(LassoAuthnRequest *request); + +PyObject *authn_request_getattr(PyObject *self, PyObject *args); +PyObject *authn_request_build(PyObject *self, PyObject *args); + +#endif /* __PYLASSO_PY_SINGLE_SIGN_ON_AND_FEDERATION_H__ */ |
