From 892592fe13ed55c6b8a89a6659b6ea0e4e066046 Mon Sep 17 00:00:00 2001 From: olavmrk Date: Wed, 18 May 2011 10:49:08 +0000 Subject: Change cfg->idp_metadata_files to an array instead of an hash. git-svn-id: https://modmellon.googlecode.com/svn/trunk@126 a716ebb1-153a-0410-b759-cfb97c6a1b53 --- auth_mellon.h | 2 +- auth_mellon_config.c | 22 +++++++--------------- auth_mellon_handler.c | 20 +++++++------------- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/auth_mellon.h b/auth_mellon.h index 452fdea..f6bdede 100644 --- a/auth_mellon.h +++ b/auth_mellon.h @@ -183,7 +183,7 @@ typedef struct am_dir_cfg_rec { const char *sp_metadata_file; const char *sp_private_key_file; const char *sp_cert_file; - apr_hash_t *idp_metadata_files; + apr_array_header_t *idp_metadata_files; const char *idp_public_key_file; const char *idp_ca_file; diff --git a/auth_mellon_config.c b/auth_mellon_config.c index 2056e0a..53be596 100644 --- a/auth_mellon_config.c +++ b/auth_mellon_config.c @@ -291,17 +291,10 @@ static const char *am_set_idp_string_slot(cmd_parms *cmd, server_rec *s = cmd->server; apr_pool_t *pconf = s->process->pconf; am_dir_cfg_rec *cfg = (am_dir_cfg_rec *)struct_ptr; - const char *error; - const char *provider_id; - - if ((error = am_get_provider_id(cmd->pool, s, - arg, &provider_id)) != NULL) - return apr_psprintf(cmd->pool, "%s - %s", cmd->cmd->name, error); + const char **filename_slot; - apr_hash_set(cfg->idp_metadata_files, - apr_pstrdup(pconf, provider_id), - APR_HASH_KEY_STRING, - apr_pstrdup(pconf, arg)); + filename_slot = apr_array_push(cfg->idp_metadata_files); + *filename_slot = apr_pstrdup(pconf, arg); return NULL; } @@ -1084,7 +1077,7 @@ void *auth_mellon_dir_config(apr_pool_t *p, char *d) dir->sp_metadata_file = NULL; dir->sp_private_key_file = NULL; dir->sp_cert_file = NULL; - dir->idp_metadata_files = apr_hash_make(p); + dir->idp_metadata_files = apr_array_make(p, 0, sizeof(const char *)); dir->idp_public_key_file = NULL; dir->idp_ca_file = NULL; dir->login_path = default_login_path; @@ -1208,10 +1201,9 @@ void *auth_mellon_dir_merge(apr_pool_t *p, void *base, void *add) add_cfg->sp_cert_file : base_cfg->sp_cert_file); - new_cfg->idp_metadata_files = apr_hash_copy(p, - (apr_hash_count(add_cfg->idp_metadata_files) > 0) ? - add_cfg->idp_metadata_files : - base_cfg->idp_metadata_files); + new_cfg->idp_metadata_files = (add_cfg->idp_metadata_files->nelts > 0 ? + add_cfg->idp_metadata_files : + base_cfg->idp_metadata_files); new_cfg->idp_public_key_file = (add_cfg->idp_public_key_file ? add_cfg->idp_public_key_file : diff --git a/auth_mellon_handler.c b/auth_mellon_handler.c index c0379e8..c3284c3 100644 --- a/auth_mellon_handler.c +++ b/auth_mellon_handler.c @@ -216,33 +216,27 @@ static int am_server_add_providers(request_rec *r) am_dir_cfg_rec *cfg = am_get_dir_cfg(r); const char *idp_metadata_file; const char *idp_public_key_file; - apr_hash_index_t *index; + apr_size_t index; int count = 0; - if (apr_hash_count(cfg->idp_metadata_files) == 1) + if (cfg->idp_metadata_files->nelts == 1) idp_public_key_file = cfg->idp_public_key_file; else idp_public_key_file = NULL; - for (index = apr_hash_first(r->pool, cfg->idp_metadata_files); - index; - index = apr_hash_next(index)) { - const char *idp_provider_id; - apr_ssize_t len; + for (index = 0; index < cfg->idp_metadata_files->nelts; index++) { int ret; - - apr_hash_this(index, (const void **)&idp_provider_id, - &len, (void *)&idp_metadata_file); + idp_metadata_file = APR_ARRAY_IDX(cfg->idp_metadata_files, index, + const char *); - ret = lasso_server_add_provider(cfg->server, LASSO_PROVIDER_ROLE_IDP, idp_metadata_file, idp_public_key_file, cfg->idp_ca_file); if (ret != 0) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, - "Error adding IdP \"%s\" to lasso server object.", - idp_provider_id); + "Error adding IdP from \"%s\" to lasso server object.", + idp_metadata_file); } else { count++; } -- cgit