You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ka...@apache.org on 2006/11/29 06:40:27 UTC
svn commit: r480418 - in /webservices/axis2/trunk/c/rampart: include/
src/core/ src/omxmlsec/ src/omxmlsec/openssl/ src/omxmlsec/tokens/ src/util/
Author: kaushalye
Date: Tue Nov 28 21:40:24 2006
New Revision: 480418
URL: http://svn.apache.org/viewvc?view=rev&rev=480418
Log:
-Adding security token reference support for encryption
-Modified build to link to the token library
-Send key information using issuer name and the serial number of the certificate used to encrypt.
-Modification in the asymmetric encryption context to store the password for key store.
Added:
webservices/axis2/trunk/c/rampart/include/oxs_token_security_token_reference.h
webservices/axis2/trunk/c/rampart/include/oxs_token_x509_data.h
webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_security_token_reference.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_data.c
Modified:
webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h
webservices/axis2/trunk/c/rampart/include/oxs_constants.h
webservices/axis2/trunk/c/rampart/include/oxs_key_mgr.h
webservices/axis2/trunk/c/rampart/include/oxs_token_x509_issuer_serial.h
webservices/axis2/trunk/c/rampart/src/core/Makefile.am
webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/x509.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am
webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_issuer_serial.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c
webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c
Modified: webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h Tue Nov 28 21:40:24 2006
@@ -73,6 +73,10 @@
oxs_asym_ctx_get_file_name(const oxs_asym_ctx_t *ctx,
const axis2_env_t *env);
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_asym_ctx_get_password(const oxs_asym_ctx_t *ctx,
+ const axis2_env_t *env);
+
AXIS2_EXTERN oxs_asym_ctx_format_t AXIS2_CALL
oxs_asym_ctx_get_format(const oxs_asym_ctx_t *ctx,
const axis2_env_t *env);
@@ -97,6 +101,11 @@
oxs_asym_ctx_set_file_name(oxs_asym_ctx_t *ctx,
const axis2_env_t *env,
axis2_char_t *file_name);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_password(oxs_asym_ctx_t *ctx,
+ const axis2_env_t *env,
+ axis2_char_t *password);
AXIS2_EXTERN axis2_status_t AXIS2_CALL
oxs_asym_ctx_set_format(oxs_asym_ctx_t *ctx,
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=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_constants.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_constants.h Tue Nov 28 21:40:24 2006
@@ -93,6 +93,7 @@
****************************************************************/
#define OXS_NODE_BINARY_SECURITY_TOKEN "BinarySecurityToken"
#define OXS_NODE_KEY_IDENTIFIER "KeyIdentifier"
+#define OXS_NODE_SECURITY_TOKEN_REFRENCE "SecurityTokenReference"
/****************************************************************
Modified: webservices/axis2/trunk/c/rampart/include/oxs_key_mgr.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_key_mgr.h?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_key_mgr.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_key_mgr.h Tue Nov 28 21:40:24 2006
@@ -40,7 +40,8 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
oxs_key_mgr_load_key(const axis2_env_t *env,
- oxs_asym_ctx_t *ctx);
+ oxs_asym_ctx_t *ctx,
+ axis2_char_t *password);
/** @} */
#ifdef __cplusplus
Added: webservices/axis2/trunk/c/rampart/include/oxs_token_security_token_reference.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_security_token_reference.h?view=auto&rev=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_security_token_reference.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_security_token_reference.h Tue Nov 28 21:40:24 2006
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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_TOKEN_SECURITY_TOKEN_REFERENCE
+#define OXS_TOKEN_SECURITY_TOKEN_REFERENCE
+
+
+/**
+ * @file
+ * @brief
+ */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_qname.h>
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_security_token_reference_element(const axis2_env_t *env,
+ axiom_node_t *parent);
+
+
+/*TODO write free method*/
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OXS_TOKEN_SECURITY_TOKEN_REFERENCE */
Added: webservices/axis2/trunk/c/rampart/include/oxs_token_x509_data.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_x509_data.h?view=auto&rev=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_x509_data.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_x509_data.h Tue Nov 28 21:40:24 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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_TOKEN_X509_DATA_H
+#define OXS_TOKEN_X509_DATA_H
+
+
+/**
+ * @file
+ * @brief
+ */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_qname.h>
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+* X509Data element
+*/
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_x509_data_element(const axis2_env_t *env,
+ axiom_node_t *parent);
+
+/*TODO write free method*/
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OXS_TOKEN_X509_DATA_H */
Modified: webservices/axis2/trunk/c/rampart/include/oxs_token_x509_issuer_serial.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_x509_issuer_serial.h?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_x509_issuer_serial.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_x509_issuer_serial.h Tue Nov 28 21:40:24 2006
@@ -37,6 +37,12 @@
* X509Data element
*/
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_x509_issuer_serial_with_data(const axis2_env_t *env,
+ axiom_node_t *parent,
+ axis2_char_t *issuer_name,
+ axis2_char_t *serial_number);
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
oxs_token_build_x509_issuer_serial_element(const axis2_env_t *env,
axiom_node_t *parent);
Modified: webservices/axis2/trunk/c/rampart/src/core/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/core/Makefile.am?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/core/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/core/Makefile.am Tue Nov 28 21:40:24 2006
@@ -8,6 +8,7 @@
libmod_rampart_la_LIBADD = ../handlers/librampart_handlers.la \
../util/librampart_util.la \
../omxmlsec/libomxmlsec.la \
+ ../omxmlsec/tokens/liboxstokens.la \
../omxmlsec/openssl/libomopenssl.la
INCLUDES = -I$(top_builddir)/include \
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c Tue Nov 28 21:40:24 2006
@@ -23,6 +23,7 @@
struct oxs_asym_ctx_t
{
axis2_char_t *file_name;
+ axis2_char_t *password;
axis2_char_t *algorithm;
oxs_asym_ctx_operation_t operation;
oxs_asym_ctx_format_t format;
@@ -31,7 +32,7 @@
};
-/*private functions*/
+/*Public functions*/
axis2_char_t *AXIS2_CALL
oxs_asym_ctx_get_file_name(
@@ -41,6 +42,13 @@
return asym_ctx->file_name;
}
+axis2_char_t *AXIS2_CALL
+oxs_asym_ctx_get_password(
+ const oxs_asym_ctx_t *asym_ctx,
+ const axis2_env_t *env)
+{
+ return asym_ctx->password;
+}
oxs_asym_ctx_format_t AXIS2_CALL
oxs_asym_ctx_get_format(
const oxs_asym_ctx_t *asym_ctx,
@@ -100,6 +108,22 @@
}
axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_password(
+ oxs_asym_ctx_t *asym_ctx,
+ const axis2_env_t *env,
+ axis2_char_t *password)
+{
+
+ if (asym_ctx->password)
+ {
+ AXIS2_FREE(env->allocator, asym_ctx->password);
+ asym_ctx->password = NULL;
+ }
+ asym_ctx->password = AXIS2_STRDUP(password, env);
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
oxs_asym_ctx_set_format(
oxs_asym_ctx_t *asym_ctx,
const axis2_env_t *env,
@@ -186,6 +210,7 @@
}
asym_ctx->file_name= NULL;
+ asym_ctx->password= NULL;
asym_ctx->format= -1;
asym_ctx->algorithm = NULL;
asym_ctx->operation = -1;
@@ -206,6 +231,12 @@
{
AXIS2_FREE(env->allocator, asym_ctx->file_name);
asym_ctx->file_name = NULL;
+ }
+
+ if (asym_ctx->password)
+ {
+ AXIS2_FREE(env->allocator, asym_ctx->password);
+ asym_ctx->password = NULL;
}
if (asym_ctx->algorithm)
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c Tue Nov 28 21:40:24 2006
@@ -162,12 +162,14 @@
openssl_rsa_t *rsa = NULL;
oxs_asym_ctx_operation_t operation = -1;
axis2_status_t status = AXIS2_FAILURE;
-
+ axis2_char_t *password = NULL;
+
/*TODO We support RSA encryption only. If any other algorithm is specified, reject*/
/*Load the key using key manager*/
- status = oxs_key_mgr_load_key(env, ctx);
+ password = oxs_asym_ctx_get_password(ctx, env);
+ status = oxs_key_mgr_load_key(env, ctx, password);
#if 0
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=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/key_mgr.c Tue Nov 28 21:40:24 2006
@@ -21,10 +21,10 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
oxs_key_mgr_load_key(const axis2_env_t *env,
- oxs_asym_ctx_t *ctx)
+ oxs_asym_ctx_t *ctx,
+ axis2_char_t *password)
{
axis2_char_t *filename = NULL;
- axis2_char_t *password = "1234";
axis2_status_t status = AXIS2_FAILURE;
openssl_x509_format_t format;
openssl_pkey_t *open_prvkey = NULL;
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/x509.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/x509.c?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/x509.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/x509.c Tue Nov 28 21:40:24 2006
@@ -27,6 +27,7 @@
#include <openssl_pkcs12.h>
#include <openssl_x509.h>
+/*Usefull when we have BinarySecurityTokn*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
openssl_x509_load_from_buffer(const axis2_env_t *env,
axis2_char_t *b64_encoded_buf,
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am Tue Nov 28 21:40:24 2006
@@ -4,7 +4,7 @@
token_cipher_data.c token_key_name.c token_key_info.c token_binary_security_token.c \
token_reference_list.c token_data_reference.c token_encrypted_key.c \
token_key_identifier.c token_x509_data.c token_x509_issuer_serial.c\
- token_x509_issuer_name.c token_x509_serial_number.c
+ token_x509_issuer_name.c token_x509_serial_number.c token_security_token_reference.c
liboxstokens_la_LIBADD =../../../../util/src/libaxis2_util.la \
../../../../axiom/src/om/libaxis2_axiom.la
Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_security_token_reference.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_security_token_reference.c?view=auto&rev=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_security_token_reference.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_security_token_reference.c Tue Nov 28 21:40:24 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed 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 <oxs_constants.h>
+#include <oxs_error.h>
+#include <oxs_token_security_token_reference.h>
+#include <axiom_attribute.h>
+#include <axiom_element.h>
+
+/*TODO These names should be changed to oxs_token_build_XXX_node*/
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_security_token_reference_element(const axis2_env_t *env,
+ axiom_node_t *parent)
+{
+ axiom_node_t *security_token_reference_node = NULL;
+ axiom_element_t *security_token_reference_ele = NULL;
+ axiom_namespace_t *ns_obj = NULL;
+
+ ns_obj = axiom_namespace_create(env, OXS_WSSE_NS,
+ OXS_WSSE);
+
+ security_token_reference_ele = axiom_element_create(env, parent, OXS_NODE_SECURITY_TOKEN_REFRENCE, ns_obj, &security_token_reference_node);
+ if (!security_token_reference_ele)
+ {
+ oxs_error(ERROR_LOCATION,
+ OXS_ERROR_ELEMENT_FAILED, "Error creating SecurityTokenReference element");
+ return NULL;
+ }
+
+ return security_token_reference_node;
+}
+
+
Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_data.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_data.c?view=auto&rev=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_data.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_data.c Tue Nov 28 21:40:24 2006
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed 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 <oxs_constants.h>
+#include <oxs_error.h>
+#include <oxs_token_x509_data.h>
+#include <axiom_element.h>
+
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_x509_data_element(const axis2_env_t *env,
+ axiom_node_t *parent)
+{
+ axiom_node_t *x509_data_node = NULL;
+ axiom_element_t *x509_data_ele = NULL;
+ axiom_namespace_t *ns_obj = NULL;
+
+ ns_obj = axiom_namespace_create(env, OXS_DSIG_NS,
+ OXS_DS);
+
+
+ x509_data_ele = axiom_element_create(env, parent, OXS_NODE_X509_DATA, ns_obj, &x509_data_node);
+ if (!x509_data_ele)
+ {
+ oxs_error(ERROR_LOCATION,
+ OXS_ERROR_ELEMENT_FAILED, "Error creating X509Data element");
+ return NULL;
+ }
+
+ return x509_data_node;
+}
+
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_issuer_serial.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_issuer_serial.c?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_issuer_serial.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_issuer_serial.c Tue Nov 28 21:40:24 2006
@@ -18,8 +18,31 @@
#include <oxs_constants.h>
#include <oxs_error.h>
#include <oxs_token_x509_issuer_serial.h>
+#include <oxs_token_x509_issuer_name.h>
+#include <oxs_token_x509_serial_number.h>
#include <axiom_element.h>
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_x509_issuer_serial_with_data(const axis2_env_t *env,
+ axiom_node_t *parent,
+ axis2_char_t *issuer_name,
+ axis2_char_t *serial_number)
+{
+ axiom_node_t *x509_issuer_serial_node = NULL;
+ axiom_node_t *x509_issuer_name_node = NULL;
+ axiom_node_t *x509_serial_number_node = NULL;
+
+ x509_issuer_serial_node = oxs_token_build_x509_issuer_serial_element(env, parent);
+ if(issuer_name){
+ x509_issuer_name_node = oxs_token_build_issuer_name_element(env, x509_issuer_serial_node, issuer_name);
+ }
+ if(serial_number){
+ x509_serial_number_node = oxs_token_build_serial_number_element(env, x509_issuer_serial_node, serial_number);
+ }
+ return x509_issuer_serial_node;
+
+}
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
oxs_token_build_x509_issuer_serial_element(const axis2_env_t *env,
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c Tue Nov 28 21:40:24 2006
@@ -27,6 +27,8 @@
#include <oxs_token_reference_list.h>
#include <oxs_token_key_info.h>
#include <oxs_token_key_identifier.h>
+#include <oxs_token_x509_issuer_serial.h>
+#include <oxs_token_security_token_reference.h>
#include <oxs_constants.h>
#include <oxs_axiom.h>
#include <oxs_ctx.h>
@@ -38,7 +40,31 @@
#include <oxs_xml_encryption.h>
/*private functions*/
+static axis2_status_t
+oxs_xml_enc_populate_stref_with_issuer_serial(const axis2_env_t *env,
+ oxs_asym_ctx_t *asym_ctx,
+ axiom_node_t *stref_node)
+{
+ axiom_node_t *issuer_serial_node = NULL;
+ oxs_x509_cert_t *cert = NULL;
+ axis2_char_t *issuer_name = NULL;
+ axis2_char_t serial_number[255];
+ int serial = -1;
+
+ /*Get binary securty token data to be set to the KeyIdentifierNode*/
+ cert = oxs_asym_ctx_get_certificate(asym_ctx, env);
+
+ issuer_name = oxs_x509_cert_get_issuer(cert, env);
+ serial = oxs_x509_cert_get_serial_number(cert, env);
+ if((!issuer_name) || (serial<0)){
+ return AXIS2_FAILURE;
+ }
+ sprintf(serial_number, "%d", serial);
+
+ issuer_serial_node = oxs_token_build_x509_issuer_serial_with_data(env, stref_node, issuer_name, serial_number);
+ return AXIS2_SUCCESS;
+}
/*public functions*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -195,16 +221,15 @@
{
axis2_char_t *algorithm = NULL;
axis2_char_t *encrypted_key_data = NULL;
- axis2_char_t *bst_data = NULL;
oxs_buffer_t *input = NULL;
oxs_buffer_t *result = NULL;
axiom_node_t *encrypted_key_node = NULL;
axiom_node_t *enc_mtd_node = NULL;
- axiom_node_t *kifier_node = NULL;
+ axiom_node_t *key_info_node = NULL;
+ axiom_node_t *stref_node = NULL;
axiom_node_t *cd_node = NULL;
axiom_node_t *cv_node = NULL;
axis2_status_t status = AXIS2_FAILURE;
- oxs_x509_cert_t *cert = NULL;
/*Create input buffer*/
input = oxs_buffer_create(env);
@@ -219,23 +244,25 @@
/*Get the encrypted key*/
encrypted_key_data = (axis2_char_t *)OXS_BUFFER_GET_DATA(result, env);
- /*Get binary securty token data to be set to the KeyIdentifierNode*/
- cert = oxs_asym_ctx_get_certificate(asym_ctx, env);
- bst_data = oxs_x509_cert_get_data(cert, env);
-
/*Build nodes*/
encrypted_key_node = oxs_token_build_encrypted_key_element(env, parent);
algorithm = oxs_asym_ctx_get_algorithm(asym_ctx, env);
enc_mtd_node = oxs_token_build_encryption_method_element(env, encrypted_key_node, algorithm);
- kifier_node = oxs_token_build_key_identifier_element(env, encrypted_key_node, OXS_ENCODING_BASE64BINARY, OXS_VALUE_X509V3, bst_data);
- cd_node = oxs_token_build_cipher_data_element(env, encrypted_key_node);
- cv_node = oxs_token_build_cipher_value_element(env, cd_node, encrypted_key_data);
+ key_info_node = oxs_token_build_key_info_element(env, encrypted_key_node);
+ stref_node = oxs_token_build_security_token_reference_element(env, key_info_node);
+ status = oxs_xml_enc_populate_stref_with_issuer_serial(env, asym_ctx, stref_node);
+ if(AXIS2_SUCCESS!=status){
+ return AXIS2_FAILURE;
+ }
- /*TODO SecurityTokenReference*/
+ cd_node = oxs_token_build_cipher_data_element(env, encrypted_key_node);
+ cv_node = oxs_token_build_cipher_value_element(env, cd_node, encrypted_key_data);
oxs_token_build_data_reference_list(env, encrypted_key_node, id_list);
+
return AXIS2_SUCCESS;
}
+
/**
* Inspect the key node. Then populate the sym_key
*/
Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c?view=diff&rev=480418&r1=480417&r2=480418
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c Tue Nov 28 21:40:24 2006
@@ -119,6 +119,7 @@
asym_ctx = oxs_asym_ctx_create(env);
oxs_asym_ctx_set_algorithm(asym_ctx, env, enc_asym_algo);
oxs_asym_ctx_set_file_name(asym_ctx, env, certificate_file);
+ oxs_asym_ctx_set_password(asym_ctx, env, "1234");
oxs_asym_ctx_set_operation(asym_ctx, env, OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT);
/*TODO This should be taken from the configurations*/
oxs_asym_ctx_set_format(asym_ctx, env, OXS_ASYM_CTX_FORMAT_PKCS12);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org