diff options
| -rw-r--r-- | lasso/Attic/protocols/authn_response.c | 106 | ||||
| -rw-r--r-- | lasso/Attic/protocols/authn_response.h | 34 | ||||
| -rw-r--r-- | lasso/Attic/protocols/elements/authentication_statement.c | 16 | ||||
| -rw-r--r-- | lasso/Attic/protocols/elements/authentication_statement.h | 4 | ||||
| -rw-r--r-- | lasso/xml/xml.c | 1 | ||||
| -rwxr-xr-x | python/examples/test.py | 24 | ||||
| -rw-r--r-- | python/lasso.py | 94 | ||||
| -rw-r--r-- | python/lasso_strings.py | 13 | ||||
| -rw-r--r-- | python/lassomod.c | 8 | ||||
| -rw-r--r-- | python/protocols/elements/py_authentication_statement.c | 14 | ||||
| -rw-r--r-- | python/protocols/py_authn_response.c | 32 | ||||
| -rw-r--r-- | python/protocols/py_authn_response.h | 3 | ||||
| -rwxr-xr-x | python/setup.py | 1 |
13 files changed, 239 insertions, 111 deletions
diff --git a/lasso/Attic/protocols/authn_response.c b/lasso/Attic/protocols/authn_response.c index 680b4e21..d5e358a1 100644 --- a/lasso/Attic/protocols/authn_response.c +++ b/lasso/Attic/protocols/authn_response.c @@ -24,6 +24,9 @@ */ #include <lasso/protocols/authn_response.h> +#include <lasso/protocols/authn_request.h> + +static GObjectClass *parent_class = NULL; /*****************************************************************************/ /* public methods */ @@ -41,7 +44,7 @@ lasso_authn_response_add_assertion(LassoAuthnResponse *response, /* FIXME : Signature */ doc = xmlNewDoc("1.0"); // <--- xmlAddChild((xmlNodePtr)doc, - LASSO_NODE_GET_CLASS(response)->get_xmlNode(response)); + LASSO_NODE_GET_CLASS(response)->get_xmlNode(LASSO_NODE(response))); signature = lasso_ds_signature_new(doc, xmlSecTransformRsaSha1Id); lasso_saml_assertion_set_signature(LASSO_SAML_ASSERTION(assertion), @@ -53,6 +56,12 @@ lasso_authn_response_add_assertion(LassoAuthnResponse *response, certificate_file); } +void +lasso_authn_response_get_requestID(LassoAuthnResponse *response) +{ + +} + gboolean lasso_authn_response_must_authenticate(LassoAuthnResponse *response, gboolean is_authenticated) @@ -103,7 +112,7 @@ lasso_authn_response_verify_signature(LassoAuthnResponse *response, xmlChar *public_key_file, xmlChar *private_key_file) { - g_return_val_if_fail(LASSO_IS_AUTHN_RESPONSE(response), 1); + g_return_val_if_fail(LASSO_IS_AUTHN_RESPONSE(response), FALSE); LassoNode *status, *status_code; gboolean signature_status; @@ -139,6 +148,50 @@ lasso_authn_response_verify_signature(LassoAuthnResponse *response, } /*****************************************************************************/ +/* overrided parent classes methods */ +/*****************************************************************************/ + +static void +lasso_authn_response_dispose(LassoAuthnResponse *response) +{ + parent_class->dispose(LASSO_NODE(response)); +} + +/* override lasso_node_dump() method */ +static xmlChar * +lasso_authn_response_dump(LassoAuthnResponse *response, + const xmlChar *encoding, + int format) +{ + LassoNode *response_dump; + xmlChar *dump; + + response_dump = lasso_node_new(); + LASSO_NODE_GET_CLASS(response_dump)->set_name(response_dump, "LassoDumpAuthnResponse"); + LASSO_NODE_GET_CLASS(response_dump)->add_child(response_dump, + lasso_node_copy(response), 0); + if (response->query != NULL) + LASSO_NODE_GET_CLASS(response_dump)->add_child(response_dump, + lasso_authn_request_new_from_query(response->query), 0); + else + LASSO_NODE_GET_CLASS(response_dump)->add_child(response_dump, + lasso_node_copy(response->request), 0); + dump = lasso_node_dump(response_dump, encoding, format); + g_object_unref(G_OBJECT (response_dump)); + + return (dump); +} + +static void +lasso_authn_response_finalize(LassoAuthnResponse *response) +{ + xmlFree(response->query); + if (response->request != NULL) + g_object_unref(response->request); + parent_class->finalize(LASSO_NODE(response)); +} + +/*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ @@ -150,6 +203,14 @@ lasso_authn_response_instance_init(LassoAuthnResponse *response) static void lasso_authn_response_class_init(LassoAuthnResponseClass *class) { + GObjectClass *gobject_class = G_OBJECT_CLASS(class); + LassoNodeClass *lasso_node_class = LASSO_NODE_CLASS(class); + + parent_class = g_type_class_peek_parent(class); + /* override parent classes methods */ + gobject_class->dispose = (void *)lasso_authn_response_dispose; + gobject_class->finalize = (void *)lasso_authn_response_finalize; + lasso_node_class->dump = lasso_authn_response_dump; } GType lasso_authn_response_get_type() { @@ -176,8 +237,35 @@ GType lasso_authn_response_get_type() { } LassoNode* -lasso_authn_response_new(xmlChar *query, - const xmlChar *providerID) +lasso_authn_response_new_from_dump(xmlChar *buffer) +{ + LassoNode *response, *request, *node_dump; + xmlNodePtr xmlNode_response, xmlNode_request; + + g_return_val_if_fail(buffer != NULL, NULL); + + response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE, NULL)); + request = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_REQUEST, NULL)); + + node_dump = lasso_node_new_from_dump(buffer); + /* get xmlNodes */ + xmlNode_response = xmlCopyNode(LASSO_NODE_GET_CLASS(response)->get_xmlNode(lasso_node_get_child(node_dump, "AuthnResponse")), 1); + xmlNode_request = xmlCopyNode(LASSO_NODE_GET_CLASS(response)->get_xmlNode(lasso_node_get_child(node_dump, "AuthnRequest")), 1); + + /* put xmlNodes in LassoNodes */ + LASSO_NODE_GET_CLASS(response)->set_xmlNode(response, xmlNode_response); + LASSO_NODE_GET_CLASS(request)->set_xmlNode(request, xmlNode_request); + + LASSO_AUTHN_RESPONSE(response)->request = request; + LASSO_AUTHN_RESPONSE(response)->query = NULL; + g_object_unref(node_dump); + + return (response); +} + +LassoNode* +lasso_authn_response_new_from_request_query(xmlChar *query, + const xmlChar *providerID) { GData *gd; LassoNode *response, *status, *status_code; @@ -188,7 +276,9 @@ lasso_authn_response_new(xmlChar *query, response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE, NULL)); gd = lasso_query_to_dict(query); + /* store query - need to verify signature */ LASSO_AUTHN_RESPONSE(response)->query = query; + LASSO_AUTHN_RESPONSE(response)->request = NULL; /* ResponseID */ lasso_samlp_response_abstract_set_responseID(LASSO_SAMLP_RESPONSE_ABSTRACT(response), @@ -216,7 +306,6 @@ lasso_authn_response_new(xmlChar *query, if (lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0) != NULL) { lasso_samlp_response_abstract_set_inResponseTo(LASSO_SAMLP_RESPONSE_ABSTRACT(response), lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0)); - LASSO_AUTHN_RESPONSE(response)->requestID = g_strdup(lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0)); } /* consent */ @@ -243,3 +332,10 @@ lasso_authn_response_new(xmlChar *query, return (response); } + +LassoNode* +lasso_authn_response_new_from_lareq(xmlChar *lareq, + const xmlChar *providerID) +{ + +} diff --git a/lasso/Attic/protocols/authn_response.h b/lasso/Attic/protocols/authn_response.h index 50931a24..a988750e 100644 --- a/lasso/Attic/protocols/authn_response.h +++ b/lasso/Attic/protocols/authn_response.h @@ -46,34 +46,36 @@ typedef struct _LassoAuthnResponseClass LassoAuthnResponseClass; struct _LassoAuthnResponse { LassoLibAuthnResponse parent; /*< public >*/ - xmlChar *requestID; + xmlChar *query; + LassoNode *request; /*< private >*/ - xmlChar *query; }; struct _LassoAuthnResponseClass { LassoLibAuthnResponseClass parent; }; -LASSO_EXPORT GType lasso_authn_response_get_type (void); +LASSO_EXPORT GType lasso_authn_response_get_type (void); -LASSO_EXPORT LassoNode* lasso_authn_response_new (xmlChar *query, - const xmlChar *providerID); +LASSO_EXPORT LassoNode* lasso_authn_response_new_from_request_query (xmlChar *query, + const xmlChar *providerID); -LASSO_EXPORT void lasso_authn_response_add_assertion (LassoAuthnResponse *response, - LassoAssertion *assertion, - const xmlChar *private_key_file, - const xmlChar *certificate_file); +LASSO_EXPORT LassoNode* lasso_authn_response_new_from_dump (xmlChar *buffer); -LASSO_EXPORT gboolean lasso_authn_response_must_authenticate (LassoAuthnResponse *response, - gboolean is_authenticated); +LASSO_EXPORT void lasso_authn_response_add_assertion (LassoAuthnResponse *response, + LassoAssertion *assertion, + const xmlChar *private_key_file, + const xmlChar *certificate_file); -LASSO_EXPORT void lasso_authn_response_process_authentication_result(LassoAuthnResponse *response, - gboolean authentication_result); +LASSO_EXPORT gboolean lasso_authn_response_must_authenticate (LassoAuthnResponse *response, + gboolean is_authenticated); -LASSO_EXPORT gboolean lasso_authn_response_verify_signature (LassoAuthnResponse *response, - xmlChar *public_key_file, - xmlChar *private_key_file); +LASSO_EXPORT void lasso_authn_response_process_authentication_result (LassoAuthnResponse *response, + gboolean authentication_result); + +LASSO_EXPORT gboolean lasso_authn_response_verify_signature (LassoAuthnResponse *response, + xmlChar *public_key_file, + xmlChar *private_key_file); #ifdef __cplusplus } diff --git a/lasso/Attic/protocols/elements/authentication_statement.c b/lasso/Attic/protocols/elements/authentication_statement.c index c2f8d49c..18db1f78 100644 --- a/lasso/Attic/protocols/elements/authentication_statement.c +++ b/lasso/Attic/protocols/elements/authentication_statement.c @@ -68,15 +68,13 @@ GType lasso_authentication_statement_get_type() { LassoNode* lasso_authentication_statement_new(const xmlChar *authenticationMethod, - const xmlChar *sessionIndex, const xmlChar *reauthenticateOnOrAfter, xmlChar *nameIdentifier, const xmlChar *nameQualifier, const xmlChar *format, xmlChar *idp_nameIdentifier, const xmlChar *idp_nameQualifier, - const xmlChar *idp_format, - const xmlChar *confirmationMethod) + const xmlChar *idp_format) { LassoNode *statement; LassoNode *subject, *identifier, *idp_identifier, *subject_confirmation; @@ -87,10 +85,6 @@ lasso_authentication_statement_new(const xmlChar *authenticationMethod, authenticationMethod); lasso_saml_authentication_statement_set_authenticationInstant(LASSO_SAML_AUTHENTICATION_STATEMENT(statement), lasso_get_current_time()); - if (sessionIndex != NULL) { - lasso_lib_authentication_statement_set_sessionIndex(LASSO_LIB_AUTHENTICATION_STATEMENT(statement), - sessionIndex); - } lasso_lib_authentication_statement_set_reauthenticateOnOrAfter(LASSO_LIB_AUTHENTICATION_STATEMENT(statement), reauthenticateOnOrAfter); @@ -113,14 +107,12 @@ lasso_authentication_statement_new(const xmlChar *authenticationMethod, LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER(idp_identifier)); subject_confirmation = lasso_saml_subject_confirmation_new(); lasso_saml_subject_confirmation_set_subjectConfirmationMethod(LASSO_SAML_SUBJECT_CONFIRMATION(subject_confirmation), - confirmationMethod); + lassoSamlConfirmationMethodBearer); lasso_saml_subject_set_subjectConfirmation(LASSO_SAML_SUBJECT(subject), LASSO_SAML_SUBJECT_CONFIRMATION(subject_confirmation)); - if (confirmationMethod != NULL) { - lasso_saml_subject_statement_abstract_set_subject(LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(statement), - LASSO_SAML_SUBJECT(subject)); - } + lasso_saml_subject_statement_abstract_set_subject(LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(statement), + LASSO_SAML_SUBJECT(subject)); return (statement); } diff --git a/lasso/Attic/protocols/elements/authentication_statement.h b/lasso/Attic/protocols/elements/authentication_statement.h index d1360541..4283a239 100644 --- a/lasso/Attic/protocols/elements/authentication_statement.h +++ b/lasso/Attic/protocols/elements/authentication_statement.h @@ -54,15 +54,13 @@ struct _LassoAuthenticationStatementClass { LASSO_EXPORT GType lasso_authentication_statement_get_type (void); LASSO_EXPORT LassoNode* lasso_authentication_statement_new (const xmlChar *authenticationMethod, - const xmlChar *sessionIndex, const xmlChar *reauthenticateOnOrAfter, xmlChar *nameIdentifier, const xmlChar *nameQualifier, const xmlChar *format, xmlChar *idp_nameIdentifier, const xmlChar *idp_nameQualifier, - const xmlChar *idp_format, - const xmlChar *confirmationMethod); + const xmlChar *idp_format); #ifdef __cplusplus } diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 86bafc5a..80acbb14 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -685,7 +685,6 @@ lasso_node_impl_url_encode(LassoNode *node, gchar *ret; g_return_val_if_fail (LASSO_IS_NODE(node), NULL); - g_return_val_if_fail (private_key_file != NULL, NULL); msg = lasso_node_build_query(node); diff --git a/python/examples/test.py b/python/examples/test.py index 1373ca01..089c4b1d 100755 --- a/python/examples/test.py +++ b/python/examples/test.py @@ -17,13 +17,8 @@ req.set_requestAuthnContext(["test"], lasso.libAuthnContextComparisonExact) req.set_scoping(proxyCount=1) -# admiration du resultat -req.dump() - # url encodage + signature query = req.url_encode(1, "../../examples/rsakey.pem") - -print query req.destroy() # creation de la response AuthnResponse OU Response @@ -31,38 +26,39 @@ req.destroy() protocolProfile = lasso.authn_request_get_protocolProfile(query) if protocolProfile == lasso.libProtocolProfilePost: # partie IDP - res = lasso.AuthnResponse(query, "http://providerid.com") + res = lasso.AuthnResponse.new_from_request_query(query, "http://providerid.com") # verification de la signature de la query print res.verify_signature("../../examples/rsapub.pem", "../../examples/rsakey.pem") print res.must_authenticate(is_authenticated=0) res.process_authentication_result(0) + # dump pour envoi au SP + dump_response = res.dump() + res.destroy() + + res = lasso.AuthnResponse.new_from_dump(dump_response) # creation de l'assertion - assertion = lasso.Assertion("issuer", res.requestID) + assertion = lasso.Assertion("issuer", res.get_attr_value("InResponseTo")) authentication_statement = lasso.AuthenticationStatement("password", - "3", "tralala", "dslqkjfslfj", "http://service-provider.com", "federated", "wxkfjesmqfj", "http://idp-provider.com", - "federated", - "bearer") + "federated") assertion.add_authenticationStatement(authentication_statement) # ajout de l'assertion res.add_assertion(assertion, "../../examples/rsakey.pem", "../../examples/rsacert.pem") - # dump pour envoi au SP - dump_response = res.dump() # partie SP # Verification de la signature de l'assertion - print res.get_child("Assertion").verify_signature("../../examples/rootcert.pem") + print "Signature check: ", res.get_child("Assertion").verify_signature("../../examples/rootcert.pem") # recuperation du StatusCode status_code = res.get_child("StatusCode") # recuperation de la valeur de l'attribut "Value" - print status_code.get_attr_value("Value") + print "Resultat de la demande d'authentification:", status_code.get_attr_value("Value") res.destroy() else: print "La Response (par artifact) n'est pas encore implementée" diff --git a/python/lasso.py b/python/lasso.py index cc20815d..bf498859 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -82,6 +82,48 @@ class Node: return lassomod.node_verify_signature(self, certificate_file) +class SamlAssertion(Node): + def __init__(self, _obj=None): + """ + """ + if _obj != None: + self._o = _obj + return + _obj = lassomod.saml_assertion_new() + if _obj is None: raise Error('lasso_saml_assertion_new() failed') + Node.__init__(self, _obj=_obj) + + def add_authenticationStatement(self, authenticationStatement): + lassomod.saml_assertion_add_authenticationStatement(self, + authenticationStatement) + + +class SamlAuthenticationStatement(Node): + def __init__(self, _obj=None): + """ + """ + if _obj != None: + self._o = _obj + return + _obj = lassomod.saml_authentication_statement_new() + if _obj is None: raise Error('lasso_saml_authentication_statement_new() failed') + Node.__init__(self, _obj=_obj) + + +class LibAuthenticationStatement(SamlAuthenticationStatement): + def __init__(self, _obj=None): + """ + """ + if _obj != None: + self._o = _obj + return + _obj = lassomod.lib_authentication_statement_new() + if _obj is None: raise Error('lasso_saml_authentication_statement_new() failed') + SamlAuthenticationStatement.__init__(self, _obj=_obj) + def set_sessionIndex(self, sessionIndex): + lassomod.lib_authentication_statement_set_sessionIndex(self, sessionIndex) + + class LibAuthnRequest(Node): def __init__(self, _obj=None): """ @@ -179,34 +221,6 @@ class LibNameIdentifierMappingRequest(Node): lassomod.lib_name_identifier_mapping_request_set_consent(self, consent) -class SamlAssertion(Node): - def __init__(self, _obj=None): - """ - """ - if _obj != None: - self._o = _obj - return - _obj = lassomod.saml_assertion_new() - if _obj is None: raise Error('lasso_saml_assertion_new() failed') - Node.__init__(self, _obj=_obj) - - def add_authenticationStatement(self, authenticationStatement): - lassomod.saml_assertion_add_authenticationStatement(self, - authenticationStatement) - - -class SamlAuthenticationStatement(Node): - def __init__(self, _obj=None): - """ - """ - if _obj != None: - self._o = _obj - return - _obj = lassomod.saml_authentication_statement_new() - if _obj is None: raise Error('lasso_saml_authentication_statement_new() failed') - Node.__init__(self, _obj=_obj) - - class SamlNameIdentifier(Node): def __init__(self, _obj=None): """ @@ -254,16 +268,22 @@ class AuthnRequest(LibAuthnRequest): class AuthnResponse(Node): - def __init__(self, query, providerID, _obj=None): + def __init__(self, _obj): """ """ - if _obj != None: - self._o = _obj - return - _obj = lassomod.authn_response_new(query, providerID) - if _obj is None: raise Error('lasso_authn_response_new() failed') + self._o = _obj Node.__init__(self, _obj=_obj) + def new_from_dump(cls, buffer): + obj = lassomod.authn_response_new_from_dump(buffer) + return AuthnResponse(obj) + new_from_dump = classmethod(new_from_dump) + + def new_from_request_query(cls, query, providerID): + obj = lassomod.authn_response_new_from_request_query(query, providerID) + return AuthnResponse(obj) + new_from_request_query = classmethod(new_from_request_query) + def __isprivate(self, name): return name == '_o' @@ -461,7 +481,6 @@ class Assertion(SamlAssertion): class AuthenticationStatement(Node): def __init__(self, authenticationMethod, - sessionIndex, reauthenticateOnOrAfter, nameIdentifier, nameQualifier, @@ -469,7 +488,6 @@ class AuthenticationStatement(Node): idp_nameIdentifier, idp_nameQualifier, idp_format, - confirmationMethod, _obj=None): """ """ @@ -477,15 +495,13 @@ class AuthenticationStatement(Node): self._o = _obj return _obj = lassomod.authentication_statement_new(authenticationMethod, - sessionIndex, reauthenticateOnOrAfter, nameIdentifier, nameQualifier, format, idp_nameIdentifier, idp_nameQualifier, - idp_format, - confirmationMethod) + idp_format) if _obj is None: raise Error('lasso_authentication_statement_new() failed') Node.__init__(self, _obj=_obj) diff --git a/python/lasso_strings.py b/python/lasso_strings.py index d3498757..24c63fbb 100644 --- a/python/lasso_strings.py +++ b/python/lasso_strings.py @@ -128,3 +128,16 @@ samlAuthenticationMethodXkms = "urn:oasis:names:tc:SAML:1.0:am:XKMS" samlAuthenticationMethodXmlSign = "urn:ietf:rfc:3075" samlAuthenticationMethodUnspecified = "urn:oasis:names:tc:SAML:1.0:am:unspecified" +# * ConfirmationMethods */ +samlConfirmationMethodArtifact01 = "urn:oasis:names:tc:SAML:1.0:cm:artifact-01" +samlConfirmationMethodBearer = "urn:oasis:names:tc:SAML:1.1:cm:bearer" +samlConfirmationMethodHolderOfKey = "urn:oasis:names:tc:SAML:1.0:cm:holder-of-key" +samlConfirmationMethodSenderVouches = "urn:oasis:names:tc:SAML:1.0:cm:sender-vouches" + +# *****************************************************************************/ +# * SOAP */ +# *****************************************************************************/ + +# * prefix & href */ +soapEnvHRef = "http://schemas.xmlsoap.org/soap/envelope/" +soapEnvPrefix = "soap-env" diff --git a/python/lassomod.c b/python/lassomod.c index 62c628d1..b780b0ec 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -27,6 +27,7 @@ #include "py_lasso.h" #include "xml/py_xml.h" +#include "xml/py_lib_authentication_statement.h" #include "xml/py_lib_authn_request.h" #include "xml/py_lib_federation_termination_notification.h" #include "xml/py_lib_logout_request.h" @@ -68,6 +69,10 @@ static PyMethodDef lasso_methods[] = { {"node_soap_envelop", node_soap_envelop, METH_VARARGS}, {"node_verify_signature", node_verify_signature, METH_VARARGS}, + /* py_lib_authentication_statement.h */ + {"lib_authentication_statement_new", lib_authentication_statement_new, METH_VARARGS}, + {"lib_authentication_statement_set_sessionIndex", lib_authentication_statement_set_sessionIndex, METH_VARARGS}, + /* py_lib_authn_request.h */ {"lib_authn_request_new", lib_authn_request_new, METH_VARARGS}, {"lib_authn_request_set_forceAuthn", lib_authn_request_set_forceAuthn, METH_VARARGS}, @@ -119,7 +124,8 @@ static PyMethodDef lasso_methods[] = { /* py_authn_response.h */ {"authn_response_getattr", authn_response_getattr, METH_VARARGS}, - {"authn_response_new", authn_response_new, METH_VARARGS}, + {"authn_response_new_from_dump", authn_response_new_from_dump, METH_VARARGS}, + {"authn_response_new_from_request_query", authn_response_new_from_request_query, METH_VARARGS}, {"authn_response_add_assertion", authn_response_add_assertion, METH_VARARGS}, {"authn_response_must_authenticate", authn_response_must_authenticate, METH_VARARGS}, {"authn_response_process_authentication_result", authn_response_process_authentication_result, METH_VARARGS}, diff --git a/python/protocols/elements/py_authentication_statement.c b/python/protocols/elements/py_authentication_statement.c index 16ed4e13..acef02dc 100644 --- a/python/protocols/elements/py_authentication_statement.c +++ b/python/protocols/elements/py_authentication_statement.c @@ -43,7 +43,6 @@ PyObject *LassoAuthenticationStatement_wrap(LassoAuthenticationStatement *statem PyObject *authentication_statement_new(PyObject *self, PyObject *args) { const xmlChar *authenticationMethod; - const xmlChar *sessionIndex; const xmlChar *reauthenticateOnOrAfter; xmlChar *nameIdentifier; const xmlChar *nameQualifier; @@ -51,27 +50,22 @@ PyObject *authentication_statement_new(PyObject *self, PyObject *args) { xmlChar *idp_nameIdentifier; const xmlChar *idp_nameQualifier; const xmlChar *idp_format; - const xmlChar *confirmationMethod; LassoNode *statement; - if(!PyArg_ParseTuple(args, (char *) "ssssssssss:authentication_statement_new", - &authenticationMethod, &sessionIndex, - &reauthenticateOnOrAfter, + if(!PyArg_ParseTuple(args, (char *) "ssssssss:authentication_statement_new", + &authenticationMethod, &reauthenticateOnOrAfter, &nameIdentifier, &nameQualifier, &format, - &idp_nameIdentifier, &idp_nameQualifier, &idp_format, - &confirmationMethod)) + &idp_nameIdentifier, &idp_nameQualifier, &idp_format)) return NULL; statement = lasso_authentication_statement_new(authenticationMethod, - sessionIndex, reauthenticateOnOrAfter, nameIdentifier, nameQualifier, format, idp_nameIdentifier, idp_nameQualifier, - idp_format, - confirmationMethod); + idp_format); return (LassoAuthenticationStatement_wrap(LASSO_AUTHENTICATION_STATEMENT(statement))); } diff --git a/python/protocols/py_authn_response.c b/python/protocols/py_authn_response.c index 69cf9653..b8f70c76 100644 --- a/python/protocols/py_authn_response.c +++ b/python/protocols/py_authn_response.c @@ -61,8 +61,6 @@ PyObject *authn_response_getattr(PyObject *self, PyObject *args) { if (!strcmp(attr, "__members__")) return Py_BuildValue("[ss]", "requestID", "query"); - if (!strcmp(attr, "requestID")) - return (xmlCharPtr_wrap(reponse->requestID)); if (!strcmp(attr, "query")) return (xmlCharPtr_wrap(reponse->query)); @@ -72,19 +70,35 @@ PyObject *authn_response_getattr(PyObject *self, PyObject *args) { /******************************************************************************/ -PyObject *authn_response_new(PyObject *self, PyObject *args) { - xmlChar *query; - const xmlChar *providerID; +PyObject *authn_response_new_from_dump(PyObject *self, PyObject *args) { + xmlChar *buffer; + LassoNode *response; + + if (CheckArgs(args, "S:authn_response_new_from_dump")) { + if(!PyArg_ParseTuple(args, (char *) "s:authn_response_new_from_dump", + &buffer)) + return NULL; + } + else return NULL; + + response = lasso_authn_response_new_from_dump(buffer); + + return (LassoAuthnResponse_wrap(LASSO_AUTHN_RESPONSE(response))); +} + +PyObject *authn_response_new_from_request_query(PyObject *self, PyObject *args) { + xmlChar *query = NULL; + const xmlChar *providerID = NULL; LassoNode *response; - if (CheckArgs(args, "SS:authn_response_new")) { - if(!PyArg_ParseTuple(args, (char *) "ss:authn_response_new", &query, - &providerID)) + if (CheckArgs(args, "ss:authn_response_new_from_request_query")) { + if(!PyArg_ParseTuple(args, (char *) "zz:authn_response_new_from_request_query", + &query, &providerID)) return NULL; } else return NULL; - response = lasso_authn_response_new(query, providerID); + response = lasso_authn_response_new_from_request_query(query, providerID); return (LassoAuthnResponse_wrap(LASSO_AUTHN_RESPONSE(response))); } diff --git a/python/protocols/py_authn_response.h b/python/protocols/py_authn_response.h index fe85e839..79e3f20b 100644 --- a/python/protocols/py_authn_response.h +++ b/python/protocols/py_authn_response.h @@ -38,7 +38,8 @@ typedef struct { PyObject *LassoAuthnResponse_wrap(LassoAuthnResponse *response); PyObject *authn_response_getattr(PyObject *self, PyObject *args); -PyObject *authn_response_new(PyObject *self, PyObject *args); +PyObject *authn_response_new_from_dump(PyObject *self, PyObject *args); +PyObject *authn_response_new_from_request_query(PyObject *self, PyObject *args); PyObject *authn_response_add_assertion(PyObject *self, PyObject *args); PyObject *authn_response_must_authenticate(PyObject *self, PyObject *args); PyObject *authn_response_process_authentication_result(PyObject *self, PyObject *args); diff --git a/python/setup.py b/python/setup.py index dc1dfc95..a94d5190 100755 --- a/python/setup.py +++ b/python/setup.py @@ -189,6 +189,7 @@ libraries.append('lasso') em = Extension("lassomod", sources = ["py_lasso.c", "xml/py_xml.c", + "xml/py_lib_authentication_statement.c", "xml/py_lib_authn_request.c", "xml/py_lib_federation_termination_notification.c", "xml/py_lib_logout_request.c", |
