You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ka...@apache.org on 2007/02/21 08:29:41 UTC

svn commit: r509928 - in /webservices/axis2/trunk/c/rampart: include/oxs_c14n.h include/oxs_constants.h src/omxmlsec/c14n/c14n.c

Author: kaushalye
Date: Tue Feb 20 23:29:40 2007
New Revision: 509928

URL: http://svn.apache.org/viewvc?view=rev&rev=509928
Log:
Applying patch sent by Dumindu. JIRA AXIS2C-511.



Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_c14n.h
    webservices/axis2/trunk/c/rampart/include/oxs_constants.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/c14n/c14n.c

Modified: webservices/axis2/trunk/c/rampart/include/oxs_c14n.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_c14n.h?view=diff&rev=509928&r1=509927&r2=509928
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_c14n.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_c14n.h Tue Feb 20 23:29:40 2007
@@ -42,6 +42,26 @@
 extern "C"
 {
 #endif
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    oxs_c14n_apply_stream_algo(
+        const axis2_env_t *env,
+        const axiom_document_t *doc,
+        axis2_stream_t *stream,
+        const axis2_array_list_t *ns_prefixes,
+        const axiom_node_t *node,
+        const axis2_char_t* algo
+        );
+
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    oxs_c14n_apply_algo(
+        const axis2_env_t *env,
+        const axiom_document_t *doc,
+        axis2_char_t **outbuf,
+        const axis2_array_list_t *ns_prefixes,
+        const axiom_node_t *node,
+        const axis2_char_t *algo
+        );
+
 
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     oxs_c14n_apply_stream(

Modified: webservices/axis2/trunk/c/rampart/include/oxs_constants.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_constants.h?view=diff&rev=509928&r1=509927&r2=509928
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_constants.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_constants.h Tue Feb 20 23:29:40 2007
@@ -178,9 +178,12 @@
 /****************************************************************
    C14N
 ****************************************************************/
+
 #define OXS_HREF_XML_C14N                   "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
 #define OXS_HREF_XML_EXC_C14N     "http://www.w3.org/2001/10/xml-exc-c14n#"
 
+#define OXS_HREF_XML_C14N_WITH_COMMENTS         "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"
+#define OXS_HREF_XML_EXC_C14N_WITH_COMMENTS "http://www.w3.org/2001/10/xml-exc-c14n#WithComments"
 /****************************************************************
    Transforms
 ****************************************************************/

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/c14n/c14n.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/c14n/c14n.c?view=diff&rev=509928&r1=509927&r2=509928
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/c14n/c14n.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/c14n/c14n.c Tue Feb 20 23:29:40 2007
@@ -29,6 +29,7 @@
 #include <axiom_children_iterator.h>
 #include <axiom_document.h>
 #include <axiom_comment.h>
+#include <oxs_constants.h>
 #include <oxs_c14n.h>
 #include "c14n_sorted_list.h"
 
@@ -54,6 +55,12 @@
     ((doc) ? AXIOM_DOCUMENT_GET_ROOT_ELEMENT((axiom_document_t *)(doc), \
         (ctx)->env) : c14n_get_root_node((node), (ctx))) 
 
+typedef enum {
+    C14N_XML_C14N = 1,
+    C14N_XML_C14N_WITH_COMMENTS,
+    C14N_XML_EXC_C14N,
+    C14N_XML_EXC_C14N_WITH_COMMENTS,
+} c14n_algo_t;
 
 typedef struct c14n_ns_stack {
     int head; /*index of the currnt stack TOP*/
@@ -377,6 +384,11 @@
     const c14n_ctx_t *ctx
     );
 
+static c14n_algo_t 
+c14n_get_algorithm(
+    const axis2_char_t* algo
+    );
+
 /*static axis2_bool_t
 c14n_in_nodeset(
     const axiom_node_t *node,
@@ -462,6 +474,86 @@
         parent = AXIOM_NODE_GET_PARENT((axiom_node_t *)parent, ctx->env);
     }
     return (axiom_node_t *)prv_parent;
+}
+
+static c14n_algo_t 
+c14n_get_algorithm(
+    const axis2_char_t* algo
+    )
+{
+   if (axis2_strcmp(algo, OXS_HREF_XML_C14N))
+            return C14N_XML_C14N;
+
+   if (axis2_strcmp(algo, OXS_HREF_XML_C14N_WITH_COMMENTS))
+            return C14N_XML_C14N_WITH_COMMENTS;
+
+   if (axis2_strcmp(algo, OXS_HREF_XML_EXC_C14N))
+            return C14N_XML_EXC_C14N;
+
+   if (axis2_strcmp(algo, OXS_HREF_XML_EXC_C14N_WITH_COMMENTS))
+            return C14N_XML_EXC_C14N_WITH_COMMENTS;
+
+   return 0; /*c14n_algo_t enum starts with 1*/
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_c14n_apply_stream_algo(
+    const axis2_env_t *env,
+    const axiom_document_t *doc,
+    axis2_stream_t *stream,
+    const axis2_array_list_t *ns_prefixes,
+    const axiom_node_t *node,
+    const axis2_char_t* algo
+    )
+{
+    switch (c14n_get_algorithm(algo))
+    {
+        case C14N_XML_C14N:
+            return oxs_c14n_apply_stream(env, doc, AXIS2_FALSE, stream, AXIS2_FALSE,
+                    ns_prefixes, node);
+        case C14N_XML_C14N_WITH_COMMENTS:
+            return oxs_c14n_apply_stream(env, doc, AXIS2_TRUE, stream, AXIS2_FALSE,
+                    ns_prefixes, node);
+        case C14N_XML_EXC_C14N:
+            return oxs_c14n_apply_stream(env, doc, AXIS2_FALSE, stream, AXIS2_TRUE,
+                    ns_prefixes, node);
+        case C14N_XML_EXC_C14N_WITH_COMMENTS:
+            return oxs_c14n_apply_stream(env, doc, AXIS2_TRUE, stream, AXIS2_TRUE,
+                    ns_prefixes, node);
+        default:
+            /*TODO: set the error*/
+            return AXIS2_FAILURE;
+     }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_c14n_apply_algo(
+    const axis2_env_t *env,
+    const axiom_document_t *doc,
+    axis2_char_t **outbuf,
+    const axis2_array_list_t *ns_prefixes,
+    const axiom_node_t *node,
+    const axis2_char_t *algo
+    )
+{
+    switch (c14n_get_algorithm(algo))
+    {
+        case C14N_XML_C14N:
+            return oxs_c14n_apply(env, doc, AXIS2_FALSE, outbuf, AXIS2_FALSE,
+                    ns_prefixes, node);
+        case C14N_XML_C14N_WITH_COMMENTS:
+            return oxs_c14n_apply(env, doc, AXIS2_TRUE, outbuf, AXIS2_FALSE,
+                    ns_prefixes, node);
+        case C14N_XML_EXC_C14N:
+            return oxs_c14n_apply(env, doc, AXIS2_FALSE, outbuf, AXIS2_TRUE,
+                    ns_prefixes, node);
+        case C14N_XML_EXC_C14N_WITH_COMMENTS:
+            return oxs_c14n_apply(env, doc, AXIS2_TRUE, outbuf, AXIS2_TRUE,
+                    ns_prefixes, node);
+        default:
+            /*TODO:set the error*/
+            return AXIS2_FAILURE;
+     }
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org