summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-07-10 01:33:56 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-07-10 01:33:56 +0000
commit1ed5aafdc04e029d9a902fd8b6df2220820c519f (patch)
tree5cc274ef59895141e1009269001e649dbb910f2c /python
parent1c41403396d1b13e18664da38a7615bffd8624a1 (diff)
downloadlasso-1ed5aafdc04e029d9a902fd8b6df2220820c519f.tar.gz
lasso-1ed5aafdc04e029d9a902fd8b6df2220820c519f.tar.xz
lasso-1ed5aafdc04e029d9a902fd8b6df2220820c519f.zip
*** empty log message ***
Diffstat (limited to 'python')
-rw-r--r--python/environs/py_login.c66
-rw-r--r--python/environs/py_login.h3
-rw-r--r--python/examples/login.py32
-rw-r--r--python/lasso.py58
-rw-r--r--python/lasso_strings.py22
-rw-r--r--python/lassomod.c8
6 files changed, 185 insertions, 4 deletions
diff --git a/python/environs/py_login.c b/python/environs/py_login.c
index 91649aea..5dcf08a5 100644
--- a/python/environs/py_login.c
+++ b/python/environs/py_login.c
@@ -24,6 +24,7 @@
*/
#include "../lassomod.h"
+#include "../xml/py_xml.h"
#include "py_login.h"
@@ -41,6 +42,37 @@ PyObject *LassoLogin_wrap(LassoLogin *login) {
/******************************************************************************/
+PyObject *login_getattr(PyObject *self, PyObject *args) {
+ PyObject *login_obj;
+ LassoLogin *login;
+ const char *attr;
+
+ if (CheckArgs(args, "OS:login_get_attr")) {
+ if (!PyArg_ParseTuple(args, "Os:login_get_attr", &login_obj, &attr))
+ return NULL;
+ }
+ else return NULL;
+
+ login = LassoLogin_get(login_obj);
+
+ if (!strcmp(attr, "__members__"))
+ return Py_BuildValue("[ssss]", "request", "response", "request_type",
+ "msg_url");
+ if (!strcmp(attr, "request"))
+ return (LassoNode_wrap(LASSO_PROFILE_CONTEXT(login)->request));
+ if (!strcmp(attr, "response"))
+ return (LassoNode_wrap(LASSO_PROFILE_CONTEXT(login)->response));
+ if (!strcmp(attr, "request_type"))
+ return (int_wrap(LASSO_PROFILE_CONTEXT(login)->request_type));
+ if (!strcmp(attr, "msg_url"))
+ return (charPtr_wrap(LASSO_PROFILE_CONTEXT(login)->msg_url));
+
+ Py_INCREF(Py_None);
+ return (Py_None);
+}
+
+/******************************************************************************/
+
PyObject *login_new(PyObject *self, PyObject *args) {
PyObject *server_obj, *user_obj;
LassoLogin *login;
@@ -110,3 +142,37 @@ PyObject *login_build_artifact_msg(PyObject *self, PyObject *args) {
return (int_wrap(ret));
}
+
+PyObject *login_build_authn_request_msg(PyObject *self, PyObject *args) {
+ PyObject *login_obj;
+ gint ret;
+
+ if (CheckArgs(args, "O:login_build_authn_request_msg")) {
+ if(!PyArg_ParseTuple(args, (char *) "O:login_build_authn_request_msg",
+ &login_obj))
+ return NULL;
+ }
+ else return NULL;
+
+ ret = lasso_login_build_authn_request_msg(LassoLogin_get(login_obj));
+
+ return (int_wrap(ret));
+}
+
+PyObject *login_init_authn_request(PyObject *self, PyObject *args) {
+ PyObject *login_obj;
+ gchar *remote_providerID;
+ gint ret;
+
+ if (CheckArgs(args, "OS:login_init_authn_request")) {
+ if(!PyArg_ParseTuple(args, (char *) "Os:login_init_authn_request",
+ &login_obj, &remote_providerID))
+ return NULL;
+ }
+ else return NULL;
+
+ ret = lasso_login_init_authn_request(LassoLogin_get(login_obj),
+ remote_providerID);
+
+ return (int_wrap(ret));
+}
diff --git a/python/environs/py_login.h b/python/environs/py_login.h
index d6ff0fb3..4956aff7 100644
--- a/python/environs/py_login.h
+++ b/python/environs/py_login.h
@@ -39,8 +39,11 @@ typedef struct {
#define LassoLogin_get(v) (((v) == Py_None) ? NULL : (((LassoLogin_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj))
PyObject *LassoLogin_wrap(LassoLogin *login);
+PyObject *login_getattr(PyObject *self, PyObject *args);
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);
+PyObject *login_build_authn_request_msg(PyObject *self, PyObject *args);
+PyObject *login_init_authn_request(PyObject *self, PyObject *args);
#endif /* __PYLASSO_PY_LOGIN_H__ */
diff --git a/python/examples/login.py b/python/examples/login.py
new file mode 100644
index 00000000..d9e11230
--- /dev/null
+++ b/python/examples/login.py
@@ -0,0 +1,32 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import sys
+sys.path.insert(0, '../')
+import lasso
+
+lasso.init()
+
+####################
+# Service provider #
+####################
+server = lasso.Server.new("../../examples/sp.xml",
+ "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem",
+ lasso.SignatureMethodRsaSha1)
+
+server.add_provider("../../examples/idp.xml", None, None)
+
+# creation d'une AuthnRequest
+splogin = lasso.Login.new(server, None)
+ret = splogin.init_authn_request("https://identity-provider:2003/liberty-alliance/metadata")
+splogin.request.set_isPassive(0)
+splogin.request.set_forceAuthn(1)
+#splogin.request.set_nameIDPolicy(lasso.LibNameIDPolicyTypeFederated)
+splogin.request.set_relayState("fake")
+splogin.request.set_protocolProfile(lasso.libProtocolProfileBrwsArt)
+
+print "Request type =", splogin.request_type
+print splogin.request.dump()
+
+print splogin.build_authn_request_msg()
+print "message url =", splogin.msg_url
diff --git a/python/lasso.py b/python/lasso.py
index 0b9f4773..0f825ec1 100644
--- a/python/lasso.py
+++ b/python/lasso.py
@@ -790,6 +790,14 @@ class AuthenticationStatement(Node):
################################################################################
SignatureMethodRsaSha1 = 1
SignatureMethodDsaSha1 = 2
+
+MessageTypeNone = 0
+MessageTypeAuthnRequest = 1
+MessageTypeAuthnResponse = 2
+MessageTypeRequest = 3
+MessageTypeResponse = 4
+MessageTypeArtifact = 5
+
class Server:
"""\brief Short desc
@@ -812,6 +820,56 @@ class Server:
public_key, certificate)
+class Login:
+ """\brief Short desc
+
+ Long desc
+ """
+
+ def __init__(self, _obj):
+ """
+ The constructor
+ """
+ self._o = _obj
+
+ def __isprivate(self, name):
+ return name == '_o'
+
+ 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.login_getattr(self, name)
+ if ret is None:
+ raise AttributeError, name
+ if name == "request":
+ if lassomod.login_getattr(self, "request_type") == MessageTypeAuthnRequest:
+ ret = AuthnRequest(None, _obj=ret)
+ # TODO
+ if name == "response":
+ ret = Node(_obj=ret)
+ return ret
+
+ def new(cls, server, user=None):
+ obj = lassomod.login_new(server, user)
+ return Login(obj)
+ new = classmethod(new)
+
+ def build_artifact_msg(self, authentication_result, authenticationMethod,
+ reauthenticateOnOrAfter, method):
+ return lassomod.login_build_artifact_msg(self, authentication_result,
+ authenticationMethod,
+ reauthenticateOnOrAfter,
+ method)
+
+ def build_authn_request_msg(self):
+ return lassomod.login_build_authn_request_msg(self)
+
+ def init_authn_request(self, remote_providerID):
+ return lassomod.login_init_authn_request(self, remote_providerID)
+
+
class Logout:
"""\brief Short desc
diff --git a/python/lasso_strings.py b/python/lasso_strings.py
index 8e2eb01e..005dd39c 100644
--- a/python/lasso_strings.py
+++ b/python/lasso_strings.py
@@ -47,6 +47,14 @@
# *****************************************************************************/
+# * Lasso */
+# *****************************************************************************/
+
+# * prefix & href */
+lassoHRef = "http://www.entrouvert.org/namespaces/lasso/0.0"
+lassoPrefix = "lasso"
+
+# *****************************************************************************/
# * Liberty Alliance */
# *****************************************************************************/
@@ -82,8 +90,10 @@ libStatusCodeUnknownPrincipal = "lib:UnknownPrincipal"
libStatusCodeUnsignedAuthnRequest = "lib:UnsignedAuthnRequest"
# * ProtocolProfile */
-libProtocolProfileArtifact = "http://projectliberty.org/profiles/brws-art"
-libProtocolProfilePost = "http://projectliberty.org/profiles/brws-post"
+libProtocolProfileSSOGet = "http://projectliberty.org/profiles/sso-get"
+libProtocolProfileSSOPost = "http://projectliberty.org/profiles/sso-post"
+libProtocolProfileBrwsArt = "http://projectliberty.org/profiles/brws-art"
+libProtocolProfileBrwsPost = "http://projectliberty.org/profiles/brws-post"
libProtocolProfileFedTermIdpHttp = "http://projectliberty.org/profiles/fedterm-idp-http"
libProtocolProfileFedTermIdpSoap = "http://projectliberty.org/profiles/fedterm-idp-soap"
libProtocolProfileFedTermSpHttp = "http://projectliberty.org/profiles/fedterm-sp-http"
@@ -104,6 +114,14 @@ libNameIdentifierFormatEncrypted = "urn:liberty:iff:nameid:encrypted"
libNameIdentifierFormatEntityID = "urn:liberty:iff:nameid:entityID"
# *****************************************************************************/
+# * METADATA */
+# *****************************************************************************/
+
+# * prefix & href */
+metadataHRef = "urn:liberty:metadata:2003-08"
+metadataPrefix = "md"
+
+# *****************************************************************************/
# * SAML */
# *****************************************************************************/
diff --git a/python/lassomod.c b/python/lassomod.c
index 21fa9c9d..74aefaae 100644
--- a/python/lassomod.c
+++ b/python/lassomod.c
@@ -202,8 +202,12 @@ static PyMethodDef lasso_methods[] = {
/* environs */
/* py_login.h */
- {"login_new", login_new, METH_VARARGS},
- {"login_new_from_dump", login_new_from_dump, METH_VARARGS},
+ {"login_getattr", login_getattr, METH_VARARGS},
+ {"login_new", login_new, METH_VARARGS},
+ {"login_new_from_dump", login_new_from_dump, METH_VARARGS},
+ {"login_build_artifact_msg", login_build_artifact_msg, METH_VARARGS},
+ {"login_build_authn_request_msg", login_build_authn_request_msg, METH_VARARGS},
+ {"login_init_authn_request", login_init_authn_request, METH_VARARGS},
/* py_logout.h */
{"logout_new", logout_new, METH_VARARGS},