Author: kaushalye
Date: Wed Jun 6 01:50:37 2007
New Revision: 544771
URL: http://svn.apache.org/viewvc?view=rev&rev=544771
Log:
Improving the encryption sample for OMXMLSec
Modified:
webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/Makefile.am
webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/enc.c
Modified: webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/Makefile.am
URL:
http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/Makefile.am?view=diff&rev=544771&r1=544770&r2=544771
==============================================================================
--- webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/Makefile.am (original)
+++ webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/Makefile.am Wed Jun 6
01:50:37 2007
@@ -3,19 +3,15 @@
enc_SOURCES = enc.c
-INCLUDES = -I $(AXIS2C_HOME)/include \
- -I ../../../include \
- -I ../../../util/include \
- -I ../../../axiom/include
+INCLUDES = -I $(AXIS2C_HOME)/include/axis2-1.0 \
+ -I ../../../include
-enc_LDADD = ../../../src/util/librampart_util.la \
+enc_LDADD = -laxutil \
+ -laxis2_axiom \
+ -lxml2 \
../../../src/omxmlsec/libomxmlsec.la \
../../../src/omxmlsec/openssl/libomopenssl.la \
- ../../../src/omxmlsec/tokens/liboxstokens.la \
- ../../../../util/src/libaxutil.la \
- ../../../../axiom/src/om/libaxis2_axiom.la \
- ../../../../axiom/src/parser/libxml2/libaxis2_libxml2.la \
- -lxml2
+ ../../../src/omxmlsec/tokens/liboxstokens.la
EXTRA_DIST = input.xml
Modified: webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/enc.c
URL:
http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/enc.c?view=diff&rev=544771&r1=544770&r2=544771
==============================================================================
--- webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/enc.c (original)
+++ webservices/rampart/trunk/c/samples/omxmlsec/xmlenc/enc.c Wed Jun 6
01:50:37 2007
@@ -51,6 +51,7 @@
if (!doc) printf("\n doc is NULL");
tmpl = axiom_document_build_all(doc, env);
+ axiom_xml_reader_xml_free(reader, env, NULL);
/* tmpl = axiom_document_get_root_element(doc, env);*/
if (!tmpl) printf("\n tmpl is NULL");
return tmpl;
@@ -61,7 +62,7 @@
{
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);
+ oxs_key_populate(key, env, (unsigned char*)"012345670123456701234567",
"session_key", 32, OXS_KEY_USAGE_DECRYPT);
return key;
}
@@ -84,7 +85,7 @@
/*Create ctx*/
ctx = oxs_ctx_create(env);
- OXS_CTX_SET_KEY(ctx, env, key);
+ oxs_ctx_set_key(ctx, env, key);
/*Get the EncryptedData node*/
enc_data_node = axiom_node_get_first_element(tmpl, env);
@@ -121,10 +122,10 @@
/*Create ctx*/
ctx = oxs_ctx_create(env);
- OXS_CTX_SET_KEY(ctx, env, key);
+ oxs_ctx_set_key(ctx, env, key);
/*Set algorithm*/
- OXS_CTX_SET_ENC_MTD_ALGORITHM(ctx, env, OXS_HREF_DES3_CBC);
+ oxs_ctx_set_enc_mtd_algorithm(ctx, env, OXS_HREF_DES3_CBC);
/*Get the node to be encrypted*/
enc_node = axiom_node_get_first_element(tmpl, env);
@@ -135,6 +136,8 @@
temp_status = oxs_xml_enc_encrypt_node(env, ctx, enc_node,
&enc_data_node);
+ oxs_ctx_free( ctx, env);
+
if (temp_status){
printf("\noxs_enc_encrypt_template SUCCESS\n");
}else{
@@ -147,6 +150,7 @@
fwrite(encrypted_result, 1, axutil_strlen(encrypted_result), outf);
fclose(outf);
printf("Node encrypted successfully. Result is written to result.xml\n");
+ axiom_document_free( axiom_node_get_document(tmpl, env), env);
return temp_status;
}