Author: dumindu
Date: Tue Dec  4 11:27:09 2007
New Revision: 10493

Log:

'xmlToken=' can be replaced with any user defined token now.



Modified:
   trunk/solutions/identity/modules/mod-cspace/cspace_config.c
   trunk/solutions/identity/modules/mod-cspace/mod_cspace.c
   trunk/solutions/identity/modules/mod-cspace/mod_cspace.h

Modified: trunk/solutions/identity/modules/mod-cspace/cspace_config.c
==============================================================================
--- trunk/solutions/identity/modules/mod-cspace/cspace_config.c (original)
+++ trunk/solutions/identity/modules/mod-cspace/cspace_config.c Tue Dec  4 
11:27:09 2007
@@ -33,6 +33,7 @@
 
 #define OUTPUT_LEN 120
 
+/*TODO: use strncpy where ever possible*/
 void cfg_svr_printf_fn(const char* st, cspace_svr_cfg *cfg, const char* nl)
 {
     if (cfg) 
@@ -90,12 +91,20 @@
     return NULL;
 }
 
+static const char *cmd_cspace_xml_token(cmd_parms *cmd, void *mconfig, 
+                                  const char *arg)
+{
+    cspace_dir_cfg *cfg = (cspace_dir_cfg *)mconfig;
+    strcpy(cfg->xml_token, arg);
+    return NULL;
+}
+
 static const char *cmd_cspace_login_page(cmd_parms *cmd, void *mconfig, 
                                          const char *arg)
 {
     cspace_dir_cfg *cfg = (cspace_dir_cfg *)mconfig;
     /*strcpy(cfg->login_page, arg);*/
-    const char *path = (const char*)arg;
+    const char *path = (const char *)arg;
     *(const char **)apr_array_push((cfg->login_page)) = apr_pstrdup(cfg->pool,
                                                                     path);
 #ifdef CSPACE_DEBUG
@@ -153,7 +162,7 @@
     cspace_svr_cfg *cfg = ap_get_module_config(cmd->server->module_config,
                                                &cspace_module);
     expire = atol(arg);
-    cfg->session_expire = ((expire>0) ? expire : DEF_SESS_EXPIRE_TIME);
+    cfg->session_expire = ((expire > 0) ? expire : DEF_SESS_EXPIRE_TIME);
     return NULL;
 }
 
@@ -165,6 +174,8 @@
                  NULL, OR_ALL, "whether to enable session management or not"),
     AP_INIT_TAKE1("CardSpaceTVS", cmd_cspace_tvs, NULL, OR_ALL, 
                   "URL of Token Verification Service"),
+    AP_INIT_TAKE1("CardSpaceTVS", cmd_cspace_xml_token, NULL, OR_ALL, 
+                  "Name of the XML token sent"),
     AP_INIT_TAKE1("CardSpaceLoginURI", cmd_cspace_login_page, NULL, OR_ALL, 
                   "URI of login page in session managed case"),
     /* SSLCertificateKeyFile cannot be used in 2.0 because that will make 
@@ -248,6 +259,10 @@
     cfg->dirspec[0] = '\0';
     cfg->use_cspace_auth = 0;
     cfg->tvs[0] = '\0';
+
+    /*use apr_strncpy*/
+    strncpy(cfg->xml_token, CSPACE_XML_TOKEN, CSPACE_XML_TOKEN_LEN_MAX);
+   
     /*cfg->login_page[0] = '\0';*/
     cfg->login_page = apr_array_make(p, DEF_IGNORE_LIST_SIZE, 
                                      sizeof(const char *));
@@ -280,6 +295,7 @@
                                     ocfg->use_cspace_auth;
     strcpy(merged_cfg->dirspec, ocfg->dirspec);
     strcpy(merged_cfg->tvs, ocfg->tvs);
+    strcpy(merged_cfg->xml_token, ocfg->xml_token);
     /*strcpy(merged_cfg->login_page, ocfg->login_page);*/
     if ((!ocfg->login_page) && 
             (pcfg->login_page) && 

Modified: trunk/solutions/identity/modules/mod-cspace/mod_cspace.c
==============================================================================
--- trunk/solutions/identity/modules/mod-cspace/mod_cspace.c    (original)
+++ trunk/solutions/identity/modules/mod-cspace/mod_cspace.c    Tue Dec  4 
11:27:09 2007
@@ -433,8 +433,8 @@
     /* TODO: make the argument (tag identifying login page) a config option */
     if ((cspace_login_arg_avail(r)) && (r->method_number == M_POST)) {
         if (cspace_read_request(r, &buf, &ret)) {
-            /*TODO: xmlToken can be different! yet another config option*/
-            if ((buf) && (ap_strstr(buf, CSPACE_XML_TOKEN))) {
+            /*TODO:DONE xmlToken can be different! yet another config option*/
+            if ((buf) && (ap_strstr(buf, dir_cfg->xml_token))) {
                 int state = FAIL;
 
                 cspace_decode_url((char *)buf);
@@ -490,7 +490,7 @@
         if (cspace_read_request(r, &buf, &ret)) {
             
             /*TODO: xmlToken can be different! yet another config option*/
-            if ((buf) && (ap_strstr(buf, CSPACE_XML_TOKEN))) {
+            if ((buf) && (ap_strstr(buf, dir_cfg->xml_token))) {
                 int state = FAIL;
 
                 cspace_decode_url((char *)buf);

Modified: trunk/solutions/identity/modules/mod-cspace/mod_cspace.h
==============================================================================
--- trunk/solutions/identity/modules/mod-cspace/mod_cspace.h    (original)
+++ trunk/solutions/identity/modules/mod-cspace/mod_cspace.h    Tue Dec  4 
11:27:09 2007
@@ -20,6 +20,7 @@
 #define CSPACE_DEFAULT_LOGIN_AMP_ARG "&__mod_cspace_login__"
 
 
+#define CSPACE_XML_TOKEN_LEN_MAX 128
 #define CSPACE_XML_TOKEN "xmlToken="
 
 /*#define CSPACE_VERIFY_SUCCESS 100
@@ -35,13 +36,14 @@
 
 typedef struct cspace_dir_cfg {
     apr_pool_t *pool;
-    int use_cspace_auth; /*true|false flag*/
-    int session; /*true|false flag*/
-    int sso; /*true|false flag*/
-    char dirspec[256];/*TODO: remove MAGIC numbers*/
-    char tvs[1024];
+    int use_cspace_auth;        /*true|false flag*/
+    int session;                /*true|false flag*/
+    int sso;                    /*true|false flag*/
+    char dirspec[256];          /*TODO: remove MAGIC numbers*/
+    char tvs[1024];             /*TODO: remove MAGIC numbers*/
     apr_array_header_t *login_page;
-    char session_file[1024];
+    char session_file[1024];    /*TODO: remove MAGIC numbers*/
+    char xml_token[CSPACE_XML_TOKEN_LEN_MAX];
     /*void *session_ctx;*/ /*of session_ctx_t type*/
 } cspace_dir_cfg;
 
@@ -66,7 +68,7 @@
 #define cfg_dir_printf(st, cfg, nl) 
 #endif
 
-const command_rec cspace_cmds[11];
+const command_rec cspace_cmds[12];
 
 void *cspace_svr_cfg_create(apr_pool_t *p, server_rec *s);
 

_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev

Reply via email to