summaryrefslogtreecommitdiffstats
path: root/lasso/saml-2.0
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2013-09-08 23:39:33 +0200
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2013-09-08 23:39:33 +0200
commitcfdd3daf208b822e8c6c792157b14861251b655e (patch)
treeab49f82f06d7f52903a4c5b273baa540178ae7f1 /lasso/saml-2.0
parent3dc786380a4f93e583798d0fae2de1a7c5218d70 (diff)
downloadlasso-cfdd3daf208b822e8c6c792157b14861251b655e.tar.gz
lasso-cfdd3daf208b822e8c6c792157b14861251b655e.tar.xz
lasso-cfdd3daf208b822e8c6c792157b14861251b655e.zip
saml2/provider.c: add new function lasso_saml20_provider_get_endpoint_url() for retrieving endpoint locations using the new endpoints list
Diffstat (limited to 'lasso/saml-2.0')
-rw-r--r--lasso/saml-2.0/provider.c57
-rw-r--r--lasso/saml-2.0/providerprivate.h3
2 files changed, 60 insertions, 0 deletions
diff --git a/lasso/saml-2.0/provider.c b/lasso/saml-2.0/provider.c
index a34fbee6..8f408b12 100644
--- a/lasso/saml-2.0/provider.c
+++ b/lasso/saml-2.0/provider.c
@@ -780,6 +780,63 @@ lasso_saml20_provider_get_assertion_consumer_service_url_by_binding(LassoProvide
return NULL;
}
+/**
+ * lasso_saml20_provider_get_endpoint_url:
+ * @provider: a #LassoProvider object
+ * @role: the role of the given provider,
+ * @kind: the endpoint kind, ex. AssertionConsumerService
+ * @bindings:(allow-none): a list of string, giving binding to match, if needed,
+ * @is_response: TRUE if the URL will be user for returning a response
+ * @is_default: TRUE if we are looking for the default endpoint
+ * @idx: if >= 0 look for the endpoint with the given index
+ *
+ * Return the best URL for reaching the given endpoint
+ */
+const gchar*
+lasso_saml20_provider_get_endpoint_url(LassoProvider *provider,
+ LassoProviderRole role, const char *kind, GSList *bindings, gboolean is_response,
+ gboolean is_default, int idx)
+{
+ EndpointType* endpoint_type = NULL;
+ GList *t = NULL;
+
+ if (! LASSO_IS_PROVIDER(provider) || !kind)
+ return NULL;
+ lasso_foreach(t, provider->private_data->endpoints) {
+ endpoint_type = (EndpointType*) t->data;
+ if (! endpoint_type)
+ continue;
+ if (! endpoint_type->binding)
+ continue;
+ if (endpoint_type->role != role)
+ continue;
+ if (! lasso_strisequal(endpoint_type->kind, kind))
+ continue;
+ /* endpoints are already properly ordered so that the first matching one is the
+ * default one */
+ if (is_default)
+ break;
+ else if (idx >= 0) {
+ if (endpoint_type->index == idx)
+ break;
+ } else {
+ /* if all else fails return the first matching one or the first matching our
+ * list of bindings */
+ if (!bindings || g_slist_find_custom(bindings, endpoint_type->binding, (GCompareFunc)g_strcmp0))
+ break;
+ }
+ endpoint_type = NULL;
+ }
+
+ if (! endpoint_type)
+ return NULL;
+ if (is_response && endpoint_type->return_url)
+ return endpoint_type->return_url;
+ else
+ return endpoint_type->url;
+}
+
+
lasso_error_t
lasso_saml20_provider_get_artifact_resolution_service_index(LassoProvider *provider, unsigned short *index)
{
diff --git a/lasso/saml-2.0/providerprivate.h b/lasso/saml-2.0/providerprivate.h
index ccc40022..c26375ac 100644
--- a/lasso/saml-2.0/providerprivate.h
+++ b/lasso/saml-2.0/providerprivate.h
@@ -55,6 +55,9 @@ const gchar* lasso_saml20_provider_get_assertion_consumer_service_binding_by_url
LassoProvider *provider, const char *url);
lasso_error_t lasso_saml20_provider_get_artifact_resolution_service_index(LassoProvider *provider,
unsigned short *index);
+const gchar* lasso_saml20_provider_get_endpoint_url(LassoProvider *provider, LassoProviderRole role,
+ const char *kind, GSList *bindings, gboolean is_response, gboolean is_default,
+ int idx);
#ifdef __cplusplus
}
#endif /* __cplusplus */