axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kausha...@apache.org
Subject svn commit: r504797 - in /webservices/axis2/trunk/c/rampart: include/oxs_sign_ctx.h include/oxs_xml_signature.h src/handlers/rampart_in_handler.c src/omxmlsec/xml_signature.c src/util/rampart_sec_header_processor.c test/omxmlsec/test.c
Date Thu, 08 Feb 2007 05:47:51 GMT
Author: kaushalye
Date: Wed Feb  7 21:47:50 2007
New Revision: 504797

URL: http://svn.apache.org/viewvc?view=rev&rev=504797
Log:
Adding signature support in OMXMLSecurity

Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_sign_ctx.h
    webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h
    webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
    webservices/axis2/trunk/c/rampart/src/util/rampart_sec_header_processor.c
    webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c

Modified: webservices/axis2/trunk/c/rampart/include/oxs_sign_ctx.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_sign_ctx.h?view=diff&rev=504797&r1=504796&r2=504797
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_sign_ctx.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_sign_ctx.h Wed Feb  7 21:47:50 2007
@@ -53,7 +53,7 @@
     const axis2_env_t *env);
 
 axis2_char_t *AXIS2_CALL
-oxs_sign_ctx_get_digest_mtd(
+oxs_sign_ctx_get_c14n_mtd(
     const oxs_sign_ctx_t *sign_ctx,
     const axis2_env_t *env);
 

Modified: webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h?view=diff&rev=504797&r1=504796&r2=504797
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h Wed Feb  7 21:47:50 2007
@@ -30,6 +30,7 @@
 #include <axiom_node.h>
 #include <axiom_element.h>
 #include <axis2_qname.h>
+#include <oxs_sign_ctx.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -40,14 +41,16 @@
  */
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_xml_sig_sign(const axis2_env_t *env,
-    oxs_sign_ctx_t *sign_ctx);
+    oxs_sign_ctx_t *sign_ctx,
+    axiom_node_t *parent);
 
 /**
  * Verify
  */
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_xml_sig_verify(const axis2_env_t *env,
-    oxs_sign_ctx_t *sign_ctx);
+    oxs_sign_ctx_t *sign_ctx,
+    axiom_node_t *signature_node);
 
 /** @} */
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c?view=diff&rev=504797&r1=504796&r2=504797
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c (original)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c Wed Feb  7 21:47:50
2007
@@ -163,7 +163,6 @@
                 return AXIS2_FAILURE;
             }                
 
-           
 
         }else{ /* End of sec_header */
             /*It's OK to have SOAP envelopes without headers*/

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=504797&r1=504796&r2=504797
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c Wed Feb  7 21:47:50 2007
@@ -29,6 +29,11 @@
 #include <oxs_token_digest_value.h>
 #include <oxs_token_transforms.h>
 #include <oxs_token_transform.h>
+#include <oxs_token_c14n_method.h>
+#include <oxs_token_signature.h>
+#include <oxs_token_signature_method.h>
+#include <oxs_token_signature_value.h>
+#include <oxs_token_signed_info.h>
 /*Private functions*/
 
 /*parent is ds:SignedInfo*/
@@ -83,13 +88,33 @@
 /*Public functions*/
 AXIS2_EXTERN axis2_status_t AXIS2_CALL 
 oxs_xml_sig_sign(const axis2_env_t *env,
-    oxs_sign_ctx_t *sign_ctx)
+    oxs_sign_ctx_t *sign_ctx,
+    axiom_node_t *parent)
 {
     axiom_node_t *signed_info_node = NULL;
+    axiom_node_t *signature_node = NULL;
+    axiom_node_t *signature_mtd_node = NULL;
+    axiom_node_t *signature_val_node = NULL;
+    axiom_node_t *c14n_mtd_node = NULL;
+    axis2_char_t *sign_algo = NULL;
+    axis2_char_t *c14n_algo = NULL;
+    axis2_char_t *signature_val = NULL;
     axis2_array_list_t *sign_parts = NULL;
     int i=0;
 
-    /*Get the signature context*/
+    /*Construct the <Signature> element*/
+    signature_node = oxs_token_build_signature_element(env, parent, "Sign-ID");
+
+    /*Construct the <SignedInfo>  */
+    signed_info_node = oxs_token_build_signed_info_element(env, signature_node);
+
+    /*Construct the <SignatureMethod>  */
+    sign_algo = oxs_sign_ctx_get_sign_mtd_algo(sign_ctx, env);
+    signature_mtd_node = oxs_token_build_signature_method_element(env, signed_info_node,
sign_algo);
+
+    /*Construct the <CanonicalizationMethod> */
+    c14n_algo = oxs_sign_ctx_get_c14n_mtd(sign_ctx, env);
+    c14n_mtd_node = oxs_token_build_c14n_method_element(env, signed_info_node, c14n_algo);
 
     /*Look for signature parts*/
     sign_parts = oxs_sign_ctx_get_sign_parts(sign_ctx , env);
@@ -103,23 +128,24 @@
         rampart_xml_sig_build_reference(env, signed_info_node, sign_part);
 
     }
-
-    /*Then construct the <SignatureMethod> , <CanonicalizationMethod> */
-
-    /*Finalize <SignedInfo>*/
+    /*Cannonicalize <SignedInfo>*/
+    
 
     /*Then serialize <SignedInfo>*/
-
+     
     /*Sign the data using the private key*/
-
-    /*Construct the <Signature> element*/
+    signature_val = "MC0CFFrVLtRlk=";
+    
+    /*Construct <SignatureValue>*/
+    signature_val_node = oxs_token_build_signature_value_element(env, signature_node, signature_val);
     
     return AXIS2_SUCCESS;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL 
 oxs_xml_sig_verify(const axis2_env_t *env,
-    oxs_sign_ctx_t *sign_ctx)
+    oxs_sign_ctx_t *sign_ctx,
+    axiom_node_t *signature_node)
 {
     return AXIS2_SUCCESS;
 }

Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_sec_header_processor.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_sec_header_processor.c?view=diff&rev=504797&r1=504796&r2=504797
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_sec_header_processor.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_sec_header_processor.c Wed Feb  7 21:47:50
2007
@@ -168,6 +168,9 @@
         axiom_node_t *envelope_node = NULL;
         oxs_ctx_t *ctx = NULL;
         axiom_node_t *decrypted_node = NULL; 
+        axiom_soap_body_t *soap_body = NULL;
+        /*This need to be called to build the SOAP Body. Not in use but DO NOT remove*/
+        soap_body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
 
         /*Get the i-th element and decrypt it */
         id = (axis2_char_t*)AXIS2_ARRAY_LIST_GET(reference_list, env, i);

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=504797&r1=504796&r2=504797
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Wed Feb  7 21:47:50 2007
@@ -26,11 +26,9 @@
 #include <oxs_ctx.h>
 #include <oxs_key.h>
 #include <oxs_error.h>
-#include <oxs_encryption.h>
-#include <oxs_xml_encryption.h>
-#include <oxs_token_encrypted_data.h>
-#include <oxs_x509_cert.h>
-
+#include <oxs_xml_signature.h>
+#include <oxs_sign_ctx.h>
+#include <oxs_sign_part.h>
 
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
 load_sample_xml(const axis2_env_t *env,
@@ -65,60 +63,15 @@
     return env;
 }
 
-oxs_key_t *create_key(axis2_env_t *env)
-{
-    oxs_key_t *key = NULL;
-    key = oxs_key_create(env);
-    OXS_KEY_POPULATE(key, env, (unsigned char*)"012345670123456701234567", "session_key",
 32, OXS_KEY_USAGE_DECRYPT);
-    return key;
-}
-
-axis2_status_t decrypt(axis2_env_t *env,  axis2_char_t *filename)
-{
-    oxs_ctx_t *ctx = NULL;
-    axiom_node_t *tmpl = NULL;
-    axiom_node_t *enc_data_node = NULL;
-    axiom_node_t *decrypted_node = NULL;
-    oxs_key_t *key = NULL;
-
-    tmpl = load_sample_xml(env , tmpl, filename);
-    axis2_status_t temp_status = AXIS2_FAILURE;
-    axis2_char_t *serialized_data = NULL;
-    FILE *outf;
-
-    /*Create key*/
-    key = create_key(env);
-
-    /*Create ctx*/
-    ctx = oxs_ctx_create(env);
-    OXS_CTX_SET_KEY(ctx, env, key);
-
-    /*Get the EncryptedData node*/
-    enc_data_node = AXIOM_NODE_GET_FIRST_CHILD(tmpl, env);
-    temp_status = oxs_xml_enc_decrypt_node(env, ctx, enc_data_node, &decrypted_node);
-
-    if (temp_status){
-        printf("\nooxs_xml_enc_decrypt_node SUCCESS\n");
-    }else{
-        printf("\noxs_xml_enc_decrypt_node FAILURE\n");
-    }
-    serialized_data = AXIOM_NODE_TO_STRING(tmpl, env);
-    outf = fopen("decrypted-result.xml", "wb");
-    fwrite(serialized_data, 1, AXIS2_STRLEN(serialized_data), outf);
-    fclose(outf);
-    return AXIS2_SUCCESS;
-}
-
 int main(int argc, char *argv[])
 {
     axis2_env_t *env = NULL;
     axis2_char_t *filename = "input.xml";
-    oxs_ctx_t *ctx = NULL;
-    oxs_key_t *key = NULL;
-    axis2_status_t temp_status = AXIS2_FAILURE;
-    axiom_node_t *tmpl = NULL, *enc_node = NULL, *enc_data_node = NULL;
-    axis2_char_t *encrypted_result = NULL;
-    axis2_char_t *id = NULL;
+    axis2_char_t *signed_result = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axiom_node_t *tmpl = NULL;
+    oxs_sign_part_t *sign_part = NULL;
+    oxs_sign_ctx_t *sign_ctx = NULL;
     FILE *outf;
 
     env = axis2_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
@@ -138,42 +91,18 @@
         printf("load_sample_xml FAILED");
         return -1;
     }
-    /*Create key*/
-    key = create_key(env);
-   
-    /*Create ctx*/
-    ctx = oxs_ctx_create(env);
-    OXS_CTX_SET_KEY(ctx, env, key);
-
-    /*Set algorithm*/
-    OXS_CTX_SET_ENC_MTD_ALGORITHM(ctx, env, OXS_HREF_DES3_CBC);
-
-    /*Get the node to be encrypted*/
-    enc_node = AXIOM_NODE_GET_FIRST_CHILD(tmpl, env);
-
-    /*Create a reference to encrypted node*/
-    id =  oxs_util_generate_id(env, OXS_ENCDATA_ID);
-    enc_data_node =  oxs_token_build_encrypted_data_element(env, tmpl, OXS_TYPE_ENC_ELEMENT,
id); 
-    /*Encrypt***************************************************/
-
-    temp_status = oxs_xml_enc_encrypt_node(env, ctx,  enc_node, &enc_data_node);
+    
+    /*Sign specific*/
+    sign_part = oxs_sign_part_create(env);
+    status = oxs_sign_part_set_node(sign_part, env, AXIOM_NODE_GET_FIRST_CHILD(tmpl, env));
 
-    if (temp_status)
-    {
-        printf("\noxs_enc_encrypt_template SUCCESS\n");
-    }
-    else
-    {
-        printf("\noxs_enc_encrypt_template FAILURE\n");
-    }
+    sign_ctx = oxs_sign_ctx_create(env);
 
-    encrypted_result = AXIOM_NODE_TO_STRING(tmpl, env) ;
-    /*printf("Final template is\n %s  ", encrypted_result);*/
+    
+    signed_result = AXIOM_NODE_TO_STRING(tmpl, env) ;
 
     outf = fopen("result.xml", "wb");
-    fwrite(encrypted_result, 1, AXIS2_STRLEN(encrypted_result), outf);
+    fwrite(signed_result, 1, AXIS2_STRLEN(signed_result), outf);
     fclose(outf);
-    /*Decrypt**********************************************/
-    decrypt(env, "result.xml");
     return 0;
 }



---------------------------------------------------------------------
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