axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kausha...@apache.org
Subject svn commit: r509098 - in /webservices/axis2/trunk/c/rampart: include/ src/omxmlsec/ test/omxmlsec/
Date Mon, 19 Feb 2007 05:56:23 GMT
Author: kaushalye
Date: Sun Feb 18 21:56:22 2007
New Revision: 509098

URL: http://svn.apache.org/viewvc?view=rev&rev=509098
Log:
1. Adding transform struct to keep information abt a single step of transformation as specified
in XML-Signature
2. Adding a transform factory to produce predefined transforms.
3. Modified omxmlsecurity test to load a certificate.


Added:
    webservices/axis2/trunk/c/rampart/include/oxs_transform.h
    webservices/axis2/trunk/c/rampart/include/oxs_transforms_factory.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/transform.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/transforms_factory.c
Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_constants.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am
    webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
    webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c

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=509098&r1=509097&r2=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_constants.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_constants.h Sun Feb 18 21:56:22 2007
@@ -181,6 +181,13 @@
 #define OXS_HREF_C14N                   "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
 
 /****************************************************************
+   Transforms
+****************************************************************/
+#define OXS_HREF_TRANSFORM_XML_EXC_C14N     "http://www.w3.org/2001/10/xml-exc-c14n#"
+#define OXS_HREF_TRANSFORM_STR_TRANSFORM     "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform"
+#define OXS_HREF_TRANSFORM_ENVELOPED_SIGNATURE "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
+
+/****************************************************************
     KeyNAME
 ****************************************************************/
 #define OXS_NAME_KEY_NAME          "key-name" 

Added: webservices/axis2/trunk/c/rampart/include/oxs_transform.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_transform.h?view=auto&rev=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_transform.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_transform.h Sun Feb 18 21:56:22 2007
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OXS_TRANSFORM_H
+#define OXS_TRANSFORM_H
+
+
+/**
+  * @file oxs_transform.h
+  * @brief The class representing a single step of transformation. 
+  */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+    /*The input or output data type*/
+    typedef enum  {
+        OXS_TRANSFORM_TYPE_NODE = 0,
+        OXS_TRANSFORM_TYPE_CHAR
+    } oxs_tr_dtype_t;
+
+
+    /*Function interface for any transform*/
+    typedef axis2_status_t (AXIS2_CALL*
+            tr_func)(const axis2_env_t *env,
+            void *input,
+            oxs_tr_dtype_t input_dtype,
+            void **output,
+            oxs_tr_dtype_t **output_dtype);
+
+    typedef struct oxs_transform_t oxs_transform_t;
+
+
+    /*Create function*/
+    AXIS2_EXTERN oxs_transform_t *AXIS2_CALL
+    oxs_transform_create(const axis2_env_t *env);
+
+    /*Free*/
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    oxs_transform_free(oxs_transform_t *ctx,
+        const axis2_env_t *env);
+
+
+/**********************Getter functions******************************************/
+axis2_char_t *AXIS2_CALL
+oxs_transform_get_id(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env);
+
+oxs_tr_dtype_t AXIS2_CALL
+oxs_transform_get_input_data_type(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env);
+
+oxs_tr_dtype_t AXIS2_CALL
+oxs_transform_get_output_data_type(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env);
+
+tr_func *AXIS2_CALL
+    oxs_transform_get_transform_function(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env);
+
+/**********************Setter functions******************************************/
+axis2_status_t AXIS2_CALL
+oxs_transform_set_id(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    axis2_char_t *id);
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_input_data_type(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    oxs_tr_dtype_t input_data_type);
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_output_data_type(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    oxs_tr_dtype_t output_data_type);
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_transform_func(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    tr_func *transform_func);
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* OXS_TRANSFORM_H */

Added: webservices/axis2/trunk/c/rampart/include/oxs_transforms_factory.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_transforms_factory.h?view=auto&rev=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_transforms_factory.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_transforms_factory.h Sun Feb 18 21:56:22
2007
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OXS_TRANSFORMS_FACTORY_H
+#define OXS_TRANSFORMS_FACTORY_H
+
+
+/**
+  * @file oxs_transforms_factory.h
+  * @brief Produces transforms for OMXMLSecurity  
+  */
+
+#include <axis2_defines.h>
+#include <oxs_ctx.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_qname.h>
+#include <oxs_transform.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_EXTERN oxs_transform_t *AXIS2_CALL
+oxs_transforms_factory_produce_transform(const axis2_env_t *env,
+    axis2_char_t *id);
+
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* OXS_TRANSFORMS_FACTORY_H */

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am?view=diff&rev=509098&r1=509097&r2=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am Sun Feb 18 21:56:22 2007
@@ -4,7 +4,7 @@
 libomxmlsec_la_SOURCES = ctx.c  buffer.c key.c cipher.c error.c axis2_utils.c axiom.c \
                          iv.c xml_encryption.c encryption.c\
 						utility.c asym_ctx.c x509_cert.c key_mgr.c sign_part.c sign_ctx.c \
-						xml_signature.c signature.c
+						xml_signature.c signature.c transform.c transforms_factory.c
 						
 
 libomxmlsec_la_LIBADD  = -lssl\

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c?view=diff&rev=509098&r1=509097&r2=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c Sun Feb 18 21:56:22 2007
@@ -258,5 +258,4 @@
     oxs_cert = oxs_key_mgr_convert_to_x509(env, cert);
 
     return oxs_cert; 
-
 }

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/transform.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/transform.c?view=auto&rev=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/transform.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/transform.c Sun Feb 18 21:56:22 2007
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <axis2_util.h>
+#include <oxs_transform.h>
+#include <oxs_error.h>
+
+
+struct oxs_transform_t
+{
+    axis2_char_t *id ;
+    oxs_tr_dtype_t input_data_type;
+    oxs_tr_dtype_t output_data_type;
+    tr_func *transform_func; /*The function to implement the transform*/
+};
+
+axis2_char_t *AXIS2_CALL
+oxs_transform_get_id(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env)
+{
+    return transform->id;
+}
+
+oxs_tr_dtype_t AXIS2_CALL
+oxs_transform_get_input_data_type(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env)
+{
+    return transform->input_data_type;
+}
+
+oxs_tr_dtype_t AXIS2_CALL
+oxs_transform_get_output_data_type(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env)
+{
+    return transform->output_data_type;
+}
+
+tr_func *AXIS2_CALL
+oxs_transform_get_transform_function(
+    const oxs_transform_t *transform,
+    const axis2_env_t *env)
+{
+    return transform->transform_func;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_id(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    axis2_char_t *id)
+{
+
+    if (transform->id)
+    {
+        AXIS2_FREE(env->allocator, transform->id);
+        transform->id = NULL;
+    }
+    transform->id = AXIS2_STRDUP(id, env);
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_input_data_type(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    oxs_tr_dtype_t input_data_type)
+{
+    transform->input_data_type = input_data_type;
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_output_data_type(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    oxs_tr_dtype_t output_data_type)
+{
+    transform->output_data_type = output_data_type;
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_transform_set_transform_function(
+    oxs_transform_t *transform,
+    const axis2_env_t *env,
+    tr_func *transform_func)
+{
+    transform->transform_func = transform_func;
+    return AXIS2_SUCCESS;
+}
+
+

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/transforms_factory.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/transforms_factory.c?view=auto&rev=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/transforms_factory.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/transforms_factory.c Sun Feb 18 21:56:22
2007
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <axis2_util.h>
+#include <oxs_constants.h>
+#include <oxs_error.h>
+#include <oxs_buffer.h>
+#include <oxs_transform.h>
+#include <oxs_transforms_factory.h>
+#include <oxs_buffer.h>
+
+/*Functions that implements transforms*/
+axis2_status_t AXIS2_CALL
+oxs_transforms_exc_c14n(const axis2_env_t *env,
+            axiom_node_t *input,
+            oxs_tr_dtype_t input_dtype,
+            axis2_char_t **output,
+            oxs_tr_dtype_t **output_dtype)
+{
+    *output= "SAMPLE-SAMPLE-SAMPLE";
+    /*output_dtype = OXS_TRANSFORM_TYPE_CHAR;*/
+
+    return AXIS2_SUCCESS;
+}
+
+/*Public functions*/
+AXIS2_EXTERN oxs_transform_t *AXIS2_CALL
+oxs_transforms_factory_produce_transform(const axis2_env_t *env,
+    axis2_char_t *id)
+{
+    oxs_transform_t *tr =  NULL;
+
+    /*Inspect the id and produce a transform*/
+    if(0== axis2_strcmp(id, OXS_HREF_TRANSFORM_XML_EXC_C14N)){
+        tr = oxs_transform_create(env);
+        oxs_transform_set_id(tr, env, id);
+        oxs_transform_set_input_data_type(tr, env, OXS_TRANSFORM_TYPE_NODE);
+        oxs_transform_set_output_data_type(tr, env, OXS_TRANSFORM_TYPE_CHAR);
+        oxs_transform_set_transform_func(tr, env, oxs_transforms_exc_c14n);
+    }else{
+        /*Error we do not support*/
+        return NULL;
+    }
+}
+

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c?view=diff&rev=509098&r1=509097&r2=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c Sun Feb 18 21:56:22 2007
@@ -105,7 +105,7 @@
         axiom_node_t *transforms_node = NULL;
         /*Add ds:Transforms element*/
         transforms_node = oxs_token_build_transforms_element(env, reference_node);
-        /*LOOP: Apply transforms. This usually C14N*/
+        /*LOOP: Apply transforms. For example exclusive C14N*/
         for (i = 0; i < AXIS2_ARRAY_LIST_SIZE(transforms, env); i++){
             /*Apply transform*/
 

Modified: webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c?view=diff&rev=509098&r1=509097&r2=509098
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Sun Feb 18 21:56:22 2007
@@ -106,6 +106,7 @@
     sign_ctx = oxs_sign_ctx_create(env);
     if(sign_ctx){
         openssl_pkey_t *prvkey = NULL;
+        oxs_x509_cert_t *cert = NULL;
 
         /*Set private key*/
         prvkey = oxs_key_mgr_load_private_key_from_file(env, "rsakey.pem", "");
@@ -115,6 +116,11 @@
         oxs_sign_ctx_set_private_key(sign_ctx, env, prvkey);
 
         /*TODO : Set x509 certificate. This is required to set the Key Information in ds:KeyInfo*/
+        cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, "rsacert.pem");
+        if(!cert){
+             printf("Cannot load certificate");
+        }
+        oxs_sign_ctx_set_certificate(sign_ctx, env, cert);
 
         /*Set sig algo*/
         oxs_sign_ctx_set_sign_mtd_algo(sign_ctx, env, OXS_HREF_RSA_SHA1);



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


Mime
View raw message