From 4544ea9e9d5dc81c856e0f0d3a090882149fe912 Mon Sep 17 00:00:00 2001 From: John Dennis Date: Thu, 28 May 2015 12:42:52 -0400 Subject: [PATCH] Add function to set protocol conformance Lasso uses an internal private variable bound to the provider to indicate which protocol the provider is servicing. It is vital this value be correctly set because many Lasso routines used it to dispatch to the appropriate protocol handlers. Normally the provider's protocol conformance is set as a side-effect of parsing the XML metadata that describes the provider (e.g. an SP or IdP). However there are some providers (e.g. an ECP client) which do not have metadata. For providers lacking metadata it is essential there be a mechanism to set the protocol conformance otherwise the library will malfunction. The function comes with documentation that includes a clear warning this is to be used only in limited circumstances. Signed-off-by: John Dennis License: MIT --- docs/reference/lasso/lasso-sections.txt | 1 + lasso/id-ff/provider.c | 26 +++++++++++++++++++++++++ lasso/id-ff/provider.h | 3 +++ 3 files changed, 30 insertions(+) diff --git a/docs/reference/lasso/lasso-sections.txt b/docs/reference/lasso/lasso-sections.txt index 4d822505..1d54a4e9 100644 --- a/docs/reference/lasso/lasso-sections.txt +++ b/docs/reference/lasso/lasso-sections.txt @@ -169,6 +169,7 @@ lasso_provider_get_metadata_list_for_role lasso_provider_get_metadata_keys_for_role lasso_provider_get_roles lasso_provider_match_conformance +lasso_provider_set_protocol_conformance LASSO_PROVIDER LASSO_IS_PROVIDER diff --git a/lasso/id-ff/provider.c b/lasso/id-ff/provider.c index 5344cf39..2a27baa6 100644 --- a/lasso/id-ff/provider.c +++ b/lasso/id-ff/provider.c @@ -969,6 +969,32 @@ lasso_provider_get_protocol_conformance(const LassoProvider *provider) return provider->private_data->conformance; } +/** + * lasso_provider_set_protocol_conformance: + * @provider: a #LassoProvider object + * @protocol_conformance: #LassoProtocolConformance enumerated value. + * + * Normally the protocol conformance is set when the metadata for the + * provider is loaded because the metadata defines the type of + * server. However some #LassoServer variants do not have metadata + * (e.g. ECP) therefore instead of loading the metadata it is + * necessary to explicitly set the protocol conformance because parts + * of the Lasso library dispatch based on the protocol conformance. + * Without the protocol conformance being set it is likely the wrong + * code will execute. + * + * **WARNING**, do not manually set the protocol conformance if + * metadata has been loaded, metadata is the final arbiter of protocol + * conformance. + * + * Return value: 0 on success; another value if an error occured. + **/ +void +lasso_provider_set_protocol_conformance(LassoProvider *provider, LassoProtocolConformance protocol_conformance) +{ + provider->private_data->conformance = protocol_conformance; +} + gboolean _lasso_provider_load_metadata_from_buffer(LassoProvider *provider, const gchar *metadata, int length) { diff --git a/lasso/id-ff/provider.h b/lasso/id-ff/provider.h index 1da17591..5421f3c7 100644 --- a/lasso/id-ff/provider.h +++ b/lasso/id-ff/provider.h @@ -236,6 +236,9 @@ LASSO_EXPORT xmlNode* lasso_provider_get_organization(const LassoProvider *provi LASSO_EXPORT LassoProtocolConformance lasso_provider_get_protocol_conformance( const LassoProvider *provider); +LASSO_EXPORT void lasso_provider_set_protocol_conformance(LassoProvider *provider, + LassoProtocolConformance protocol_conformance); + LASSO_EXPORT void lasso_provider_set_encryption_mode(LassoProvider *provider, LassoEncryptionMode encryption_mode);