diff options
author | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-19 12:25:35 +0000 |
---|---|---|
committer | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-19 12:25:35 +0000 |
commit | 8c0b0cb66780eb70c8f2cc0331bdaf4f78c8fc48 (patch) | |
tree | bf46ad727891d3a9126fa679a1680b2c75df2f30 | |
parent | 6585a27baffa20d757d1d93cf11264cb593a6910 (diff) | |
download | lasso-8c0b0cb66780eb70c8f2cc0331bdaf4f78c8fc48.tar.gz lasso-8c0b0cb66780eb70c8f2cc0331bdaf4f78c8fc48.tar.xz lasso-8c0b0cb66780eb70c8f2cc0331bdaf4f78c8fc48.zip |
update federation termination
-rw-r--r-- | lasso/Attic/protocols/provider.c | 10 | ||||
-rw-r--r-- | lasso/Attic/protocols/provider.h | 2 | ||||
-rw-r--r-- | lasso/id-ff/federation_termination.c | 11 | ||||
-rw-r--r-- | python/environs/py_federation_termination.c | 30 | ||||
-rw-r--r-- | python/environs/py_federation_termination.h | 4 | ||||
-rw-r--r-- | python/examples/defederation.py | 45 | ||||
-rw-r--r-- | python/lasso.py | 60 | ||||
-rw-r--r-- | python/lassomod.c | 4 |
8 files changed, 145 insertions, 21 deletions
diff --git a/lasso/Attic/protocols/provider.c b/lasso/Attic/protocols/provider.c index 18bbe7a2..79a81e1f 100644 --- a/lasso/Attic/protocols/provider.c +++ b/lasso/Attic/protocols/provider.c @@ -75,9 +75,15 @@ lasso_provider_get_federationTerminationNotificationProtocolProfile(LassoProvide } gchar * -lasso_provider_get_federationTerminationNotificationServiceURL(LassoProvider *provider) +lasso_provider_get_federationTerminationReturnServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "FederationTerminationNotificationServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "FederationTerminationReturnServiceURL", NULL)); +} + +gchar * +lasso_provider_get_federationTerminationServiceURL(LassoProvider *provider) +{ + return(lasso_node_get_child_content(provider->metadata, "FederationTerminationServiceURL", NULL)); } gchar * diff --git a/lasso/Attic/protocols/provider.h b/lasso/Attic/protocols/provider.h index b4c00ab7..fd769fdc 100644 --- a/lasso/Attic/protocols/provider.h +++ b/lasso/Attic/protocols/provider.h @@ -76,6 +76,8 @@ LASSO_EXPORT gchar *lasso_provider_get_assertionConsumerServiceURL LASSO_EXPORT gchar *lasso_provider_get_federationTerminationNotificationProtocolProfile (LassoProvider *provider); +LASSO_EXPORT gchar *lasso_provider_get_federationTerminationReturnServiceURL (LassoProvider *provider); + LASSO_EXPORT gchar *lasso_provider_get_federationTerminationNotificationServiceURL (LassoProvider *provider); LASSO_EXPORT gchar *lasso_provider_dump (LassoProvider *provider); diff --git a/lasso/id-ff/federation_termination.c b/lasso/id-ff/federation_termination.c index 47e00af6..d120784b 100644 --- a/lasso/id-ff/federation_termination.c +++ b/lasso/id-ff/federation_termination.c @@ -56,7 +56,11 @@ lasso_federation_termination_build_notification_msg(LassoFederationTermination * if(xmlStrEqual(protocolProfile, lassoLibProtocolProfileSloSpSoap) || xmlStrEqual(protocolProfile, lassoLibProtocolProfileSloIdpSoap)){ debug(DEBUG, "Building a federation termination soap message\n"); profileContext->request_type = lassoHttpMethodSoap; - profileContext->msg_url = lasso_provider_get_federationTerminationNotificationServiceURL(provider); + profileContext->msg_url = lasso_provider_get_federationTerminationServiceURL(provider); + if(profileContext->msg_url==NULL){ + debug(ERROR, "Federation Termination Notification url not found\n"); + return(-4); + } profileContext->msg_body = lasso_node_export_to_soap(profileContext->request); } else if(xmlStrEqual(protocolProfile,lassoLibProtocolProfileSloSpHttp)||xmlStrEqual(protocolProfile,lassoLibProtocolProfileSloIdpHttp)){ @@ -69,9 +73,12 @@ lasso_federation_termination_build_notification_msg(LassoFederationTermination * } else{ debug(ERROR, "Unknown protocol profile\n"); - return(-4); + return(-5); } + debug(INFO, "notification url : %s\n", profileContext->msg_url); + debug(INFO, "notification body : %s\n", profileContext->msg_body); + return(0); } diff --git a/python/environs/py_federation_termination.c b/python/environs/py_federation_termination.c index a9e9718d..6f6d0902 100644 --- a/python/environs/py_federation_termination.c +++ b/python/environs/py_federation_termination.c @@ -42,6 +42,36 @@ PyObject *LassoFederationTermination_wrap(LassoFederationTermination *federation /******************************************************************************/ +PyObject *federation_termination_getattr(PyObject *self, PyObject *args) { + PyObject *federation_termination_obj; + LassoFederationTermination *federation_termination; + const char *attr; + + if (CheckArgs(args, "OS:federation_termination_get_attr")) { + if (!PyArg_ParseTuple(args, "Os:federation_termination_get_attr", &federation_termination_obj, &attr)) + return NULL; + } + else return NULL; + + federation_termination = LassoFederationTermination_get(federation_termination_obj); + + if (!strcmp(attr, "__members__")) + return Py_BuildValue("[ssss]", "user", "msg_url", "msg_body", + "msg_relayState"); + + if (!strcmp(attr, "user")) + return (LassoUser_wrap(LASSO_PROFILE_CONTEXT(federation_termination)->user)); + if (!strcmp(attr, "msg_url")) + return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(federation_termination)->msg_url)); + if (!strcmp(attr, "msg_body")) + return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(federation_termination)->msg_body)); + if (!strcmp(attr, "msg_relayState")) + return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(federation_termination)->msg_relayState)); + + Py_INCREF(Py_None); + return (Py_None); +} + PyObject *federation_termination_new(PyObject *self, PyObject *args) { PyObject *server_obj, *user_obj; LassoFederationTermination *federation_termination; diff --git a/python/environs/py_federation_termination.h b/python/environs/py_federation_termination.h index cc1ebefb..c68547aa 100644 --- a/python/environs/py_federation_termination.h +++ b/python/environs/py_federation_termination.h @@ -39,10 +39,12 @@ typedef struct { #define LassoFederationTermination_get(v) (((v) == Py_None) ? NULL : (((LassoFederationTermination_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj)) PyObject *LassoFederationTermination_wrap(LassoFederationTermination *federation_termination); -PyObject *federation_termination_new(PyObject *self, PyObject *args); +PyObject *federation_termination_getattr(PyObject *self, PyObject *args); + PyObject *federation_termination_build_notification_msg(PyObject *self, PyObject *args); PyObject *federation_termination_destroy(PyObject *self, PyObject *args); PyObject *federation_termination_init_notification(PyObject *self, PyObject *args); +PyObject *federation_termination_new(PyObject *self, PyObject *args); PyObject *federation_termination_process_notification_msg(PyObject *self, PyObject *args); #endif /* __PYLASSO_PY_FEDERATION_TERMINATION_H__ */ diff --git a/python/examples/defederation.py b/python/examples/defederation.py index 82805097..1522945f 100644 --- a/python/examples/defederation.py +++ b/python/examples/defederation.py @@ -6,18 +6,45 @@ import lasso lasso.init() -notification = lasso.FederationTerminationNotification.new("http://providerid.com", - "CDSC7SCD65SCDSDCCDS", "http://qualifier.com", "federated") +# servers : +spserver = lasso.Server.new("../../examples/sp.xml", + "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", + lasso.signatureMethodRsaSha1) -query = notification.url_encode(0, './rsakey.pem') -print query +spserver.add_provider("../../examples/idp.xml", None, None) -notification2 = lasso.FederationTerminationNotification.new_from_query(query) -print notification2.dump() +idpserver = lasso.Server.new("../../examples/idp.xml", + "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", + lasso.signatureMethodRsaSha1) -soap = notification.soap_envelop() +spserver.add_provider("../../examples/sp.xml", None, None) -notification3 = lasso.FederationTerminationNotification.new_from_soap(soap) -print notification3.dump() +# users : +spuser_dump = "<LassoUser><LassoIdentities><LassoIdentity RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><LassoRemoteNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">LLLLLLLLLLLLLLLLLLLLLLLLL</NameIdentifier></LassoRemoteNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" + +spuser = lasso.User.new_from_dump(spuser_dump) + +idpuser_dump = "<LassoUser><LassoIdentities><LassoIdentity RemoteProviderID=\"https://service-provider:2003/liberty-alliance/metadata\"><LassoLocalNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">LLLLLLLLLLLLLLLLLLLLLLLLL</NameIdentifier></LassoLocalNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" + +idpuser = lasso.User.new_from_dump(idpuser_dump) + +# sp federation termination : +spdefederation = lasso.FederationTermination.new(spserver, spuser, lasso.providerTypeSp) +spdefederation.init_notification("https://identity-provider:2003/liberty-alliance/metadata") +spdefederation.build_notification_msg() +print 'url : ', spdefederation.msg_url +print 'body : ', spdefederation.msg_body + +# idp federation termination : +print "---------------------------------------------------------" +print " At identity provider " +idpdefederation = lasso.FederationTermination.new(idpserver, idpuser, lasso.providerTypeIdp) +idpdefederation.process_notification_msg(spdefederation.msg_body, lasso.httpMethodSoap) +#idpdefederation.build_response_msg() +#print 'url : ', idpdefederation.msg_url +#print 'body : ', idpdefederation.msg_body + + +print 'End of federation termination' lasso.shutdown() diff --git a/python/lasso.py b/python/lasso.py index 664a345d..9853fd6a 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -976,22 +976,24 @@ class Logout: def __isprivate(self, name): return name == '_o' + def __init__(self, _obj): + """ + The constructor + """ + self._o = _obj + 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) + ret = lassomod.logout_getattr(self, name) if ret is None: raise AttributeError, name + if name == "user": + ret = User(_obj=ret) return ret - def __init__(self, _obj): - """ - The constructor - """ - self._o = _obj - def new(cls, server, user, provider_type): obj = lassomod.logout_new(server, user, provider_type) return Logout(obj) @@ -1014,3 +1016,47 @@ class Logout: def process_response_msg(self, response_msg, response_method): return lassomod.logout_process_response_msg(self, response_msg, response_method); + +class FederationTermination: + """\brief Short desc + + Long desc + """ + + def __isprivate(self, name): + return name == '_o' + + def __init__(self, _obj): + """ + The constructor + """ + self._o = _obj + + 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.federation_termination_getattr(self, name) + if ret is None: + raise AttributeError, name + if name == "user": + ret = User(_obj=ret) + return ret + + def new(cls, server, user, provider_type): + obj = lassomod.federation_termination_new(server, user, provider_type) + return FederationTermination(obj) + new = classmethod(new) + + def build_notification_msg(self): + return lassomod.federation_termination_build_notification_msg(self) + + def destroy(self): + pass + + def init_notification(self, remote_providerID): + return lassomod.federation_termination_init_notification(self, remote_providerID); + + def process_notification_msg(self, notification_msg, notification_method): + return lassomod.federation_termination_process_notification_msg(self, notification_msg, notification_method); diff --git a/python/lassomod.c b/python/lassomod.c index 8a10fe21..cb0646bd 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -204,6 +204,8 @@ static PyMethodDef lasso_methods[] = { /* environs */ /* py_federation_termination.h */ + {"federation_termination_getattr", federation_termination_getattr, METH_VARARGS}, + {"federation_termination_new", federation_termination_new, METH_VARARGS}, {"federation_termination_build_notification_msg", federation_termination_build_notification_msg, METH_VARARGS}, {"federation_termination_destroy", federation_termination_destroy, METH_VARARGS}, @@ -229,6 +231,8 @@ static PyMethodDef lasso_methods[] = { {"login_process_response_msg", login_process_response_msg, METH_VARARGS}, /* py_logout.h */ + {"logout_getattr", logout_getattr, METH_VARARGS}, + {"logout_new", logout_new, METH_VARARGS}, {"logout_build_request_msg", logout_build_request_msg, METH_VARARGS}, {"logout_build_response_msg", logout_build_response_msg, METH_VARARGS}, |