summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-04-08 02:44:16 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-04-08 02:44:16 +0000
commita914a109350e3285e6c8118644ba2162cd8632ad (patch)
treefcc3ef9ee550b083d4060b741bc7c436bb8b92b0 /python
parentb73d899efd03f3058b752e0f64061f1f7e308fc9 (diff)
downloadlasso-a914a109350e3285e6c8118644ba2162cd8632ad.tar.gz
lasso-a914a109350e3285e6c8118644ba2162cd8632ad.tar.xz
lasso-a914a109350e3285e6c8118644ba2162cd8632ad.zip
*** empty log message ***
Diffstat (limited to 'python')
-rwxr-xr-xpython/examples/test.py33
-rw-r--r--python/lasso.py85
-rw-r--r--python/lassomod.c16
-rw-r--r--python/protocols/py_single_sign_on_and_federation.c172
-rw-r--r--python/protocols/py_single_sign_on_and_federation.h18
-rw-r--r--python/py_lasso.c10
-rw-r--r--python/wrap_objs.c6
-rw-r--r--python/wrap_objs.h6
-rw-r--r--python/xml/py_xml.c19
-rw-r--r--python/xml/py_xml.h1
10 files changed, 326 insertions, 40 deletions
diff --git a/python/examples/test.py b/python/examples/test.py
index b636b38a..a7690348 100755
--- a/python/examples/test.py
+++ b/python/examples/test.py
@@ -10,19 +10,42 @@ req = lasso.AuthnRequest("providerid.com",
"federated",
"false",
"true",
- "", # None
+ "pp", # None
"3",
None,
None,
"", # None
- "", # None
+ "encoded_RelayState", # None
0,
None,
"obtained")
-req.request.dump("iso-8859-1", 1)
+req.node.dump("iso-8859-1", 1)
+
+query = req.node.url_encode(1, "../../examples/rsakey.pem")
+
+res = lasso.AuthnResponse(query, 1,
+ "../../examples/rsapub.pem",
+ "../../examples/rsakey2.pem",
+ "../../examples/rsacert.pem", 0)
+
+res.init("toto", 1)
+
+assertion = lasso.assertion_build(res, "http://idprovider.com")
+authentication_statement = lasso.authentication_statement_build("password",
+ "3",
+ "tralalal",
+ "dslqkjfslfj",
+ "http://service-provider.com",
+ "federated",
+ "wxkfjesmqfj",
+ "http://idp-provider.com",
+ "federated",
+ "bearer")
+lasso.assertion_add_authenticationStatement(assertion, authentication_statement);
+res.add_assertion(assertion)
-#req.dump("iso-8859-1", 1)
-#req.destroy()
+res.node.dump("iso-8859-1", 1)
+#req.node.destroy()
#print lasso.shutdown()
diff --git a/python/lasso.py b/python/lasso.py
index b90f8e73..289b94e8 100644
--- a/python/lasso.py
+++ b/python/lasso.py
@@ -39,12 +39,29 @@ def init():
"""
"""
return lassomod.init()
-
def shutdown():
"""
"""
return lassomod.shutdown()
+def assertion_build(response, issuer):
+ return Node(_obj=lassomod.assertion_build(response, issuer))
+def assertion_add_authenticationStatement(assertion, statement):
+ return lassomod.assertion_add_authenticationStatement(assertion, statement)
+
+def authentication_statement_build(authenticationMethod, sessionIndex,
+ reauthenticateOnOrAfter,
+ nameIdentifier, nameQualifier,
+ format, idp_nameIdentifier,
+ idp_nameQualifier, idp_format,
+ confirmationMethod):
+ return Node(_obj=lassomod.authentication_statement_build(authenticationMethod, sessionIndex,
+ reauthenticateOnOrAfter,
+ nameIdentifier, nameQualifier,
+ format, idp_nameIdentifier,
+ idp_nameQualifier, idp_format,
+ confirmationMethod))
+
class AuthnRequest:
def __init__(self, providerID, nameIDPolicy, forceAuthn, isPassive,
protocolProfile, assertionConsumerServiceID, authnContextClassRefs,
@@ -55,20 +72,20 @@ class AuthnRequest:
if _obj != None:
self._o = _obj
return
- self._o = lassomod.authn_request_build(providerID,
- nameIDPolicy,
- forceAuthn,
- isPassive,
- protocolProfile,
- assertionConsumerServiceID,
- authnContextClassRefs,
- authnContextStatementRefs,
- authnContextComparison,
- relayState,
- proxyCount,
- idpList,
- consent)
- if self._o is None: raise Error('lasso_authn_request_build() failed')
+ self._o = lassomod.authn_request_create(providerID,
+ nameIDPolicy,
+ forceAuthn,
+ isPassive,
+ protocolProfile,
+ assertionConsumerServiceID,
+ authnContextClassRefs,
+ authnContextStatementRefs,
+ authnContextComparison,
+ relayState,
+ proxyCount,
+ idpList,
+ consent)
+ if self._o is None: raise Error('lasso_authn_request_create() failed')
def __isprivate(self, name):
return name == '_o'
def __getattr__(self, name):
@@ -79,9 +96,43 @@ class AuthnRequest:
ret = lassomod.authn_request_getattr(self, name)
if ret is None:
raise AttributeError, name
- if name == "request":
+ if name == "node":
+ ret = Node(_obj=ret)
+ return ret
+
+class AuthnResponse:
+ def __init__(self, query, verify_signature, public_key_file, private_key_file,
+ certificate_file, is_authenticated, _obj=None):
+ """
+ """
+ if _obj != None:
+ self._o = _obj
+ return
+ self._o = lassomod.authn_response_create(query,
+ verify_signature,
+ public_key_file,
+ private_key_file,
+ certificate_file,
+ is_authenticated)
+ if self._o is None: raise Error('lasso_authn_response_create() failed')
+ 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.authn_response_getattr(self, name)
+ if ret is None:
+ raise AttributeError, name
+ if name == "node":
ret = Node(_obj=ret)
return ret
+ def init(self, providerID, authentication_result):
+ return lassomod.authn_response_init(self, providerID,
+ authentication_result)
+ def add_assertion(self, assertion):
+ return lassomod.authn_response_add_assertion(self, assertion)
class Node:
def __init__(self, _obj=None):
@@ -96,3 +147,5 @@ class Node:
lassomod.node_dump(self, encoding, format)
def destroy(self):
lassomod.node_unref(self)
+ def url_encode(self, sign_method, private_key_file):
+ return lassomod.node_url_encode(self, sign_method, private_key_file)
diff --git a/python/lassomod.c b/python/lassomod.c
index fc97e55e..8fce8193 100644
--- a/python/lassomod.c
+++ b/python/lassomod.c
@@ -37,13 +37,21 @@ static PyMethodDef lasso_methods[] = {
{"check_version_ext", check_version_ext, METH_VARARGS},
/* py_xml.h */
- {"node_dump", node_dump, METH_VARARGS},
- {"node_unref", node_unref, METH_VARARGS},
+ {"node_dump", node_dump, METH_VARARGS},
+ {"node_unref", node_unref, METH_VARARGS},
+ {"node_url_encode", node_url_encode, METH_VARARGS},
/* py_single_sign_on_and_federation.h */
{"authn_request_getattr", authn_request_getattr, METH_VARARGS},
- {"authn_request_create", authn_request_create, METH_VARARGS},
-
+ {"authn_request_create", authn_request_create, METH_VARARGS},
+ {"authn_response_getattr", authn_response_getattr, METH_VARARGS},
+ {"authn_response_create", authn_response_create, METH_VARARGS},
+ {"authn_response_init", authn_response_init, METH_VARARGS},
+ {"authn_response_add_assertion", authn_response_add_assertion, METH_VARARGS},
+ {"assertion_build", assertion_build, METH_VARARGS},
+ {"assertion_add_authenticationStatement", assertion_add_authenticationStatement, METH_VARARGS},
+ {"authentication_statement_build", authentication_statement_build, METH_VARARGS},
+
{NULL, NULL} /* End of Methods Sentinel */
};
diff --git a/python/protocols/py_single_sign_on_and_federation.c b/python/protocols/py_single_sign_on_and_federation.c
index a65b8d30..b9ccc3b5 100644
--- a/python/protocols/py_single_sign_on_and_federation.c
+++ b/python/protocols/py_single_sign_on_and_federation.c
@@ -27,6 +27,10 @@
#include "../xml/py_xml.h"
#include "py_single_sign_on_and_federation.h"
+/******************************************************************************/
+/* lassoAuthnRequest */
+/******************************************************************************/
+
PyObject *lassoAuthnRequest_wrap(lassoAuthnRequest *request) {
PyObject *ret;
@@ -40,8 +44,6 @@ PyObject *lassoAuthnRequest_wrap(lassoAuthnRequest *request) {
}
/******************************************************************************/
-/* lassoAuthnRequest */
-/******************************************************************************/
PyObject *authn_request_getattr(PyObject *self, PyObject *args) {
PyObject *lareq_obj;
@@ -58,7 +60,7 @@ PyObject *authn_request_getattr(PyObject *self, PyObject *args) {
if (!strcmp(attr, "__members__"))
return Py_BuildValue("[s]", "node");
- if (!strcmp(attr, "request"))
+ if (!strcmp(attr, "node"))
return (LassoNode_wrap(lareq->node));
Py_INCREF(Py_None);
@@ -86,7 +88,7 @@ PyObject *authn_request_create(PyObject *self, PyObject *args) {
lassoAuthnRequest *request;
- if(!PyArg_ParseTuple(args, (char *) "ssssssOOssiOs:build_authn_request",
+ if(!PyArg_ParseTuple(args, (char *) "ssssssOOssiOs:authn_request_create",
&providerID, &nameIDPolicy, &forceAuthn, &isPassive,
&protocolProfile, &assertionConsumerServiceID,
&authnContextClassRefs, &authnContextStatementRefs,
@@ -110,3 +112,165 @@ PyObject *authn_request_create(PyObject *self, PyObject *args) {
return (lassoAuthnRequest_wrap(request));
}
+
+/******************************************************************************/
+/* lassoAuthnResponse */
+/******************************************************************************/
+
+PyObject *lassoAuthnResponse_wrap(lassoAuthnResponse *response) {
+ PyObject *ret;
+
+ if (response == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyCObject_FromVoidPtrAndDesc((void *) response,
+ (char *) "lassoAuthnResponse *", NULL);
+ return (ret);
+}
+
+/******************************************************************************/
+
+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("[s]", "node");
+ if (!strcmp(attr, "node"))
+ return (LassoNode_wrap(reponse->node));
+
+ Py_INCREF(Py_None);
+ return (Py_None);
+}
+
+/******************************************************************************/
+
+PyObject *authn_response_create(PyObject *self, PyObject *args) {
+ xmlChar *query;
+ gboolean verify_signature;
+ const xmlChar *public_key_file;
+ const xmlChar *private_key_file;
+ const xmlChar *certificate_file;
+ gboolean is_authenticated;
+
+ lassoAuthnResponse *response;
+
+ if(!PyArg_ParseTuple(args, (char *) "sisssi:authn_response_create",
+ &query, &verify_signature, &public_key_file, &private_key_file,
+ &certificate_file, &is_authenticated))
+ return NULL;
+
+ response = lasso_authn_response_create(query,
+ verify_signature,
+ public_key_file,
+ private_key_file,
+ certificate_file,
+ is_authenticated);
+
+ return (lassoAuthnResponse_wrap(response));
+}
+
+PyObject *authn_response_init(PyObject *self, PyObject *args) {
+ PyObject *response_obj;
+ const xmlChar *providerID;
+ gboolean authentication_result;
+ int ret;
+
+ if(!PyArg_ParseTuple(args, (char *) "Osi:authn_response_init",
+ &response_obj, &providerID, &authentication_result))
+ return NULL;
+
+ ret = lasso_authn_response_init(lassoAuthnResponse_get(response_obj),
+ providerID, authentication_result);
+
+ return (int_wrap(ret));
+}
+
+PyObject *authn_response_add_assertion(PyObject *self, PyObject *args) {
+ PyObject *response_obj, *assertion_obj;
+ int ret;
+
+ if(!PyArg_ParseTuple(args, (char *) "OO:authn_response_add_assertion",
+ &response_obj, &assertion_obj))
+ return NULL;
+
+ ret = lasso_authn_response_add_assertion(lassoAuthnResponse_get(response_obj),
+ LassoNode_get(assertion_obj));
+
+ return (int_wrap(ret));
+}
+
+/******************************************************************************/
+/* assertion */
+/******************************************************************************/
+
+PyObject *assertion_build(PyObject *self, PyObject *args) {
+ PyObject *response_obj;
+ xmlChar *issuer;
+ LassoNode *assertion;
+
+ if(!PyArg_ParseTuple(args, (char *) "Os:assertion_build",
+ &response_obj, &issuer))
+ return NULL;
+
+ assertion = lasso_assertion_build(lassoAuthnResponse_get(response_obj),
+ issuer);
+ return (LassoNode_wrap(assertion));
+}
+
+PyObject *assertion_add_authenticationStatement(PyObject *self, PyObject *args) {
+ PyObject *assertion_obj, *statement_obj;
+ int ret;
+
+ if(!PyArg_ParseTuple(args, (char *) "OO:assertion_add_authenticationStatement",
+ &assertion_obj, &statement_obj))
+ return NULL;
+
+ ret = lasso_assertion_add_authenticationStatement(LassoNode_get(assertion_obj),
+ LassoNode_get(statement_obj));
+
+ return (int_wrap(ret));
+}
+
+/******************************************************************************/
+/* authentication statement */
+/******************************************************************************/
+
+PyObject *authentication_statement_build(PyObject *self, PyObject *args) {
+ xmlChar *authenticationMethod;
+ xmlChar *sessionIndex;
+ xmlChar *reauthenticateOnOrAfter;
+ xmlChar *nameIdentifier;
+ xmlChar *nameQualifier;
+ xmlChar *format;
+ xmlChar *idp_nameIdentifier;
+ xmlChar *idp_nameQualifier;
+ xmlChar *idp_format;
+ xmlChar *confirmationMethod;
+ LassoNode *statement;
+
+ if(!PyArg_ParseTuple(args, (char *) "szsssssssz:authentication_statement_build",
+ &authenticationMethod, &sessionIndex, &reauthenticateOnOrAfter,
+ &nameIdentifier, &nameQualifier, &format, &idp_nameIdentifier,
+ &idp_nameQualifier, &idp_format, &confirmationMethod))
+ return NULL;
+
+ statement = lasso_authentication_statement_build(authenticationMethod, sessionIndex,
+ reauthenticateOnOrAfter,
+ nameIdentifier, nameQualifier,
+ format, idp_nameIdentifier,
+ idp_nameQualifier, idp_format,
+ confirmationMethod);
+
+ return (LassoNode_wrap(statement));
+}
diff --git a/python/protocols/py_single_sign_on_and_federation.h b/python/protocols/py_single_sign_on_and_federation.h
index ea331756..e2a64f1b 100644
--- a/python/protocols/py_single_sign_on_and_federation.h
+++ b/python/protocols/py_single_sign_on_and_federation.h
@@ -35,7 +35,25 @@ typedef struct {
#define lassoAuthnRequest_get(v) (((v) == Py_None) ? NULL : (((lassoAuthnRequest_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj))
PyObject *lassoAuthnRequest_wrap(lassoAuthnRequest *request);
+typedef struct {
+ PyObject_HEAD
+ lassoAuthnResponse *obj;
+} lassoAuthnResponse_object;
+
+#define lassoAuthnResponse_get(v) (((v) == Py_None) ? NULL : (((lassoAuthnResponse_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj))
+PyObject *lassoAuthnResponse_wrap(lassoAuthnResponse *response);
+
PyObject *authn_request_getattr(PyObject *self, PyObject *args);
PyObject *authn_request_create(PyObject *self, PyObject *args);
+PyObject *authn_response_getattr(PyObject *self, PyObject *args);
+PyObject *authn_response_create(PyObject *self, PyObject *args);
+PyObject *authn_response_init(PyObject *self, PyObject *args);
+PyObject *authn_response_add_assertion(PyObject *self, PyObject *args);
+
+PyObject *assertion_build(PyObject *self, PyObject *args);
+PyObject *assertion_add_authenticationStatement(PyObject *self, PyObject *args);
+
+PyObject *authentication_statement_build(PyObject *self, PyObject *args);
+
#endif /* __PYLASSO_PY_SINGLE_SIGN_ON_AND_FEDERATION_H__ */
diff --git a/python/py_lasso.c b/python/py_lasso.c
index a778a043..5fa8f931 100644
--- a/python/py_lasso.c
+++ b/python/py_lasso.c
@@ -27,19 +27,19 @@
#include "py_lasso.h"
PyObject *init(PyObject *self, PyObject *args) {
- return (wrap_int(lasso_init()));
+ return (int_wrap(lasso_init()));
}
PyObject *shutdown(PyObject *self, PyObject *args) {
- return (wrap_int(lasso_shutdown()));
+ return (int_wrap(lasso_shutdown()));
}
PyObject *check_version_exact(PyObject *self, PyObject *args) {
- return (wrap_int(lasso_check_version_exact()));
+ return (int_wrap(lasso_check_version_exact()));
}
PyObject *check_version(PyObject *self, PyObject *args) {
- return (wrap_int(lasso_check_version()));
+ return (int_wrap(lasso_check_version()));
}
PyObject *check_version_ext(PyObject *self, PyObject *args) {
@@ -55,5 +55,5 @@ PyObject *check_version_ext(PyObject *self, PyObject *args) {
}
else return NULL;
- return (wrap_int(lasso_check_version_ext(major, minor, subminor, mode)));
+ return (int_wrap(lasso_check_version_ext(major, minor, subminor, mode)));
}
diff --git a/python/wrap_objs.c b/python/wrap_objs.c
index e3a71840..d175f6ea 100644
--- a/python/wrap_objs.c
+++ b/python/wrap_objs.c
@@ -37,11 +37,11 @@ GPtrArray *PythonStringList2_get(PyObject *list_obj) {
/* Functions to wrap C objects -> Python objects */
/*****************************************************************************/
-PyObject *wrap_int(int val) {
+PyObject *int_wrap(int val) {
return (Py_BuildValue("i", val));
}
-PyObject *wrap_charPtr(char *str) {
+PyObject *charPtr_wrap(char *str) {
PyObject *ret;
if (str == NULL) {
@@ -55,7 +55,7 @@ PyObject *wrap_charPtr(char *str) {
return (ret);
}
-PyObject *wrap_charPtrConst(const char *str) {
+PyObject *charPtrConst_wrap(const char *str) {
PyObject *ret;
if (str == NULL) {
diff --git a/python/wrap_objs.h b/python/wrap_objs.h
index a74dfe86..a846d00a 100644
--- a/python/wrap_objs.h
+++ b/python/wrap_objs.h
@@ -51,9 +51,9 @@ typedef struct {
xmlChar **PythonStringList_get(PyObject *list_obj);
GPtrArray *PythonStringList2_get(PyObject *list_obj);
-PyObject *wrap_int(int val);
-PyObject *wrap_charPtr(char *str);
-PyObject *wrap_charPtrConst(const char *str);
+PyObject *int_wrap(int val);
+PyObject *charPtr_wrap(char *str);
+PyObject *charPtrConst_wrap(const char *str);
PyObject *wrap_xmlCharPtr(xmlChar *str);
PyObject *wrap_xmlCharPtrConst(const xmlChar *str);
diff --git a/python/xml/py_xml.c b/python/xml/py_xml.c
index 49dd7c46..1ce046eb 100644
--- a/python/xml/py_xml.c
+++ b/python/xml/py_xml.c
@@ -75,3 +75,22 @@ PyObject *node_unref(PyObject *self, PyObject *args) {
Py_INCREF(Py_None);
return (Py_None);
}
+
+PyObject *node_url_encode(PyObject *self, PyObject *args) {
+ PyObject *node_obj;
+ guint sign_method;
+ const gchar *private_key_file;
+ gchar *ret;
+
+ if (CheckArgs(args, "OIS:node_unref")) {
+ if(!PyArg_ParseTuple(args, (char *) "Ois:node_url_encode",
+ &node_obj, &sign_method, &private_key_file))
+ return NULL;
+ }
+ else return NULL;
+
+ ret = lasso_node_url_encode(LassoNode_get(node_obj),
+ sign_method, private_key_file);
+
+ return (charPtr_wrap(ret));
+}
diff --git a/python/xml/py_xml.h b/python/xml/py_xml.h
index b72dbe55..a1a186ab 100644
--- a/python/xml/py_xml.h
+++ b/python/xml/py_xml.h
@@ -37,5 +37,6 @@ PyObject *LassoNode_wrap(LassoNode *node);
PyObject *node_dump(PyObject *self, PyObject *args);
PyObject *node_unref(PyObject *self, PyObject *args);
+PyObject *node_url_encode(PyObject *self, PyObject *args);
#endif /* __PYLASSO_PY_XML_H__ */