From a914a109350e3285e6c8118644ba2162cd8632ad Mon Sep 17 00:00:00 2001 From: Valery Febvre Date: Thu, 8 Apr 2004 02:44:16 +0000 Subject: *** empty log message *** --- .../protocols/py_single_sign_on_and_federation.c | 172 ++++++++++++++++++++- .../protocols/py_single_sign_on_and_federation.h | 18 +++ 2 files changed, 186 insertions(+), 4 deletions(-) (limited to 'python/protocols') 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; @@ -39,8 +43,6 @@ PyObject *lassoAuthnRequest_wrap(lassoAuthnRequest *request) { return (ret); } -/******************************************************************************/ -/* lassoAuthnRequest */ /******************************************************************************/ PyObject *authn_request_getattr(PyObject *self, PyObject *args) { @@ -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__ */ -- cgit