diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-07-11 22:13:42 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-07-11 22:13:42 +0000 |
| commit | c1ffd41e7599ac1502c29d0a04a2b1ca289d7f66 (patch) | |
| tree | 68f2c852a9fb6491f3c6953f9c32a10dabd1e3e3 | |
| parent | 9f85a16d977b9724c2ef45e819a03ed4c00d6cdc (diff) | |
| download | lasso-c1ffd41e7599ac1502c29d0a04a2b1ca289d7f66.tar.gz lasso-c1ffd41e7599ac1502c29d0a04a2b1ca289d7f66.tar.xz lasso-c1ffd41e7599ac1502c29d0a04a2b1ca289d7f66.zip | |
*** empty log message ***
| -rw-r--r-- | lasso/Attic/protocols/authn_request.c | 290 | ||||
| -rw-r--r-- | lasso/Attic/protocols/authn_request.h | 4 | ||||
| -rw-r--r-- | lasso/Attic/protocols/authn_response.c | 7 | ||||
| -rw-r--r-- | lasso/id-ff/login.c | 3 | ||||
| -rw-r--r-- | python/environs/py_login.c | 57 | ||||
| -rw-r--r-- | python/environs/py_login.h | 3 | ||||
| -rw-r--r-- | python/lasso.py | 3 | ||||
| -rw-r--r-- | python/lassomod.c | 3 |
8 files changed, 224 insertions, 146 deletions
diff --git a/lasso/Attic/protocols/authn_request.c b/lasso/Attic/protocols/authn_request.c index 9ad46c0c..df2cfbef 100644 --- a/lasso/Attic/protocols/authn_request.c +++ b/lasso/Attic/protocols/authn_request.c @@ -181,157 +181,167 @@ lasso_authn_request_new(const xmlChar *providerID) } LassoNode* -lasso_authn_request_new_from_query(gchar *query) +lasso_authn_request_new_from_export(gchar *buffer, + lassoNodeExportTypes export_type) { - LassoNode *request, *authn_context = NULL, *scoping; + LassoNode *request=NULL, *authn_context=NULL, *scoping; GData *gd; xmlChar *str; GPtrArray *array; gint i; - request = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_REQUEST, NULL)); - - gd = lasso_query_to_dict(query); - - /* RequestID */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0); - if (str != NULL) - lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(request), - str); - else { - g_datalist_clear(&gd); - g_object_unref(request); - return (NULL); - } - - /* MajorVersion */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MajorVersion"), 0); - if (str != NULL) - lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), - str); - else - lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), - lassoLibMajorVersion); + g_return_val_if_fail(buffer != NULL, NULL); - /* MinorVersion */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MinorVersion"), 0); - if (str != NULL) - lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), - str); - else - lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), - lassoLibMinorVersion); - - /* IssueInstant */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IssueInstance"), 0); - if (str != NULL) { - lasso_samlp_request_abstract_set_issueInstance(LASSO_SAMLP_REQUEST_ABSTRACT(request), - str); - } - else { - g_datalist_clear(&gd); - g_object_unref(request); - return (NULL); - } - - /* ProviderID */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProviderID"), 0); - if (str != NULL) - lasso_lib_authn_request_set_providerID(LASSO_LIB_AUTHN_REQUEST(request), str); - else { - g_datalist_clear(&gd); - g_object_unref(request); - return (NULL); - } + request = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_REQUEST, NULL)); - /* NameIDPolicy */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "NameIDPolicy"), 0); - if (str != NULL) - lasso_lib_authn_request_set_nameIDPolicy(LASSO_LIB_AUTHN_REQUEST(request), str); - - /* ForceAuthn */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ForceAuthn"), 0); - if (str != NULL){ - if(!strcmp(str, "true")) - lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(request), TRUE); - else if(!strcmp(str, "false")) - lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(request), FALSE); - } + switch (export_type) { + case lassoNodeExportTypeQuery: + gd = lasso_query_to_dict(buffer); + + /* RequestID */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0); + if (str != NULL) + lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(request), + str); + else { + g_datalist_clear(&gd); + g_object_unref(request); + return (NULL); + } - /* IsPassive */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IsPassive"), 0); - if (str != NULL){ - if(!strcmp(str, "true")) - lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(request), TRUE); + /* MajorVersion */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MajorVersion"), 0); + if (str != NULL) + lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), + str); else - lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(request), FALSE); - } - - /* ProtocolProfile */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProtocolProfile"), 0); - if (str != NULL) - lasso_lib_authn_request_set_protocolProfile(LASSO_LIB_AUTHN_REQUEST(request), str); - - /* AssertionConsumerServiceID */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "AssertionConsumerServiceID"), 0); - if (str != NULL) - lasso_lib_authn_request_set_assertionConsumerServiceID(LASSO_LIB_AUTHN_REQUEST(request), str); - - /* AuthnContext */ - array = (GPtrArray *)g_datalist_get_data(&gd, "AuthnContextClassRef"); - if (array != NULL) { - if (authn_context == NULL) - authn_context = lasso_lib_request_authn_context_new(); - for(i=0; i<array->len; i++) - lasso_lib_request_authn_context_add_authnContextClassRef(LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context), - lasso_g_ptr_array_index(array, i)); - } - array = (GPtrArray *)g_datalist_get_data(&gd, "AuthnContextStatementRef"); - if (array != NULL) { - if (authn_context == NULL) - authn_context = lasso_lib_request_authn_context_new(); - for(i=0; i<array->len; i++) - lasso_lib_request_authn_context_add_authnContextStatementRef(LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context), - lasso_g_ptr_array_index(array, i)); - } - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "AuthnContextComparison"), 0); - if (str != NULL) { - if (authn_context == NULL) - authn_context = lasso_lib_request_authn_context_new(); - lasso_lib_request_authn_context_set_authnContextComparison(LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context), - str); - } - if (authn_context != NULL) { - lasso_lib_authn_request_set_requestAuthnContext(LASSO_LIB_AUTHN_REQUEST(request), - LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context)); - lasso_node_destroy(authn_context); - } - - /* RelayState */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RelayState"), 0); - if (str != NULL) { - lasso_lib_authn_request_set_relayState(LASSO_LIB_AUTHN_REQUEST(request), str); - } - - /* Scoping - FIXME -> IDPList */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProxyCount"), 0); - if (str != NULL) { - /* create a new Scoping instance */ - scoping = lasso_lib_scoping_new(); - /* ProxyCount */ - lasso_lib_scoping_set_proxyCount(LASSO_LIB_SCOPING(scoping), atoi(str)); - lasso_lib_authn_request_set_scoping(LASSO_LIB_AUTHN_REQUEST(request), - LASSO_LIB_SCOPING(scoping)); - lasso_node_destroy(scoping); - } - - /* consent */ - str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "consent"), 0); - if (str != NULL) { - lasso_lib_authn_request_set_consent(LASSO_LIB_AUTHN_REQUEST(request), str); + lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), + lassoLibMajorVersion); + + /* MinorVersion */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MinorVersion"), 0); + if (str != NULL) + lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), + str); + else + lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), + lassoLibMinorVersion); + + /* IssueInstant */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IssueInstance"), 0); + if (str != NULL) { + lasso_samlp_request_abstract_set_issueInstance(LASSO_SAMLP_REQUEST_ABSTRACT(request), + str); + } + else { + g_datalist_clear(&gd); + g_object_unref(request); + return (NULL); + } + + /* ProviderID */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProviderID"), 0); + if (str != NULL) + lasso_lib_authn_request_set_providerID(LASSO_LIB_AUTHN_REQUEST(request), str); + else { + g_datalist_clear(&gd); + g_object_unref(request); + return (NULL); + } + + /* NameIDPolicy */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "NameIDPolicy"), 0); + if (str != NULL) + lasso_lib_authn_request_set_nameIDPolicy(LASSO_LIB_AUTHN_REQUEST(request), str); + + /* ForceAuthn */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ForceAuthn"), 0); + if (str != NULL){ + if(!strcmp(str, "true")) + lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(request), TRUE); + else if(!strcmp(str, "false")) + lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(request), FALSE); + } + + /* IsPassive */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IsPassive"), 0); + if (str != NULL){ + if(!strcmp(str, "true")) + lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(request), TRUE); + else + lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(request), FALSE); + } + + /* ProtocolProfile */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProtocolProfile"), 0); + if (str != NULL) + lasso_lib_authn_request_set_protocolProfile(LASSO_LIB_AUTHN_REQUEST(request), str); + + /* AssertionConsumerServiceID */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "AssertionConsumerServiceID"), 0); + if (str != NULL) + lasso_lib_authn_request_set_assertionConsumerServiceID(LASSO_LIB_AUTHN_REQUEST(request), str); + + /* AuthnContext */ + array = (GPtrArray *)g_datalist_get_data(&gd, "AuthnContextClassRef"); + if (array != NULL) { + if (authn_context == NULL) + authn_context = lasso_lib_request_authn_context_new(); + for(i=0; i<array->len; i++) + lasso_lib_request_authn_context_add_authnContextClassRef(LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context), + lasso_g_ptr_array_index(array, i)); + } + array = (GPtrArray *)g_datalist_get_data(&gd, "AuthnContextStatementRef"); + if (array != NULL) { + if (authn_context == NULL) + authn_context = lasso_lib_request_authn_context_new(); + for(i=0; i<array->len; i++) + lasso_lib_request_authn_context_add_authnContextStatementRef(LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context), + lasso_g_ptr_array_index(array, i)); + } + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "AuthnContextComparison"), 0); + if (str != NULL) { + if (authn_context == NULL) + authn_context = lasso_lib_request_authn_context_new(); + lasso_lib_request_authn_context_set_authnContextComparison(LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context), + str); + } + if (authn_context != NULL) { + lasso_lib_authn_request_set_requestAuthnContext(LASSO_LIB_AUTHN_REQUEST(request), + LASSO_LIB_REQUEST_AUTHN_CONTEXT(authn_context)); + lasso_node_destroy(authn_context); + } + + /* RelayState */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RelayState"), 0); + if (str != NULL) { + lasso_lib_authn_request_set_relayState(LASSO_LIB_AUTHN_REQUEST(request), str); + } + + /* Scoping + FIXME -> IDPList */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProxyCount"), 0); + if (str != NULL) { + /* create a new Scoping instance */ + scoping = lasso_lib_scoping_new(); + /* ProxyCount */ + lasso_lib_scoping_set_proxyCount(LASSO_LIB_SCOPING(scoping), atoi(str)); + lasso_lib_authn_request_set_scoping(LASSO_LIB_AUTHN_REQUEST(request), + LASSO_LIB_SCOPING(scoping)); + lasso_node_destroy(scoping); + } + + /* consent */ + str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "consent"), 0); + if (str != NULL) { + lasso_lib_authn_request_set_consent(LASSO_LIB_AUTHN_REQUEST(request), str); + } + + g_datalist_clear(&gd); + break; + case lassoNodeExportTypeBase64: + break; } - g_datalist_clear(&gd); return (request); } diff --git a/lasso/Attic/protocols/authn_request.h b/lasso/Attic/protocols/authn_request.h index 88d0815d..4048b4eb 100644 --- a/lasso/Attic/protocols/authn_request.h +++ b/lasso/Attic/protocols/authn_request.h @@ -58,7 +58,9 @@ LASSO_EXPORT gchar* lasso_authn_request_get_protocolProfile (gchar *query); LASSO_EXPORT GType lasso_authn_request_get_type (void); LASSO_EXPORT LassoNode* lasso_authn_request_new (const xmlChar *providerID); -LASSO_EXPORT LassoNode* lasso_authn_request_new_from_query (gchar *query); + +LASSO_EXPORT LassoNode* lasso_authn_request_new_from_export (gchar *buffer, + lassoNodeExportTypes export_type); LASSO_EXPORT void lasso_authn_request_set_requestAuthnContext (LassoAuthnRequest *request, GPtrArray *authnContextClassRefs, diff --git a/lasso/Attic/protocols/authn_response.c b/lasso/Attic/protocols/authn_response.c index efbbef23..30b1ae92 100644 --- a/lasso/Attic/protocols/authn_response.c +++ b/lasso/Attic/protocols/authn_response.c @@ -154,7 +154,7 @@ lasso_authn_response_new_from_export(xmlChar *buffer, lassoNodeExportTypes export_type) { xmlChar *buffer_decoded = xmlMalloc(strlen(buffer)); - LassoNode *response; + LassoNode *response = NULL; g_return_val_if_fail(buffer != NULL, NULL); @@ -163,14 +163,13 @@ lasso_authn_response_new_from_export(xmlChar *buffer, switch (export_type) { case lassoNodeExportTypeBase64: xmlSecBase64Decode(buffer, buffer_decoded, strlen(buffer)); + lasso_node_import(response, buffer_decoded); + xmlFree(buffer_decoded); break; case lassoNodeExportTypeQuery: case lassoNodeExportTypeSoap: break; } - lasso_node_import(response, buffer_decoded); - xmlFree(buffer_decoded); - return (response); } diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c index 5ba05a65..021e97cf 100644 --- a/lasso/id-ff/login.c +++ b/lasso/id-ff/login.c @@ -373,7 +373,8 @@ lasso_login_init_from_authn_request_msg(LassoLogin *login, case lassoHttpMethodGet: case lassoHttpMethodRedirect: /* LibAuthnRequest send by method GET */ - LASSO_PROFILE_CONTEXT(login)->request = lasso_authn_request_new_from_query(authn_request_msg); + LASSO_PROFILE_CONTEXT(login)->request = lasso_authn_request_new_from_export(authn_request_msg, + lassoNodeExportTypeQuery); break; case lassoHttpMethodPost: /* TODO LibAuthnRequest send by method POST */ diff --git a/python/environs/py_login.c b/python/environs/py_login.c index 6d2882c0..c2f8691b 100644 --- a/python/environs/py_login.c +++ b/python/environs/py_login.c @@ -165,6 +165,29 @@ PyObject *login_build_authn_request_msg(PyObject *self, PyObject *args) { return (int_wrap(ret)); } +PyObject *login_build_authn_response_msg(PyObject *self, PyObject *args) { + PyObject *login_obj; + gint authentication_result; + const gchar *authenticationMethod; + const gchar *reauthenticateOnOrAfter; + gint ret; + + if (CheckArgs(args, "OISS:login_build_artifact_msg")) { + if(!PyArg_ParseTuple(args, (char *) "Oiss:login_build_artifact_msg", + &login_obj, &authentication_result, + &authenticationMethod, &reauthenticateOnOrAfter)) + return NULL; + } + else return NULL; + + ret = lasso_login_build_authn_response_msg(LassoLogin_get(login_obj), + authentication_result, + authenticationMethod, + reauthenticateOnOrAfter); + + return (int_wrap(ret)); +} + PyObject *login_build_request_msg(PyObject *self, PyObject *args) { PyObject *login_obj; gint ret; @@ -181,6 +204,40 @@ PyObject *login_build_request_msg(PyObject *self, PyObject *args) { return (int_wrap(ret)); } +PyObject *login_dump(PyObject *self, PyObject *args) { + PyObject *login_obj; + gchar *ret; + + if (CheckArgs(args, "O:login_dump")) { + if(!PyArg_ParseTuple(args, (char *) "O:login_dump", + &login_obj)) + return NULL; + } + else return NULL; + + ret = lasso_login_dump(LassoLogin_get(login_obj)); + + return (charPtrConst_wrap(ret)); +} + +PyObject *login_handle_authn_response_msg(PyObject *self, PyObject *args) { + PyObject *login_obj; + gchar *authn_response_msg; + gboolean ret; + + if (CheckArgs(args, "OS:login_handle_authn_response_msg")) { + if(!PyArg_ParseTuple(args, (char *) "Os:login_handle_authn_response_msg", + &login_obj, &authn_response_msg)) + return NULL; + } + else return NULL; + + ret = lasso_login_handle_authn_response_msg(LassoLogin_get(login_obj), + authn_response_msg); + + return (int_wrap(ret)); +} + PyObject *login_handle_request_msg(PyObject *self, PyObject *args) { PyObject *login_obj; gchar *request_msg; diff --git a/python/environs/py_login.h b/python/environs/py_login.h index 8fed53ae..3c50fe9f 100644 --- a/python/environs/py_login.h +++ b/python/environs/py_login.h @@ -44,7 +44,10 @@ 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_build_authn_response_msg(PyObject *self, PyObject *args); PyObject *login_build_request_msg(PyObject *self, PyObject *args); +PyObject *login_dump(PyObject *self, PyObject *args); +PyObject *login_handle_authn_response_msg(PyObject *self, PyObject *args); PyObject *login_handle_request_msg(PyObject *self, PyObject *args); PyObject *login_init_authn_request(PyObject *self, PyObject *args); PyObject *login_init_from_authn_request_msg(PyObject *self, PyObject *args); diff --git a/python/lasso.py b/python/lasso.py index 8f6df7c1..c171ac33 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -874,6 +874,9 @@ class Login: def build_request_msg(self): return lassomod.login_build_request_msg(self) + def handle_authn_response_msg(self, authn_response_msg): + return lassomod.login_handle_authn_response_msg(self, authn_response_msg) + def handle_request_msg(self, request_msg): return lassomod.login_handle_request_msg(self, request_msg) diff --git a/python/lassomod.c b/python/lassomod.c index 846e07e3..ce18c5e4 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -207,7 +207,10 @@ static PyMethodDef lasso_methods[] = { {"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_build_authn_response_msg", login_build_authn_response_msg, METH_VARARGS}, {"login_build_request_msg", login_build_request_msg, METH_VARARGS}, + {"login_dump", login_dump, METH_VARARGS}, + {"login_handle_authn_response_msg", login_handle_authn_response_msg, METH_VARARGS}, {"login_handle_request_msg", login_handle_request_msg, METH_VARARGS}, {"login_init_authn_request", login_init_authn_request, METH_VARARGS}, {"login_init_from_authn_request_msg", login_init_from_authn_request_msg, METH_VARARGS}, |
