diff options
author | olavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53> | 2011-05-18 10:48:47 +0000 |
---|---|---|
committer | olavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53> | 2011-05-18 10:48:47 +0000 |
commit | a0ff8fc554f83a58889e8f808d699d8f27cce7e5 (patch) | |
tree | 65bd862f2ae9f37ac70f6ea5a2e90adeb3551880 | |
parent | ea23708cdcaa0d6219a30444bdb470abdab3ae35 (diff) | |
download | mod_auth_mellon-a0ff8fc554f83a58889e8f808d699d8f27cce7e5.tar.gz mod_auth_mellon-a0ff8fc554f83a58889e8f808d699d8f27cce7e5.tar.xz mod_auth_mellon-a0ff8fc554f83a58889e8f808d699d8f27cce7e5.zip |
Move am_get_idp() and am_first_idp() to after am_get_lasso_server().
This is in preparation of using am_get_lasso_server from those functions.
git-svn-id: https://modmellon.googlecode.com/svn/trunk@122 a716ebb1-153a-0410-b759-cfb97c6a1b53
-rw-r--r-- | auth_mellon_handler.c | 170 |
1 files changed, 86 insertions, 84 deletions
diff --git a/auth_mellon_handler.c b/auth_mellon_handler.c index 1ea3a66..84c2d58 100644 --- a/auth_mellon_handler.c +++ b/auth_mellon_handler.c @@ -201,90 +201,6 @@ static char *am_generate_metadata(apr_pool_t *p, request_rec *r) } #endif /* HAVE_lasso_server_new_from_buffers */ -/* This function returns the first configured IdP - * - * Parameters: - * request_rec *r The request we received. - * - * Returns: - * the providerID, or NULL if an error occured - */ -static const char *am_first_idp(request_rec *r) -{ - am_dir_cfg_rec *cfg = am_get_dir_cfg(r); - apr_hash_index_t *index; - const char *provider_id; - apr_ssize_t len; - void *idp_metadata_file; - - index = apr_hash_first(r->pool, cfg->idp_metadata_files); - if (index == NULL) - return NULL; - - apr_hash_this(index, (const void **)&provider_id, - &len, &idp_metadata_file); - return provider_id; -} - - -/* This function selects an IdP and returns its provider_id - * - * Parameters: - * request_rec *r The request we received. - * - * Returns: - * the provider_id, or NULL if an error occured - */ -static const char *am_get_idp(request_rec *r) -{ - am_dir_cfg_rec *cfg = am_get_dir_cfg(r); - const char *idp_provider_id; - const char *idp_metadata_file; - - /* - * If we have a single IdP, return that one. - */ - if (apr_hash_count(cfg->idp_metadata_files) == 1) - return am_first_idp(r); - - /* - * If IdP discovery handed us an IdP, try to use it. - */ - idp_provider_id = am_extract_query_parameter(r->pool, r->args, "IdP"); - if (idp_provider_id != NULL) { - int rc; - - rc = am_urldecode((char *)idp_provider_id); - if (rc != OK) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, - "Could not urldecode IdP discovery value."); - idp_provider_id = NULL; - } else { - idp_metadata_file = apr_hash_get(cfg->idp_metadata_files, - idp_provider_id, - APR_HASH_KEY_STRING); - if (idp_metadata_file == NULL) - idp_provider_id = NULL; - } - - /* - * If we do not know about it, fall back to default. - */ - if (idp_provider_id == NULL) { - ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, - "IdP discovery returned unknown or inexistant IdP"); - idp_provider_id = am_first_idp(r); - } - - return idp_provider_id; - } - - /* - * No IdP answered, use default - * Perhaps we should redirect to an error page instead. - */ - return am_first_idp(r); -} /* * This function loads all IdP metadata in a lasso server @@ -392,6 +308,92 @@ static LassoServer *am_get_lasso_server(request_rec *r) } +/* This function returns the first configured IdP + * + * Parameters: + * request_rec *r The request we received. + * + * Returns: + * the providerID, or NULL if an error occured + */ +static const char *am_first_idp(request_rec *r) +{ + am_dir_cfg_rec *cfg = am_get_dir_cfg(r); + apr_hash_index_t *index; + const char *provider_id; + apr_ssize_t len; + void *idp_metadata_file; + + index = apr_hash_first(r->pool, cfg->idp_metadata_files); + if (index == NULL) + return NULL; + + apr_hash_this(index, (const void **)&provider_id, + &len, &idp_metadata_file); + return provider_id; +} + + +/* This function selects an IdP and returns its provider_id + * + * Parameters: + * request_rec *r The request we received. + * + * Returns: + * the provider_id, or NULL if an error occured + */ +static const char *am_get_idp(request_rec *r) +{ + am_dir_cfg_rec *cfg = am_get_dir_cfg(r); + const char *idp_provider_id; + const char *idp_metadata_file; + + /* + * If we have a single IdP, return that one. + */ + if (apr_hash_count(cfg->idp_metadata_files) == 1) + return am_first_idp(r); + + /* + * If IdP discovery handed us an IdP, try to use it. + */ + idp_provider_id = am_extract_query_parameter(r->pool, r->args, "IdP"); + if (idp_provider_id != NULL) { + int rc; + + rc = am_urldecode((char *)idp_provider_id); + if (rc != OK) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, + "Could not urldecode IdP discovery value."); + idp_provider_id = NULL; + } else { + idp_metadata_file = apr_hash_get(cfg->idp_metadata_files, + idp_provider_id, + APR_HASH_KEY_STRING); + if (idp_metadata_file == NULL) + idp_provider_id = NULL; + } + + /* + * If we do not know about it, fall back to default. + */ + if (idp_provider_id == NULL) { + ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, + "IdP discovery returned unknown or inexistant IdP"); + idp_provider_id = am_first_idp(r); + } + + return idp_provider_id; + } + + /* + * No IdP answered, use default + * Perhaps we should redirect to an error page instead. + */ + return am_first_idp(r); +} + + /* This function stores dumps of the LassoIdentity and LassoSession objects * for the given LassoProfile object. The dumps are stored in the session * belonging to the current request. |