summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-08-01 14:07:24 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-08-01 14:07:24 +0000
commit376dcdd7240ece140ef3c7d2aac3b38c547686e5 (patch)
treef4cac01f663403a7a9f1988e60419df8e3bf4fcd
parent540f540e8c5692c32eef22677c16cd38d702ab55 (diff)
add new method lasso_wsf_profile_set_description_from_offering
-rw-r--r--lasso/id-wsf/wsf_profile.c43
-rw-r--r--lasso/id-wsf/wsf_profile.h5
2 files changed, 47 insertions, 1 deletions
diff --git a/lasso/id-wsf/wsf_profile.c b/lasso/id-wsf/wsf_profile.c
index f20850f8..aa150532 100644
--- a/lasso/id-wsf/wsf_profile.c
+++ b/lasso/id-wsf/wsf_profile.c
@@ -34,7 +34,7 @@
#include <lasso/id-wsf/wsf_profile.h>
#include <lasso/id-wsf/wsf_profile_private.h>
-
+#include <lasso/id-wsf/discovery.h>
#include <lasso/xml/disco_modify.h>
#include <lasso/xml/soap_fault.h>
#include <lasso/xml/soap_binding_correlation.h>
@@ -220,6 +220,47 @@ lasso_security_mech_id_is_saml_authentication(const gchar *security_mech_id)
return FALSE;
}
+/**
+ * lasso_wsf_profile_set_description_from_offering_with_sec_mech:
+ * @profile: a #LassoWsfProfile
+ * @offering: a #LassoDiscoResourceOffering containing descriptions
+ * @security_mech_id: an URL representing the wished security mechanism, if NULL take the first descriptions
+ *
+ * Setup the LassoWsfProfile for a given security mechanism.
+ *
+ * Returns: 0 if a corresponding description was found,
+ * LASSO_PROFILE_ERROR_MISSING_SERVICE_DESCRIPTION if no description with the
+ * given security mechanism was found.
+ */
+gint
+lasso_wsf_profile_set_description_from_offering(
+ LassoWsfProfile *profile,
+ LassoDiscoResourceOffering *offering,
+ const gchar *security_mech_id)
+{
+ LassoDiscoDescription *description = NULL;
+
+ g_return_val_if_invalid_param(WSF_PROFILE, profile,
+ LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
+ g_return_val_if_invalid_param(DISCO_RESOURCE_OFFERING, offering,
+ LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
+ if (security_mech_id == NULL) {
+ if (offering->ServiceInstance &&
+ offering->ServiceInstance->Description) {
+ description = LASSO_DISCO_DESCRIPTION(
+ offering->ServiceInstance->Description->data);
+ }
+ } else {
+ description = lasso_discovery_get_description_auto(
+ offering, security_mech_id);
+ }
+ if (description == NULL) {
+ return LASSO_PROFILE_ERROR_MISSING_SERVICE_DESCRIPTION;
+ }
+ lasso_wsf_profile_set_description(profile, description);
+ return 0;
+}
+
void
lasso_wsf_profile_set_description(LassoWsfProfile *profile, LassoDiscoDescription *description)
{
diff --git a/lasso/id-wsf/wsf_profile.h b/lasso/id-wsf/wsf_profile.h
index dd4ae0f9..956a4190 100644
--- a/lasso/id-wsf/wsf_profile.h
+++ b/lasso/id-wsf/wsf_profile.h
@@ -37,6 +37,7 @@ extern "C" {
#include <lasso/xml/soap_binding_provider.h>
#include <lasso/xml/saml_assertion.h>
#include <lasso/xml/disco_description.h>
+#include <lasso/xml/disco_resource_offering.h>
#define LASSO_TYPE_WSF_PROFILE (lasso_wsf_profile_get_type())
#define LASSO_WSF_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
@@ -118,6 +119,10 @@ LASSO_EXPORT gboolean lasso_wsf_profile_principal_is_online(LassoWsfProfile *pro
LASSO_EXPORT gint lasso_wsf_profile_add_credential(LassoWsfProfile *profile, xmlNode *credential);
+LASSO_EXPORT gint lasso_wsf_profile_set_description_from_offering(
+ LassoWsfProfile *profile,
+ LassoDiscoResourceOffering *offering,
+ const char *security_mech_id);
LASSO_EXPORT void lasso_wsf_profile_set_description(LassoWsfProfile *profile,
LassoDiscoDescription *description);
LASSO_EXPORT void lasso_wsf_profile_set_principal_status(LassoWsfProfile *profile,