summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-07-09 16:07:36 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-07-09 16:07:36 +0000
commit425c710ee7d7cfbbb496909b24ce038c2f6768b8 (patch)
tree237b350fad8d6b14679906e198a0080f1e13cb0f /python
parent32b13e03dce0109b3445fda6b8d895a053353b6b (diff)
downloadlasso-425c710ee7d7cfbbb496909b24ce038c2f6768b8.tar.gz
lasso-425c710ee7d7cfbbb496909b24ce038c2f6768b8.tar.xz
lasso-425c710ee7d7cfbbb496909b24ce038c2f6768b8.zip
*** empty log message ***
Diffstat (limited to 'python')
-rw-r--r--python/environs/py_login.c112
-rw-r--r--python/environs/py_login.h46
-rw-r--r--python/environs/py_user.c61
-rw-r--r--python/environs/py_user.h42
-rw-r--r--python/lasso.py27
-rw-r--r--python/lassomod.c13
-rw-r--r--python/protocols/py_authn_response.c26
-rw-r--r--python/protocols/py_authn_response.h2
-rwxr-xr-xpython/setup.py2
-rw-r--r--python/xml/py_xml.c4
10 files changed, 303 insertions, 32 deletions
diff --git a/python/environs/py_login.c b/python/environs/py_login.c
new file mode 100644
index 00000000..91649aea
--- /dev/null
+++ b/python/environs/py_login.c
@@ -0,0 +1,112 @@
+/* $Id$
+ *
+ * PyLasso -- Python bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.labs.libre-entreprise.org
+ *
+ * Authors: Valery Febvre <vfebvre@easter-eggs.com>
+ * Nicolas Clapies <nclapies@entrouvert.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_login.h"
+
+PyObject *LassoLogin_wrap(LassoLogin *login) {
+ PyObject *ret;
+
+ if (login == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyCObject_FromVoidPtrAndDesc((void *) login,
+ (char *) "LassoLogin *", NULL);
+ return (ret);
+}
+
+/******************************************************************************/
+
+PyObject *login_new(PyObject *self, PyObject *args) {
+ PyObject *server_obj, *user_obj;
+ LassoLogin *login;
+ LassoServer *server;
+ LassoUser *user = NULL;
+
+ if (CheckArgs(args, "Oo:login_new")) {
+ if(!PyArg_ParseTuple(args, (char *) "O|O:login_new", &server_obj, &user_obj))
+ return NULL;
+ }
+ else return NULL;
+
+ server = LassoServer_get(server_obj);
+ if (user_obj != Py_None) {
+ user = LassoUser_get(user_obj);
+ }
+ login = LASSO_LOGIN(lasso_login_new(server, user));
+
+ return (LassoLogin_wrap(login));
+}
+
+PyObject *login_new_from_dump(PyObject *self, PyObject *args) {
+ PyObject *server_obj, *user_obj;
+ LassoLogin *login;
+ LassoServer *server;
+ LassoUser *user = NULL;
+ gchar *dump;
+
+ if (CheckArgs(args, "OoS:login_new_from_dump")) {
+ if(!PyArg_ParseTuple(args, (char *) "O|Os:login_new_from_dump", &server_obj,
+ &user_obj, &dump))
+ return NULL;
+ }
+ else return NULL;
+
+ server = LassoServer_get(server_obj);
+ if (user_obj != Py_None) {
+ user = LassoUser_get(user_obj);
+ }
+ login = LASSO_LOGIN(lasso_login_new_from_dump(server, user, dump));
+
+ return (LassoLogin_wrap(login));
+}
+
+PyObject *login_build_artifact_msg(PyObject *self, PyObject *args) {
+ PyObject *login_obj;
+ gint authentication_result;
+ const gchar *authenticationMethod;
+ const gchar *reauthenticateOnOrAfter;
+ lassoHttpMethods method;
+ gint ret;
+
+ if (CheckArgs(args, "OISSI:login_build_artifact_msg")) {
+ if(!PyArg_ParseTuple(args, (char *) "Oissi:login_build_artifact_msg",
+ &login_obj, &authentication_result,
+ &authenticationMethod, &reauthenticateOnOrAfter,
+ &method))
+ return NULL;
+ }
+ else return NULL;
+
+ ret = lasso_login_build_artifact_msg(LassoLogin_get(login_obj),
+ authentication_result,
+ authenticationMethod,
+ reauthenticateOnOrAfter,
+ method);
+
+ return (int_wrap(ret));
+}
diff --git a/python/environs/py_login.h b/python/environs/py_login.h
new file mode 100644
index 00000000..d6ff0fb3
--- /dev/null
+++ b/python/environs/py_login.h
@@ -0,0 +1,46 @@
+/* $Id$
+ *
+ * PyLasso -- Python bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.labs.libre-entreprise.org
+ *
+ * Authors: Valery Febvre <vfebvre@easter-eggs.com>
+ * Nicolas Clapies <nclapies@entrouvert.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_LOGIN_H__
+#define __PYLASSO_PY_LOGIN_H__
+
+#include <lasso/environs/login.h>
+
+#include "py_server.h"
+#include "py_user.h"
+
+typedef struct {
+ PyObject_HEAD
+ LassoLogin *obj;
+} LassoLogin_object;
+
+#define LassoLogin_get(v) (((v) == Py_None) ? NULL : (((LassoLogin_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj))
+PyObject *LassoLogin_wrap(LassoLogin *login);
+
+PyObject *login_new(PyObject *self, PyObject *args);
+PyObject *login_new_from_dump(PyObject *self, PyObject *args);
+PyObject *login_build_artifact_msg(PyObject *self, PyObject *args);
+
+#endif /* __PYLASSO_PY_LOGIN_H__ */
diff --git a/python/environs/py_user.c b/python/environs/py_user.c
new file mode 100644
index 00000000..0d359d8c
--- /dev/null
+++ b/python/environs/py_user.c
@@ -0,0 +1,61 @@
+/* $Id$
+ *
+ * PyLasso -- Python bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.labs.libre-entreprise.org
+ *
+ * Authors: Valery Febvre <vfebvre@easter-eggs.com>
+ * Nicolas Clapies <nclapies@entrouvert.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_user.h"
+
+PyObject *LassoUser_wrap(LassoUser *user) {
+ PyObject *ret;
+
+ if (user == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyCObject_FromVoidPtrAndDesc((void *) user,
+ (char *) "LassoUser *", NULL);
+ return (ret);
+}
+
+/******************************************************************************/
+
+PyObject *user_new(PyObject *self, PyObject *args) {
+ return (LassoUser_wrap(lasso_user_new()));
+}
+
+PyObject *user_new_from_dump(PyObject *self, PyObject *args) {
+ LassoUser *user;
+ gchar *dump;
+
+ if (CheckArgs(args, "S:user_new_from_dump")) {
+ if(!PyArg_ParseTuple(args, (char *) "s:user_new_from_dump", &dump))
+ return NULL;
+ }
+ else return NULL;
+
+ user = lasso_user_new_from_dump(dump);
+
+ return (LassoUser_wrap(user));
+}
diff --git a/python/environs/py_user.h b/python/environs/py_user.h
new file mode 100644
index 00000000..21543209
--- /dev/null
+++ b/python/environs/py_user.h
@@ -0,0 +1,42 @@
+/* $Id$
+ *
+ * PyLasso -- Python bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.labs.libre-entreprise.org
+ *
+ * Authors: Valery Febvre <vfebvre@easter-eggs.com>
+ * Nicolas Clapies <nclapies@entrouvert.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_USER_H__
+#define __PYLASSO_PY_USER_H__
+
+#include <lasso/environs/user.h>
+
+typedef struct {
+ PyObject_HEAD
+ LassoUser *obj;
+} LassoUser_object;
+
+#define LassoUser_get(v) (((v) == Py_None) ? NULL : (((LassoUser_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj))
+PyObject *LassoUser_wrap(LassoUser *user);
+
+PyObject *user_new(PyObject *self, PyObject *args);
+PyObject *user_new_from_dump(PyObject *self, PyObject *args);
+
+#endif /* __PYLASSO_PY_USER_H__ */
diff --git a/python/lasso.py b/python/lasso.py
index f388e2b5..ecdfb1fa 100644
--- a/python/lasso.py
+++ b/python/lasso.py
@@ -441,7 +441,7 @@ class LibRegisterNameIdentifierResponse(Node):
Node.__init__(self, _obj=_obj)
################################################################################
-# protocols : high level classes
+# protocols : middle level classes
################################################################################
def authn_request_get_protocolProfile(query):
@@ -816,3 +816,28 @@ class AuthenticationStatement(Node):
if _obj is None:
raise Error('lasso_authentication_statement_new() failed')
Node.__init__(self, _obj=_obj)
+
+################################################################################
+# environs : high level classes
+################################################################################
+SignatureMethodRsaSha1 = 1
+SignatureMethodDsaSha1 = 2
+class Login:
+ """\brief Short desc
+
+ Long desc
+ """
+ def __init__(self, _obj):
+ """
+ The constructor
+ """
+ self._o = _obj
+
+ def new(cls, server, user=None):
+ obj = lassomod.login_new(server, user)
+ return Login(obj)
+ new = classmethod(new)
+
+ def add_provider(self, metadata, public_key=None, certificate=None):
+ lassomod.lasso_server_add_provider(self, metadata,
+ public_key, certificate)
diff --git a/python/lassomod.c b/python/lassomod.c
index 4a033043..a5ec0c4b 100644
--- a/python/lassomod.c
+++ b/python/lassomod.c
@@ -53,7 +53,9 @@
#include "protocols/elements/py_assertion.h"
#include "protocols/elements/py_authentication_statement.h"
+#include "environs/py_login.h"
#include "environs/py_server.h"
+#include "environs/py_user.h"
static PyMethodDef lasso_methods[] = {
/* py_lasso.h */
@@ -141,7 +143,7 @@ static PyMethodDef lasso_methods[] = {
{"authn_response_getattr", authn_response_getattr, METH_VARARGS},
{"authn_response_new_from_dump", authn_response_new_from_dump, METH_VARARGS},
{"authn_response_new_from_export", authn_response_new_from_export, METH_VARARGS},
- {"authn_response_new_from_request_query", authn_response_new_from_request_query, METH_VARARGS},
+ //{"authn_response_new_from_request_query", authn_response_new_from_request_query, METH_VARARGS},
{"authn_response_must_authenticate", authn_response_must_authenticate, METH_VARARGS},
{"authn_response_process_authentication_result", authn_response_process_authentication_result, METH_VARARGS},
{"authn_response_verify_signature", authn_response_verify_signature, METH_VARARGS},
@@ -186,7 +188,6 @@ static PyMethodDef lasso_methods[] = {
{"register_name_identifier_response_new_from_request_query", register_name_identifier_response_new_from_request_query, METH_VARARGS},
{"register_name_identifier_response_new_from_query", register_name_identifier_response_new_from_query, METH_VARARGS},
-
/* py_request.h */
/* {"request_create", request_create, METH_VARARGS}, */
/* {"request_getattr", request_getattr, METH_VARARGS}, */
@@ -205,10 +206,18 @@ static PyMethodDef lasso_methods[] = {
{"authentication_statement_new", authentication_statement_new, METH_VARARGS},
/* environs */
+ /* py_login.h */
+ {"login_new", login_new, METH_VARARGS},
+ {"login_new_from_dump", login_new_from_dump, METH_VARARGS},
+
/* py_server.h */
{"server_new", server_new, METH_VARARGS},
{"server_add_provider", server_add_provider, METH_VARARGS},
+ /* py_user.h */
+ {"user_new", user_new, METH_VARARGS},
+ {"user_new_from_dump", user_new_from_dump, METH_VARARGS},
+
{NULL, NULL} /* End of Methods Sentinel */
};
diff --git a/python/protocols/py_authn_response.c b/python/protocols/py_authn_response.c
index bd8e3dbc..77471893 100644
--- a/python/protocols/py_authn_response.c
+++ b/python/protocols/py_authn_response.c
@@ -47,32 +47,6 @@ PyObject *LassoAuthnResponse_wrap(LassoAuthnResponse *response) {
/******************************************************************************/
-PyObject *authn_response_getattr(PyObject *self, PyObject *args) {
- PyObject *reponse_obj;
- LassoAuthnResponse *reponse;
- const char *attr;
-
- if (CheckArgs(args, "OS:authn_response_get_attr")) {
- if (!PyArg_ParseTuple(args, "Os:authn_response_get_attr", &reponse_obj, &attr))
- return NULL;
- }
- else return NULL;
-
- reponse = LassoAuthnResponse_get(reponse_obj);
-
- if (!strcmp(attr, "__members__"))
- return Py_BuildValue("[ss]", "request", "query");
- if (!strcmp(attr, "request"))
- return (LassoAuthnRequest_wrap(LASSO_AUTHN_REQUEST(reponse->request)));
- if (!strcmp(attr, "query"))
- return (xmlCharPtr_wrap(reponse->query));
-
- Py_INCREF(Py_None);
- return (Py_None);
-}
-
-/******************************************************************************/
-
PyObject *authn_response_new_from_dump(PyObject *self, PyObject *args) {
xmlChar *buffer;
LassoNode *response;
diff --git a/python/protocols/py_authn_response.h b/python/protocols/py_authn_response.h
index f3d54c0f..f11a9638 100644
--- a/python/protocols/py_authn_response.h
+++ b/python/protocols/py_authn_response.h
@@ -40,7 +40,7 @@ PyObject *LassoAuthnResponse_wrap(LassoAuthnResponse *response);
PyObject *authn_response_getattr(PyObject *self, PyObject *args);
PyObject *authn_response_new_from_dump(PyObject *self, PyObject *args);
PyObject *authn_response_new_from_export(PyObject *self, PyObject *args);
-PyObject *authn_response_new_from_request_query(PyObject *self, PyObject *args);
+//PyObject *authn_response_new_from_request_query(PyObject *self, PyObject *args);
PyObject *authn_response_must_authenticate(PyObject *self, PyObject *args);
PyObject *authn_response_process_authentication_result(PyObject *self, PyObject *args);
PyObject *authn_response_verify_signature(PyObject *self, PyObject *args);
diff --git a/python/setup.py b/python/setup.py
index c45ca59a..a1965bc6 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -216,7 +216,9 @@ em = Extension("lassomod",
"protocols/py_register_name_identifier_response.c",
"protocols/elements/py_assertion.c",
"protocols/elements/py_authentication_statement.c",
+ "environs/py_login.c",
"environs/py_server.c",
+ "environs/py_user.c",
"lassomod.c",
"utils.c", "wrap_objs.c"],
define_macros = define_macros,
diff --git a/python/xml/py_xml.c b/python/xml/py_xml.c
index 3a64a13e..743fe862 100644
--- a/python/xml/py_xml.c
+++ b/python/xml/py_xml.c
@@ -112,8 +112,8 @@ PyObject *node_export_to_query(PyObject *self, PyObject *args) {
const gchar *private_key_file;
gchar *ret;
- if (CheckArgs(args, "OIS:node_export_to_query")) {
- if(!PyArg_ParseTuple(args, (char *) "Ois:node_export_to_query",
+ if (CheckArgs(args, "Ois:node_export_to_query")) {
+ if(!PyArg_ParseTuple(args, (char *) "Oiz:node_export_to_query",
&node_obj, &sign_method, &private_key_file))
return NULL;
}