summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lasso/Attic/protocols/federation_termination_notification.c1
-rw-r--r--lasso/id-ff/profile_context.c57
-rw-r--r--lasso/id-ff/profile_context.h28
-rw-r--r--python/examples/defederation.py2
-rw-r--r--python/lasso.py14
-rw-r--r--python/lassomod.c2
-rwxr-xr-xpython/setup.py1
7 files changed, 87 insertions, 18 deletions
diff --git a/lasso/Attic/protocols/federation_termination_notification.c b/lasso/Attic/protocols/federation_termination_notification.c
index afa6b17c..eeb4a82c 100644
--- a/lasso/Attic/protocols/federation_termination_notification.c
+++ b/lasso/Attic/protocols/federation_termination_notification.c
@@ -198,6 +198,7 @@ lasso_federation_termination_notification_new_from_export(const xmlChar *b
notification = lasso_federation_termination_notification_new_from_soap(buffer);
break;
default:
+ return(NULL);
}
return(notification);
diff --git a/lasso/id-ff/profile_context.c b/lasso/id-ff/profile_context.c
index ef701bac..0b325cf5 100644
--- a/lasso/id-ff/profile_context.c
+++ b/lasso/id-ff/profile_context.c
@@ -36,9 +36,64 @@ struct _LassoProfileContextPrivate
static GObjectClass *parent_class = NULL;
/*****************************************************************************/
-/* functions */
+/* public functions */
/*****************************************************************************/
+gint
+lasso_profile_context_get_request_type_from_soap_msg(gchar *soap)
+{
+ LassoNode *soap_node, *body_node, *request_node;
+ GPtrArray *children;
+ xmlChar * name;
+ int type;
+ int i;
+
+ soap_node = lasso_node_new_from_dump(soap);
+ if(soap_node==NULL){
+ debug(ERROR, "Error while build node from soap msg\n");
+ return(-1);
+ }
+
+ body_node = lasso_node_get_child(soap_node, "Body", NULL);
+ if(body_node==NULL){
+ debug(ERROR, "Body node not found\n");
+ return(-2);
+ }
+
+ children = lasso_node_get_children(body_node);
+ if(children->len>0){
+ request_node = g_ptr_array_index(children, 0);
+ name = lasso_node_get_name(request_node);
+
+ if(xmlStrEqual(name, "Request")){
+ debug(INFO, "A Request node found\n");
+ type = lassoRequestTypeLogin;
+ }
+ else if(xmlStrEqual(name, "LogoutRequest")){
+ type = lassoRequestTypeLogout;
+ debug(INFO, "A LogoutRequest node found\n");
+ }
+ else if(xmlStrEqual(name, "FederationTerminationNotification")){
+ type = lassoRequestTypeFederationTermination;
+ debug(INFO, "A FederationTerminationNotification node found\n");
+ }
+ else if(xmlStrEqual(name, "RegisterNameIdentifierRequest")){
+ type = lassoRequestTypeRegisterNameIdentifier;
+ debug(INFO, "A RegisterNameIdentifierRequest node found\n");
+ }
+ else if(xmlStrEqual(name, "NameIdentifierMappingRequest")){
+ type = lassoRequestTypeNameIdentifierMapping;
+ debug(INFO, "A NameIdentifierMappingRequest node found\n");
+ }
+ else{
+ debug(ERROR, "Unkown node name : %s\n", name);
+ }
+ }
+
+ return(type);
+}
+
+
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
diff --git a/lasso/id-ff/profile_context.h b/lasso/id-ff/profile_context.h
index 6b5bf5e9..5f9e2570 100644
--- a/lasso/id-ff/profile_context.h
+++ b/lasso/id-ff/profile_context.h
@@ -50,6 +50,14 @@ typedef struct _LassoProfileContextClass LassoProfileContextClass;
typedef struct _LassoProfileContextPrivate LassoProfileContextPrivate;
typedef enum {
+ lassoRequestTypeLogin = 1,
+ lassoRequestTypeLogout,
+ lassoRequestTypeFederationTermination,
+ lassoRequestTypeRegisterNameIdentifier,
+ lassoRequestTypeNameIdentifierMapping,
+}lassoRequestTypes;
+
+typedef enum {
lassoHttpMethodGet = 1,
lassoHttpMethodPost,
lassoHttpMethodRedirect,
@@ -98,19 +106,21 @@ struct _LassoProfileContextClass {
GObjectClass parent;
};
-LASSO_EXPORT GType lasso_profile_context_get_type (void);
+LASSO_EXPORT GType lasso_profile_context_get_type (void);
+
+LASSO_EXPORT LassoProfileContext* lasso_profile_context_new (LassoServer *server,
+ LassoUser *user);
-LASSO_EXPORT LassoProfileContext* lasso_profile_context_new (LassoServer *server,
- LassoUser *user);
+LASSO_EXPORT gint lasso_profile_context_get_request_type_from_soap_msg (gchar *soap);
-LASSO_EXPORT gchar* lasso_profile_context_dump (LassoProfileContext *ctx,
- const gchar *name);
+LASSO_EXPORT gchar* lasso_profile_context_dump (LassoProfileContext *ctx,
+ const gchar *name);
-LASSO_EXPORT gint lasso_profile_context_set_remote_providerID(LassoProfileContext *ctx,
- gchar *providerID);
+LASSO_EXPORT gint lasso_profile_context_set_remote_providerID (LassoProfileContext *ctx,
+ gchar *providerID);
-LASSO_EXPORT void lasso_profile_context_set_response_status (LassoProfileContext *ctx,
- const gchar *statusCodeValue);
+LASSO_EXPORT void lasso_profile_context_set_response_status (LassoProfileContext *ctx,
+ const gchar *statusCodeValue);
#ifdef __cplusplus
}
diff --git a/python/examples/defederation.py b/python/examples/defederation.py
index a07c2331..7847c97e 100644
--- a/python/examples/defederation.py
+++ b/python/examples/defederation.py
@@ -33,6 +33,8 @@ spdefederation.build_notification_msg()
print 'url : ', spdefederation.msg_url
print 'body : ', spdefederation.msg_body
+print lasso.get_request_type_from_soap_msg(spdefederation.msg_body)
+
# idp federation termination :
print "---------------------------------------------------------"
diff --git a/python/lasso.py b/python/lasso.py
index 71e170f8..43fb3a29 100644
--- a/python/lasso.py
+++ b/python/lasso.py
@@ -47,6 +47,9 @@ def shutdown():
"""
return lassomod.shutdown()
+def get_request_type_from_soap_msg(soap_buffer):
+ return lassomod.profile_context_get_request_type_from_soap_msg(soap_buffer);
+
################################################################################
# xml : low level classes
################################################################################
@@ -1036,10 +1039,9 @@ class FederationTermination:
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)
+ if ret:
+ if name=="user":
+ ret = User(_obj=ret)
return ret
def new(cls, server, user, provider_type):
@@ -1084,10 +1086,6 @@ class RegisterNameIdentifier:
if name[:2] == "__" and name[-2:] == "__" and name != "__members__":
raise AttributeError, name
ret = lassomod.register_name_identifier_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):
diff --git a/python/lassomod.c b/python/lassomod.c
index 9135b060..1e34c17c 100644
--- a/python/lassomod.c
+++ b/python/lassomod.c
@@ -56,6 +56,7 @@
#include "environs/py_federation_termination.h"
#include "environs/py_login.h"
#include "environs/py_logout.h"
+#include "environs/py_profile_context.h"
#include "environs/py_register_name_identifier.h"
#include "environs/py_server.h"
#include "environs/py_user.h"
@@ -198,6 +199,7 @@ static PyMethodDef lasso_methods[] = {
{"authentication_statement_new", authentication_statement_new, METH_VARARGS},
/* environs */
+ {"profile_context_get_request_type_from_soap_msg", profile_context_get_request_type_from_soap_msg, METH_VARARGS},
/* py_federation_termination.h */
{"federation_termination_getattr", federation_termination_getattr, METH_VARARGS},
diff --git a/python/setup.py b/python/setup.py
index fc2b0269..9799c610 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -219,6 +219,7 @@ em = Extension("lassomod",
"environs/py_federation_termination.c",
"environs/py_login.c",
"environs/py_logout.c",
+ "environs/py_profile_context.c",
"environs/py_register_name_identifier.c",
"environs/py_server.c",
"environs/py_user.c",