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 2007/10/08 12:36:29 UTC

svn commit: r582768 - /webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c

Author: kaushalye
Date: Mon Oct  8 03:36:28 2007
New Revision: 582768

URL: http://svn.apache.org/viewvc?rev=582768&view=rev
Log:
Symmetric binding logic in sec header builder

Modified:
    webservices/rampart/trunk/c/src/util/rampart_sec_header_builder.c

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=582768&r1=582767&r2=582768&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 Mon Oct  8 03:36:28 2007
@@ -36,6 +36,65 @@
 
 /*Private functions*/
 axis2_status_t AXIS2_CALL
+rampart_shb_do_symmetric_binding( const axutil_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+    rampart_context_t *rampart_context,
+    axiom_soap_envelope_t *soap_envelope,
+    axiom_node_t *sec_node,
+    axiom_namespace_t *sec_ns_obj)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+
+    /*TODO Symmetric binding*/
+
+    if(rampart_context_is_include_timestamp(rampart_context,env))
+    {
+            int ttl = -1;
+            AXIS2_LOG_INFO(env->log, "[rampart][shb]  building Timestamp Token");
+            AXIS2_LOG_INFO(env->log, "[rampart][shb]  Using default timeToLive value %d",
+                           RAMPART_TIMESTAMP_TOKEN_DEFAULT_TIME_TO_LIVE);
+            /*ttl = RAMPART_TIMESTAMP_TOKEN_DEFAULT_TIME_TO_LIVE;*/
+            ttl = rampart_context_get_ttl(rampart_context,env);
+
+            status = rampart_timestamp_token_build(env,
+                                                   sec_node, sec_ns_obj, ttl);
+            if (status == AXIS2_FAILURE)
+            {
+                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart][shb] Timestamp Token build failed. ERROR");
+                return AXIS2_FAILURE;
+            }
+       }
+
+       /*User name tokens includes in messages sent from client to server*/
+        if(!axis2_msg_ctx_get_server_side(msg_ctx,env))
+        {
+            if(rampart_context_is_include_username_token(rampart_context,env))
+            {
+
+                /*Now we are passing rampart_context here so inside this method
+                relevant parameters are extracted. */
+
+                AXIS2_LOG_INFO(env->log, "[rampart][shb]  building UsernmaeToken");
+                status =rampart_username_token_build(
+                            env,
+                            rampart_context,
+                            sec_node,
+                            sec_ns_obj);
+                if (status == AXIS2_FAILURE)
+                {
+                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                                    "[rampart][shb] UsernmaeToken build failed. ERROR");
+                    return AXIS2_FAILURE;
+                }
+            }
+        }
+
+    status = AXIS2_SUCCESS;
+
+    return status;
+}
+
+axis2_status_t AXIS2_CALL
 rampart_interchange_nodes(const axutil_env_t *env,
                           axiom_node_t *node_to_move,
                           axiom_node_t *node_before)
@@ -62,7 +121,6 @@
     rampart_context_t *rampart_context,
     axiom_soap_envelope_t *soap_envelope)
 {
-
     axis2_status_t status = AXIS2_SUCCESS;
     axiom_soap_header_t *soap_header = NULL;
     axiom_node_t *soap_header_node = NULL;
@@ -106,14 +164,14 @@
     if((rampart_context_get_binding_type(rampart_context,env)) == RP_PROPERTY_ASYMMETRIC_BINDING)
     {
         /*Do Asymmetric Binding specific things*/
-        AXIS2_LOG_INFO(env->log, "[rampart][shb]  Using asymmetric binding");
+        AXIS2_LOG_INFO(env->log, "[rampart][shb] Using asymmetric binding");
 
         /*Timestamp Inclusion*/
         if(rampart_context_is_include_timestamp(rampart_context,env))
         {
             int ttl = -1;
-            AXIS2_LOG_INFO(env->log, "[rampart][shb]  building Timestamp Token");
-            AXIS2_LOG_INFO(env->log, "[rampart][shb]  Using default timeToLive value %d",
+            AXIS2_LOG_INFO(env->log, "[rampart][shb] Building Timestamp Token");
+            AXIS2_LOG_INFO(env->log, "[rampart][shb] Using default timeToLive value %d",
                            RAMPART_TIMESTAMP_TOKEN_DEFAULT_TIME_TO_LIVE);
             /*ttl = RAMPART_TIMESTAMP_TOKEN_DEFAULT_TIME_TO_LIVE;*/
             ttl = rampart_context_get_ttl(rampart_context,env);
@@ -182,7 +240,6 @@
                     return AXIS2_FAILURE;
                 }
                 /*Then Sign the message*/
-
                 status = rampart_sig_sign_message(env, msg_ctx, rampart_context, soap_envelope, sec_node);
                 if(status != AXIS2_SUCCESS)
                 {
@@ -192,7 +249,6 @@
                 }
 
                 /*Then encrypt the signature */
-
                 status = rampart_enc_encrypt_signature(env, msg_ctx, rampart_context, soap_envelope, sec_node);
                 if(status != AXIS2_SUCCESS)
                 {
@@ -202,7 +258,7 @@
                 }
 
             }
-            else
+            else /*No Signature protection*/
             {
                 status = rampart_enc_encrypt_message(env, msg_ctx, rampart_context, soap_envelope, sec_node);
                 if(status != AXIS2_SUCCESS){
@@ -221,7 +277,7 @@
 
             /*Then Handle Supporting token stuff  */
         }
-        else
+        else /*Sign before encrypt*/
         {
             is_encrypt_before_sign = AXIS2_FALSE;
             /*First do signature specific stuff*/
@@ -252,16 +308,16 @@
                 status = rampart_interchange_nodes(env, sig_node, enc_key_node);
                 if(status!=AXIS2_SUCCESS)
                 {
-                    AXIS2_LOG_INFO(env->log,"[rampart][shb]Node interchange failed.");
+                    AXIS2_LOG_INFO(env->log,"[rampart][shb] Node interchange failed.");
                     return status;
                 }
             }
-            else
+            else /*Sign before encryption*/
             {
                 status = rampart_interchange_nodes(env, enc_key_node, sig_node);
                 if(status!=AXIS2_SUCCESS)
                 {
-                    AXIS2_LOG_INFO(env->log,"[rampart][shb]Node interchange failed.");
+                    AXIS2_LOG_INFO(env->log,"[rampart][shb] Node interchange failed.");
                     return status;
                 }
             }
@@ -294,8 +350,11 @@
     }
     else if((rampart_context_get_binding_type(rampart_context,env)) == RP_PROPERTY_SYMMETRIC_BINDING)
     {
+        axis2_status_t status = AXIS2_FAILURE;
+
         /*Do Symmetric_binding specific things*/
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart][shb] Symmetric Binding. We do not support yet");
+        status = rampart_shb_do_symmetric_binding(env, msg_ctx, rampart_context, soap_envelope, sec_node, sec_ns_obj);
         return AXIS2_FAILURE;
     }
     else if((rampart_context_get_binding_type(rampart_context,env)) == RP_PROPERTY_TRANSPORT_BINDING)