Server utility returns list of providers supporting endpoint type

Add lasso_server_get_filtered_provider_list() utility.

Iterate over the server providers and build a list of provider EntityID's who
have the specified role and at least one endpoint matching the
protocol_type and http_method. Return a GList list of EntityID's

Signed-off-by: John Dennis <jdennis@redhat.com>
License: MIT
This commit is contained in:
John Dennis 2015-05-28 09:35:28 -04:00 committed by Benjamin Dauvergne
parent 237b7424bd
commit 6102c73fd7
3 changed files with 62 additions and 0 deletions

View File

@ -21,6 +21,7 @@ lasso_server_set_encryption_private_key
lasso_server_set_encryption_private_key_with_password
lasso_server_load_affiliation
lasso_server_get_endpoint_url_by_id
lasso_server_get_filtered_provider_list
lasso_server_saml2_assertion_setup_signature
<SUBSECTION Standard>
LASSO_SERVER

View File

@ -558,6 +558,63 @@ lasso_server_get_providerID_from_hash(LassoServer *server, gchar *b64_hash)
return NULL;
}
typedef struct {
GList *provider_list;
LassoProvider *provider;
LassoProviderRole role;
LassoMdProtocolType protocol_type;
LassoHttpMethod http_method;
} FilteredProviderListContext;
static void
filter_provider_list(G_GNUC_UNUSED gpointer key, gpointer value, gpointer user_data)
{
LassoProvider *remote_provider = (LassoProvider*)value;
FilteredProviderListContext *context = (FilteredProviderListContext*)user_data;
if (remote_provider->role == context->role) {
if (lasso_provider_accept_http_method(context->provider, remote_provider,
context->protocol_type, context->http_method, FALSE)) {
lasso_list_add_string(context->provider_list, remote_provider->ProviderID);
}
}
}
/**
* lasso_server_get_filtered_provider_list
* @server: a #LassoServer
* @role: each returned provider will match this #LassoProviderRole
* @protocol_type: provider must have endpoint matching #LassoMdProtocolType and @http_method
* @http_method: provider must have endpoint matching #LassoHttpMethod and @protocol_type
*
* Iterate over the @server providers and build a list of provider EntityID's who
* have the specified @role and at least one endpoint matching the
* @protocol_type and @http_method. Return a #GList list of EntityID's at the
* @provider_list pointer. The caller is responsible for freeing the @provider_list
* by calling lasso_release_list_of_strings().
*
* Return value:(transfer full)(element-type string): #GList of matching provider EntityID's returned here.
*/
GList *
lasso_server_get_filtered_provider_list(const LassoServer *server, LassoProviderRole role,
LassoMdProtocolType protocol_type,
LassoHttpMethod http_method)
{
FilteredProviderListContext context;
context.provider_list = NULL;
context.provider = LASSO_PROVIDER(server);
context.role = role;
context.protocol_type = protocol_type;
context.http_method = http_method;
g_hash_table_foreach(server->providers,
filter_provider_list, &context);
return context.provider_list;
}
/*****************************************************************************/
/* overridden parent class methods */
/*****************************************************************************/

View File

@ -130,6 +130,10 @@ LASSO_EXPORT lasso_error_t lasso_server_add_provider2(LassoServer *server, Lasso
LASSO_EXPORT gchar *lasso_server_get_endpoint_url_by_id(const LassoServer *server,
const gchar *provider_id, const gchar *endpoint_description);
LASSO_EXPORT GList *lasso_server_get_filtered_provider_list(const LassoServer *server,
LassoProviderRole role, LassoMdProtocolType protocol_type, LassoHttpMethod http_method);
#ifdef __cplusplus
}
#endif /* __cplusplus */