You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by ka...@apache.org on 2008/04/17 11:25:04 UTC

svn commit: r649018 - in /webservices/rampart/trunk/c: include/rampart_context.h src/util/rampart_context.c src/util/rampart_sec_header_builder.c

Author: kaushalye
Date: Thu Apr 17 02:24:51 2008
New Revision: 649018

URL: http://svn.apache.org/viewvc?rev=649018&view=rev
Log:
Allowing to add custom tokens to the rampart context and hence to the Security header

Modified:
    webservices/rampart/trunk/c/include/rampart_context.h
    webservices/rampart/trunk/c/src/util/rampart_context.c
    webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c

Modified: webservices/rampart/trunk/c/include/rampart_context.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/rampart_context.h?rev=649018&r1=649017&r2=649018&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/rampart_context.h (original)
+++ webservices/rampart/trunk/c/include/rampart_context.h Thu Apr 17 02:24:51 2008
@@ -1521,6 +1521,30 @@
         rampart_context_t *rampart_context,
         const axutil_env_t *env);
 
+    /**
+     * Set the a node list to the context. These nodes will be append to
+     * the Security header
+     * @param rampart_context
+     * @param env pointer to environment struct,Must not be NULL.
+     * @param tokens the token list as an array
+     * @returns status of the op.                                                                                                        
+     * AXIS2_SUCCESS on success and AXIS2_FAILURE on error          
+     */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    rampart_context_set_custom_tokens(rampart_context_t *rampart_context,
+                                        const axutil_env_t *env,
+                                        axutil_array_list_t *tokens); 
+
+    /**
+     * Get the node or the token list as an array. If the size is 0
+     * that means there are no custom tokens specified by the client
+     * @param rampart_context
+     * @param env pointer to environment struct,Must not be NULL.
+     * @returns the custom tokens list 
+     */
+    AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
+    rampart_context_get_custom_tokens(rampart_context_t *rampart_context,
+                                        const axutil_env_t *env);
 #ifdef __cplusplus
 }
 #endif

Modified: webservices/rampart/trunk/c/src/util/rampart_context.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/util/rampart_context.c?rev=649018&r1=649017&r2=649018&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/util/rampart_context.c (original)
+++ webservices/rampart/trunk/c/src/util/rampart_context.c Thu Apr 17 02:24:51 2008
@@ -55,7 +55,10 @@
 	
     /* SAML tokens. */
     axutil_array_list_t *saml_tokens;
-
+    
+    /* Custom tokens. */
+    axutil_array_list_t *custom_tokens;
+    
     /*Rampart specific members*/
     rp_secpolicy_t *secpolicy;
     rampart_callback_t *password_callback_module;
@@ -184,6 +187,7 @@
     rampart_context->certificate_file = NULL;
     rampart_context->reciever_certificate_file = NULL;    
     rampart_context->saml_tokens = NULL;
+    rampart_context->custom_tokens = NULL;
 	rampart_context->aquire_issued_token = NULL;
 
     rampart_context->secpolicy = NULL;
@@ -335,6 +339,13 @@
             rampart_context->key_list = NULL;
         }
 
+        /*Free custom tokens list*/
+        if(rampart_context->custom_tokens){
+            /*No need to free the contents*/
+            axutil_array_list_free(rampart_context->custom_tokens, env);
+            rampart_context->custom_tokens = NULL;
+        }
+
         AXIS2_FREE(env->allocator,rampart_context);
         rampart_context = NULL;
     }
@@ -2858,6 +2869,23 @@
 		return AXIS2_SUCCESS;
 	}
     return AXIS2_FAILURE;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_context_set_custom_tokens(rampart_context_t *rampart_context,
+                                        const axutil_env_t *env,
+                                        axutil_array_list_t *tokens)
+{
+    
+    rampart_context->custom_tokens = tokens;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
+rampart_context_get_custom_tokens(rampart_context_t *rampart_context,
+                                        const axutil_env_t *env)
+{
+    return rampart_context->custom_tokens;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL

Modified: webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c?rev=649018&r1=649017&r2=649018&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c (original)
+++ webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c Thu Apr 17 02:24:51 2008
@@ -509,6 +509,45 @@
         }
     }
 
+    /**********************
+     * Sample node to be added to the security header. This is for testing
+     * TODO: Remove later*/
+
+    if(1){
+        axiom_node_t *my_token = NULL;
+        axutil_array_list_t *token_list = NULL;
+        axis2_char_t *buf = "<MyToken/>";
+
+        token_list = axutil_array_list_create(env, 1);
+        my_token = oxs_axiom_deserialize_node(env, buf);
+        axutil_array_list_add(token_list, env, my_token);
+        rampart_context_set_custom_tokens(rampart_context,env, token_list);
+    }
+ 
+    /***********************/
+    /*Custom tokens are included if its available in the rampart context*/
+    if(!axis2_msg_ctx_get_server_side(msg_ctx,env))
+    {
+        axutil_array_list_t *token_list = NULL;
+
+        token_list = rampart_context_get_custom_tokens(rampart_context, env);
+        if(token_list){
+            int size = 0, i = 0;
+            size = axutil_array_list_size(token_list, env);
+            for (i = 0; i < size; i++){
+                axiom_node_t *token_node = NULL;
+                token_node = (axiom_node_t*)axutil_array_list_get(token_list, env, i);
+                if(token_node){
+                    axis2_status_t status = AXIS2_FAILURE;
+                    status = axiom_node_add_child(sec_node, env, token_node); 
+                    if(status != AXIS2_SUCCESS){
+                        return AXIS2_FAILURE;
+                    }
+                }
+            }
+        }
+    }
+
     if (rampart_context_is_include_supporting_token(rampart_context, env, server_side, AXIS2_FALSE, RP_PROPERTY_SAML_TOKEN))
     {        
         status = rampart_saml_supporting_token_build(env, rampart_context, sec_node, sign_parts_list);