axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kausha...@apache.org
Subject svn commit: r474165 - in /webservices/axis2/trunk/c/rampart: include/ src/handlers/ src/omxmlsec/ src/util/ test/omxmlsec/
Date Mon, 13 Nov 2006 06:04:57 GMT
Author: kaushalye
Date: Sun Nov 12 22:04:56 2006
New Revision: 474165

URL: http://svn.apache.org/viewvc?view=rev&rev=474165
Log:
Comititng following changes
1. Introducing rampart_encryption : Handles en/decrypting soap messages.
2. Introducing oxs_asym_ctx : Encapsulates information related to assymetric en/decryption.
3. Introducing certificate : Encapsulates x509 certificate related information. 
4. Changes made to rampart action to support asymmetric encryption.
5. Introducing new features to the OMXMLSec to encrypt a session key.
6. Removed rampart_crypto engine from the Makefile - No longer in use. Will delete it from the svn later.


Added:
    webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h
    webservices/axis2/trunk/c/rampart/include/oxs_certificate.h
    webservices/axis2/trunk/c/rampart/include/rampart_encryption.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/certificate.c
    webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c
Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_encryption.h
    webservices/axis2/trunk/c/rampart/include/oxs_token_key_info.h
    webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h
    webservices/axis2/trunk/c/rampart/include/rampart_action.h
    webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
    webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am
    webservices/axis2/trunk/c/rampart/src/omxmlsec/ctx.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c
    webservices/axis2/trunk/c/rampart/src/util/Makefile.am
    webservices/axis2/trunk/c/rampart/src/util/rampart_action.c
    webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c

Added: 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=auto&rev=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_asym_ctx.h Sun Nov 12 22:04:56 2006
@@ -0,0 +1,179 @@
+/*
+ * 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_ASYM_CTX_H
+#define OXS_ASYM_CTX_H
+
+
+/**
+  * @file oxs_asym_ctx.h
+  * @brief 
+  */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <oxs_certificate.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** @defgroup oxs_asym_ctx Message Context 
+ * @ingroup 
+ * @{
+ */
+
+
+    typedef enum  {
+        OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT,
+        OXS_ASYM_CTX_OPERATION_PRV_DECRYPT,
+        OXS_ASYM_CTX_OPERATION_PUB_DECRYPT,
+        OXS_ASYM_CTX_OPERATION_PRV_ENCRYPT
+    }oxs_asym_ctx_operation_t;
+
+    /** Type name for struct oxs_asym_ctx_ops */
+    typedef struct oxs_asym_ctx_ops oxs_asym_ctx_ops_t;
+    /** Type name for struct oxs_asym_ctx */
+    typedef struct oxs_asym_ctx oxs_asym_ctx_t;
+
+    struct oxs_asym_ctx_ops
+    {
+
+        axis2_status_t (AXIS2_CALL *
+        free)(
+                    oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env
+                    );
+
+        oxs_asym_ctx_operation_t (AXIS2_CALL *
+        get_operation)(
+                    const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env
+                    );
+
+
+        axis2_char_t *(AXIS2_CALL *
+        get_file_name)(
+                    const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env
+                    );
+
+        oxs_certificate_t *(AXIS2_CALL *
+        get_certificate)(
+                    const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env
+                    );
+
+        axis2_char_t *(AXIS2_CALL *
+        get_algorithm)(
+                    const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env
+                    );
+
+        axis2_status_t (AXIS2_CALL *
+        set_operation)(
+                    oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    oxs_asym_ctx_operation_t operation
+                    );
+
+        axis2_status_t (AXIS2_CALL *
+        set_file_name)(
+                    oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    axis2_char_t *file_name
+                    );
+
+        axis2_status_t (AXIS2_CALL *
+        set_certificate)(
+                    oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    oxs_certificate_t *cert
+                    );
+
+
+        axis2_status_t (AXIS2_CALL *
+        set_algorithm)(
+                    oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    axis2_char_t *enc_algorithm
+                    );
+
+
+    };
+    
+    struct oxs_asym_ctx
+    {
+        /** operations of oxs_asym_ctx */
+        oxs_asym_ctx_ops_t *ops;
+    };
+
+    /*Create function*/
+    AXIS2_EXTERN oxs_asym_ctx_t *AXIS2_CALL
+    oxs_asym_ctx_create(const axis2_env_t *env);
+
+
+/**********************Wrappers******************************************/
+   
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_free(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+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_algorithm(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN oxs_asym_ctx_operation_t AXIS2_CALL
+oxs_asym_ctx_get_operation(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN oxs_certificate_t* AXIS2_CALL
+oxs_asym_ctx_get_certificate(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+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_algorithm(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    axis2_char_t *algorithm);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_operation(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    oxs_asym_ctx_operation_t operation);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_certificate(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    oxs_certificate_t *certificate);
+
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* OXS_ASYM_CTX_H */

Added: webservices/axis2/trunk/c/rampart/include/oxs_certificate.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_certificate.h?view=auto&rev=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_certificate.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_certificate.h Sun Nov 12 22:04:56 2006
@@ -0,0 +1,176 @@
+/*
+ * 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_CERTIFICATE_H
+#define OXS_CERTIFICATE_H
+
+
+/**
+  * @file oxs_certificate.h
+  * @brief 
+  */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <oxs_certificate.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** @defgroup oxs_certificate 
+ * @ingroup 
+ * @{
+ */
+
+
+    /**
+     * Serial number
+     * Subject
+     * Issuer
+     * Data
+     */
+    /** Type name for struct  oxs_certificate_ops */
+    typedef struct oxs_certificate_ops oxs_certificate_ops_t;
+
+    /** Type name for struct oxs_certificate */
+    typedef struct oxs_certificate oxs_certificate_t;
+
+    struct oxs_certificate_ops
+    {
+
+        axis2_status_t (AXIS2_CALL *
+        free)(
+                    oxs_certificate_t *certificate,
+                    const axis2_env_t *env
+                    );
+
+        axis2_char_t *(AXIS2_CALL *
+        get_serial_number)(
+                    const oxs_certificate_t *certificate,
+                    const axis2_env_t *env
+                    );
+
+        axis2_char_t *(AXIS2_CALL *
+        get_subject)(
+                    const oxs_certificate_t *certificate,
+                    const axis2_env_t *env
+                    );
+
+        axis2_char_t *(AXIS2_CALL *
+        get_issuer)(
+                    const oxs_certificate_t *certificate,
+                    const axis2_env_t *env
+                    );
+
+        axis2_char_t *(AXIS2_CALL *
+        get_data)(
+                    const oxs_certificate_t *certificate,
+                    const axis2_env_t *env
+                    );
+
+        axis2_status_t (AXIS2_CALL *
+        set_serial_number)(
+                    oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *serial_number
+                    );
+
+        axis2_status_t (AXIS2_CALL *
+        set_issuer)(
+                    oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *issuer
+                    );
+
+        axis2_status_t (AXIS2_CALL *
+        set_subject)(
+                    oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *subject
+                    );
+
+
+        axis2_status_t (AXIS2_CALL *
+        set_data)(
+                    oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *data
+                    );
+
+    };
+    
+    struct oxs_certificate
+    {
+        /** operations of oxs_certificate */
+        oxs_certificate_ops_t *ops;
+    };
+
+    /*Create function*/
+    AXIS2_EXTERN oxs_certificate_t *AXIS2_CALL
+    oxs_certificate_create(const axis2_env_t *env);
+
+
+/**********************Wrappers******************************************/
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_free(oxs_certificate_t *certificate,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_serial_number(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_subject(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_issuer(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_data(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_serial_number(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *serial_number);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_subject(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *subject);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_issuer(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *issuer);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_data(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *data);
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* OXS_CERTIFICATE_H */

Modified: webservices/axis2/trunk/c/rampart/include/oxs_encryption.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_encryption.h?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_encryption.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_encryption.h Sun Nov 12 22:04:56 2006
@@ -25,6 +25,7 @@
 
 #include <axis2_defines.h>
 #include <oxs_ctx.h>
+#include <oxs_asym_ctx.h>
 #include <axis2_env.h>
 #include <axiom_node.h>
 #include <axiom_element.h>
@@ -41,7 +42,11 @@
     oxs_buffer_t *input,
     oxs_buffer_t *result);
 
-
+AXIS2_EXTERN  axis2_status_t AXIS2_CALL
+oxs_encryption_asymmetric_crypt(const axis2_env_t *env,
+    oxs_asym_ctx_t * enc_ctx,
+    oxs_buffer_t *input,
+    oxs_buffer_t *result);
 /** @} */
 #ifdef __cplusplus
 }

Modified: webservices/axis2/trunk/c/rampart/include/oxs_token_key_info.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_key_info.h?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_key_info.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_key_info.h Sun Nov 12 22:04:56 2006
@@ -36,7 +36,7 @@
 /**
 * KeyInfo element
 */
-AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
 oxs_token_build_key_info_element(const axis2_env_t *env,
                         axiom_node_t *parent
                     );

Modified: webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h Sun Nov 12 22:04:56 2006
@@ -35,29 +35,35 @@
 {
 #endif
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_xml_enc_encrypt_node(const axis2_env_t *env,
                             oxs_ctx_t * enc_ctx,
                             axiom_node_t *node,
                             axiom_node_t **enc_type_node);
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_xml_enc_decrypt_node(const axis2_env_t *env,
                             oxs_ctx_t * enc_ctx,
                             axiom_node_t *enc_type_node,
                             axiom_node_t **decrypted_node);
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_xml_enc_encrypt_data(const axis2_env_t *env,
                             oxs_ctx_t * enc_ctx,
                             oxs_buffer_t *content_buf,
                             axiom_node_t **enc_type_node);
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_xml_enc_decrypt_data(const axis2_env_t *env,
                             oxs_ctx_t * enc_ctx,
                             axiom_node_t *enc_type_node,
                             oxs_buffer_t *result_buf);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_xml_enc_encrypt_key(const axis2_env_t *env,
+                            oxs_asym_ctx_t * asym_ctx,
+                            axiom_node_t *parent,
+                            oxs_key_t *sym_key);
 /** @} */
 #ifdef __cplusplus
 }

Modified: webservices/axis2/trunk/c/rampart/include/rampart_action.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart_action.h?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart_action.h (original)
+++ webservices/axis2/trunk/c/rampart/include/rampart_action.h Sun Nov 12 22:04:56 2006
@@ -167,25 +167,25 @@
                     );
 
         /**
-        * Gets encryption_prop_file of the rampart action.
+        * Gets encryption_key_file of the rampart action.
         * @param actions rampart_action ptr to action
         * @param env pointer to environment struct
-        * @return encryption_prop_file
+        * @return encryption_key_file
         */
         axis2_char_t *(AXIS2_CALL *
-        get_encryption_prop_file )(
+        get_encryption_key_file )(
                     rampart_actions_t *actions,
                     const axis2_env_t *env
                     );
 
         /**
-        * Gets decryption_prop_file of the rampart action.
+        * Gets decryption_key_file of the rampart action.
         * @param actions rampart_action ptr to action
         * @param env pointer to environment struct
-        * @return decryption_prop_file
+        * @return decryption_key_file
         */
         axis2_char_t *(AXIS2_CALL *
-        get_decryption_prop_file )(
+        get_decryption_key_file )(
                     rampart_actions_t *actions,
                     const axis2_env_t *env
                     );
@@ -362,31 +362,31 @@
                     );
         
         /**
-        * Sets encryption_prop_file of the rampart action.
+        * Sets encryption_key_file of the rampart action.
         * @param actions rampart_action ptr to action
         * @param env pointer to environment struct
-        * @param encryption_prop_file
+        * @param encryption_key_file
         * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
         */
         axis2_status_t (AXIS2_CALL *
-        set_encryption_prop_file)(
+        set_encryption_key_file)(
                     rampart_actions_t *actions,
                     const axis2_env_t *env,
-                    axis2_char_t *encryption_prop_file
+                    axis2_char_t *encryption_key_file
                     );
 
         /**
-        * Sets decryption_prop_file of the rampart action.
+        * Sets decryption_key_file of the rampart action.
         * @param actions rampart_action ptr to action
         * @param env pointer to environment struct
-        * @param decryption_prop_file
+        * @param decryption_key_file
         * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
         */
         axis2_status_t (AXIS2_CALL *
-        set_decryption_prop_file)(
+        set_decryption_key_file)(
                     rampart_actions_t *actions,
                     const axis2_env_t *env,
-                    axis2_char_t *decryption_prop_file
+                    axis2_char_t *decryption_key_file
                     );
 
         /**
@@ -579,17 +579,17 @@
 #define RAMPART_ACTIONS_SET_PW_CB_CLASS(actions, env, password_callback_class)\
         ((actions)->ops->set_password_callback_class(actions, env,password_callback_class ))
 
-#define RAMPART_ACTIONS_GET_ENC_PROP_FILE(actions, env) \
-        ((actions)->ops->get_encryption_prop_file(actions, env) )
+#define RAMPART_ACTIONS_GET_ENC_KEY_FILE(actions, env) \
+        ((actions)->ops->get_encryption_key_file(actions, env) )
 
-#define RAMPART_ACTIONS_SET_ENC_PROP_FILE(actions, env, encryption_prop_file)\
-        ((actions)->ops->set_encryption_prop_file(actions, env, encryption_prop_file))
+#define RAMPART_ACTIONS_SET_ENC_KEY_FILE(actions, env, encryption_key_file)\
+        ((actions)->ops->set_encryption_key_file(actions, env, encryption_key_file))
 
-#define RAMPART_ACTIONS_GET_DEC_PROP_FILE(actions, env) \
-        ((actions)->ops->get_decryption_prop_file(actions, env) )
+#define RAMPART_ACTIONS_GET_DEC_KEY_FILE(actions, env) \
+        ((actions)->ops->get_decryption_key_file(actions, env) )
 
-#define RAMPART_ACTIONS_SET_DEC_PROP_FILE(actions, env, decryption_prop_file)\
-        ((actions)->ops->set_decryption_prop_file(actions, env, decryption_prop_file))
+#define RAMPART_ACTIONS_SET_DEC_KEY_FILE(actions, env, decryption_key_file)\
+        ((actions)->ops->set_decryption_key_file(actions, env, decryption_key_file))
 
 #define RAMPART_ACTIONS_GET_SIG_PROP_FILE(actions, env) \
         ((actions)->ops->get_signature_prop_file(actions, env) )

Added: webservices/axis2/trunk/c/rampart/include/rampart_encryption.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart_encryption.h?view=auto&rev=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart_encryption.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart_encryption.h Sun Nov 12 22:04:56 2006
@@ -0,0 +1,71 @@
+/*
+ *   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 <axis2_utils_defines.h>
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_soap.h>
+#include <axis2_msg_ctx.h>
+#include <rampart_action.h>
+
+/**
+  * @file rampart_encryption.h
+  * @brief 
+  */
+#ifndef RAMPART_ENCRYPTION_H
+#define RAMPART_ENCRYPTION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @param env pointer to environment struct
+* @param msg_ctx message context
+* @param actions actions defined in the descriptor file
+* @param soap_envelope the SOAP envelope
+* @param sec_node The security element
+* @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+*/
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_enc_encrypt_message(const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+    rampart_actions_t *actions,
+    axiom_soap_envelope_t *soap_envelope,
+    axiom_node_t *sec_node);
+
+
+/**
+* @param env pointer to environment struct
+* @param msg_ctx message context
+* @param actions actions defined in the descriptor file
+* @param soap_envelope the SOAP envelope
+* @param sec_node The security element
+* @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+*/
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_enc_decrypt_message(const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+    rampart_actions_t *actions,
+    axiom_soap_envelope_t *soap_envelope,
+    axiom_node_t *sec_node);
+
+/* @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* !RAMPART_ENCRYPTION_H */

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=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c (original)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c Sun Nov 12 22:04:56 2006
@@ -29,7 +29,6 @@
 #include <rampart_handler_util.h>
 #include <rampart_timestamp_token.h>
 #include <rampart_util.h>
-#include <rampart_crypto_engine.h>
 
 /*************************** Function headers *********************************/
 
@@ -74,7 +73,6 @@
     axis2_char_t *items = NULL;
     axiom_node_t *sec_node, *ts_node = NULL;
     axiom_element_t *sec_ele, *ts_ele = NULL;
-    axis2_status_t enc_status = AXIS2_FAILURE;
     rampart_actions_t *actions = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -215,32 +213,8 @@
                 else if (0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_ENCRYPT, AXIS2_STRTRIM(env, item, NULL)))
                 {
                     /*Do useful to verify encrypt*/
+                    AXIS2_LOG_INFO(env->log, "[rampart][rampart_in_handler] Decryption... NOT IMPLEMENTED YET.. SORRY");
 
-                    rampart_crypto_engine_t *engine = NULL;
-                    AXIS2_LOG_INFO(env->log, "[rampart][rampart_in_handler] Decrypting message");
-
-                    engine = rampart_crypto_engine_create(env);
-                    enc_status = RAMPART_CRYPTO_ENGINE_DECRYPT_MESSAGE(engine, env, msg_ctx, actions, soap_envelope, sec_node);
-
-                    RAMPART_CRYPTO_ENGINE_FREE(engine, env);
-                    if (enc_status == AXIS2_SUCCESS)
-                    {
-                        status = AXIS2_SUCCESS;
-                    }
-                    else
-                    {
-                        axis2_array_list_t *sub_codes = NULL;
-                        sub_codes = axis2_array_list_create(env, 1);
-                        if (sub_codes)
-                        {
-                            AXIS2_ARRAY_LIST_ADD(sub_codes, env, RAMPART_FAULT_FAILED_AUTHENTICATION);
-                        }
-                        AXIS2_LOG_INFO(env->log, "[rampart][rampart_in_handler] Decryption FAILED");
-
-                        rampart_create_fault_envelope(env, "wsse:FailedCheck",
-                                "Decryption failed. Hej kau complete this", sub_codes, msg_ctx);
-                        return AXIS2_FAILURE;
-                    }
 
                     /*Signature*/
                 }

Modified: webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c (original)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c Sun Nov 12 22:04:56 2006
@@ -26,7 +26,6 @@
 #include <rampart_username_token.h>
 #include <rampart_handler_util.h>
 #include <rampart_timestamp_token.h>
-#include <rampart_crypto_engine.h>
 #include <rampart_action.h>
 
 /*********************** Function headers *********************************/
@@ -99,7 +98,6 @@
     axis2_array_list_t *action_list = NULL;
     axis2_param_t *param_action = NULL;
     axis2_char_t *items = NULL;
-    axis2_status_t enc_status = AXIS2_FAILURE;
     rampart_actions_t *actions = NULL;
     axis2_status_t status = AXIS2_FAILURE;
 
@@ -266,24 +264,8 @@
                 else if (0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_ENCRYPT,
                         AXIS2_STRTRIM(env, item, NULL)))
                 {
-                    rampart_crypto_engine_t *engine = NULL;
-
-                    AXIS2_LOG_INFO(env->log, "[rampart][rampart_out_handler] Encrypting message");
-                    engine = rampart_crypto_engine_create(env);
-
-                    enc_status = RAMPART_CRYPTO_ENGINE_ENCRYPT_MESSAGE(engine, env, msg_ctx, actions, soap_envelope, sec_node);
-
-                    RAMPART_CRYPTO_ENGINE_FREE(engine, env);
-
-                    if (enc_status != AXIS2_SUCCESS)
-                    {
-                        AXIS2_LOG_INFO(env->log, "[rampart][rampart_out_handler] Encryption failed. ERROR");
-                        return AXIS2_FAILURE;
-                    }
-
-                    enc_status = AXIS2_SUCCESS;/*TODO Remove*/
-                    AXIS2_LOG_INFO(env->log, "[rampart][rampart_out_handler] Encryption success");
 
+                    AXIS2_LOG_INFO(env->log, "[rampart][rampart_out_handler] Encrypting we do not support yet");
                     /*Signature*/
                 }
                 else if (0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_SIGNATURE,

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=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am Sun Nov 12 22:04:56 2006
@@ -5,7 +5,7 @@
                         token_encrypted_data.c token_encryption_method.c token_cipher_value.c \
                         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 iv.c xml_encryption.c encryption.c\
-						utility.c
+						utility.c certificate.c asym_ctx.c
 
 libomxmlsec_la_LIBADD  = -lssl\
 			../../../util/src/libaxis2_util.la \

Added: 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=auto&rev=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/asym_ctx.c Sun Nov 12 22:04:56 2006
@@ -0,0 +1,378 @@
+/*
+ *   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 <axis2_util.h>
+#include <oxs_asym_ctx.h>
+#include <oxs_certificate.h>
+#include <oxs_error.h>
+
+typedef struct oxs_asym_ctx_impl
+{
+    oxs_asym_ctx_t asym_ctx;
+    
+    axis2_char_t *file_name;
+    axis2_char_t *algorithm;
+    oxs_asym_ctx_operation_t operation;   
+    oxs_certificate_t *certificate;
+}
+oxs_asym_ctx_impl_t;
+
+/** Interface to implementation conversion macro */
+#define AXIS2_INTF_TO_IMPL(oxs_asym_ctx) ((oxs_asym_ctx_impl_t *)oxs_asym_ctx)
+
+/******** function headers ***************/
+
+/*private functions*/
+static void
+oxs_asym_ctx_init_ops(
+    oxs_asym_ctx_t *asym_ctx);
+
+/*Public functions*/
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_free_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env
+);
+
+axis2_char_t *AXIS2_CALL
+oxs_asym_ctx_get_file_name_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env);
+
+axis2_char_t *AXIS2_CALL
+oxs_asym_ctx_get_algorithm_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env);
+
+oxs_asym_ctx_operation_t AXIS2_CALL
+oxs_asym_ctx_get_operation_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env);
+
+oxs_certificate_t *AXIS2_CALL
+oxs_asym_ctx_get_certificate_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_file_name_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    axis2_char_t *file_name);
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_algorithm_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    axis2_char_t *algorithm);
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_operation_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    oxs_asym_ctx_operation_t operation);
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_certificate_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    oxs_certificate_t *certificate);
+
+/******************** end of function headers *****************/
+
+
+axis2_char_t *AXIS2_CALL
+oxs_asym_ctx_get_file_name_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env)
+{
+    oxs_asym_ctx_impl_t *asym_ctx_impl = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    return asym_ctx_impl->file_name;
+}
+
+axis2_char_t *AXIS2_CALL
+oxs_asym_ctx_get_algorithm_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env)
+{
+    oxs_asym_ctx_impl_t *asym_ctx_impl = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    return asym_ctx_impl->algorithm;
+}
+
+oxs_asym_ctx_operation_t AXIS2_CALL
+oxs_asym_ctx_get_operation_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env)
+{
+    oxs_asym_ctx_impl_t *asym_ctx_impl = NULL;
+    /*AXIS2_ENV_CHECK(env, NULL);*/
+    asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    return asym_ctx_impl->operation;
+}
+
+oxs_certificate_t *AXIS2_CALL
+oxs_asym_ctx_get_certificate_impl(
+    const oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env)
+{
+    oxs_asym_ctx_impl_t *asym_ctx_impl = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    return asym_ctx_impl->certificate;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_file_name_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    axis2_char_t *file_name)
+{
+    oxs_asym_ctx_impl_t *oxs_asym_ctx_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, file_name, AXIS2_FAILURE);
+    oxs_asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    if (oxs_asym_ctx_impl->file_name)
+    {
+        AXIS2_FREE(env->allocator, oxs_asym_ctx_impl->file_name);
+        oxs_asym_ctx_impl->file_name = NULL;
+    }
+    oxs_asym_ctx_impl->file_name = AXIS2_STRDUP(file_name, env);
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_algorithm_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    axis2_char_t *algorithm)
+{
+    oxs_asym_ctx_impl_t *oxs_asym_ctx_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, algorithm, AXIS2_FAILURE);
+    oxs_asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    if (oxs_asym_ctx_impl->algorithm)
+    {
+        AXIS2_FREE(env->allocator, oxs_asym_ctx_impl->algorithm);
+        oxs_asym_ctx_impl->algorithm = NULL;
+    }
+    oxs_asym_ctx_impl->algorithm = AXIS2_STRDUP(algorithm, env);
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_operation_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    oxs_asym_ctx_operation_t operation)
+{
+    oxs_asym_ctx_impl_t *oxs_asym_ctx_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    oxs_asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    oxs_asym_ctx_impl->operation = operation;
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_certificate_impl(
+    oxs_asym_ctx_t *asym_ctx,
+    const axis2_env_t *env,
+    oxs_certificate_t *certificate)
+{
+    oxs_asym_ctx_impl_t *oxs_asym_ctx_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, certificate, AXIS2_FAILURE);
+    oxs_asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    if (oxs_asym_ctx_impl->certificate)
+    {
+        oxs_certificate_free(oxs_asym_ctx_impl->certificate, env);
+        oxs_asym_ctx_impl->certificate = NULL;
+    }
+    oxs_asym_ctx_impl->certificate = certificate;
+    return AXIS2_SUCCESS;
+}
+
+
+static void
+oxs_asym_ctx_init_ops(
+    oxs_asym_ctx_t *asym_ctx)
+{
+    asym_ctx->ops->get_file_name  = oxs_asym_ctx_get_file_name_impl;
+    asym_ctx->ops->get_algorithm  = oxs_asym_ctx_get_algorithm_impl;
+    asym_ctx->ops->get_operation  = oxs_asym_ctx_get_operation_impl;
+    asym_ctx->ops->get_certificate  = oxs_asym_ctx_get_certificate_impl;
+    asym_ctx->ops->set_file_name   = oxs_asym_ctx_set_file_name_impl;
+    asym_ctx->ops->set_algorithm  = oxs_asym_ctx_set_algorithm_impl;
+    asym_ctx->ops->set_operation  = oxs_asym_ctx_set_operation_impl;
+    asym_ctx->ops->set_certificate  = oxs_asym_ctx_set_certificate_impl;
+    asym_ctx->ops->free      = oxs_asym_ctx_free_impl;
+}
+
+
+AXIS2_EXTERN oxs_asym_ctx_t *AXIS2_CALL
+oxs_asym_ctx_create_asym_ctx(const axis2_env_t *env)
+{
+    oxs_asym_ctx_impl_t *asym_ctx_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, NULL);
+
+    asym_ctx_impl = AXIS2_MALLOC(env->allocator, sizeof(oxs_asym_ctx_impl_t));
+    if (!asym_ctx_impl)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+
+    asym_ctx_impl->file_name= NULL;
+    asym_ctx_impl->algorithm = NULL;
+    asym_ctx_impl->operation = -1;
+    asym_ctx_impl->certificate = NULL;
+
+    asym_ctx_impl->asym_ctx.ops =  AXIS2_MALLOC(env->allocator, sizeof(oxs_asym_ctx_ops_t));
+    if (!asym_ctx_impl->asym_ctx.ops)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        oxs_asym_ctx_free(&(asym_ctx_impl->asym_ctx), env);
+        return NULL;
+    }
+
+    oxs_asym_ctx_init_ops(&(asym_ctx_impl->asym_ctx));
+
+    return &(asym_ctx_impl->asym_ctx);
+
+}
+
+
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_free_impl(oxs_asym_ctx_t *asym_ctx,
+        const axis2_env_t *env)
+{
+    oxs_asym_ctx_impl_t *asym_ctx_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+    asym_ctx_impl = AXIS2_INTF_TO_IMPL(asym_ctx);
+
+    if (asym_ctx_impl->file_name)
+    {
+        AXIS2_FREE(env->allocator, asym_ctx_impl->file_name);
+        asym_ctx_impl->file_name = NULL;
+    }
+
+    if (asym_ctx_impl->algorithm)
+    {
+        AXIS2_FREE(env->allocator, asym_ctx_impl->algorithm);
+        asym_ctx_impl->algorithm = NULL;
+    }
+
+    if (asym_ctx_impl->certificate)
+    {
+        oxs_certificate_free(asym_ctx_impl->certificate, env);
+        asym_ctx_impl->certificate = NULL;
+    }
+
+    AXIS2_FREE(env->allocator,  asym_ctx_impl);
+    asym_ctx_impl = NULL;
+
+    return AXIS2_SUCCESS;
+}
+
+/**********************Wrappers******************************************/
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_free(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env)
+{
+     return  ctx->ops->free(ctx, env);
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_asym_ctx_get_file_name(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env)
+{
+     return  ctx->ops->get_file_name(ctx, env);
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_asym_ctx_get_algorithm(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env)
+{
+     return  ctx->ops->get_algorithm(ctx, env);
+}
+
+AXIS2_EXTERN oxs_asym_ctx_operation_t AXIS2_CALL
+oxs_asym_ctx_get_operation(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env)
+{
+     return  ctx->ops->get_operation(ctx, env);
+}
+
+AXIS2_EXTERN oxs_certificate_t* AXIS2_CALL
+oxs_asym_ctx_get_certificate(const oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env)
+{
+     return  ctx->ops->get_certificate(ctx, env);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_file_name(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    axis2_char_t *file_name)
+{
+     return  ctx->ops->set_file_name(ctx, env,file_name );
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_algorithm(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    axis2_char_t *algorithm)
+{
+     return  ctx->ops->set_algorithm(ctx, env, algorithm);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_operation(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    oxs_asym_ctx_operation_t operation)
+{
+     return  ctx->ops->set_operation(ctx, env,operation );
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_asym_ctx_set_certificate(oxs_asym_ctx_t *ctx,
+                    const axis2_env_t *env,
+                    oxs_certificate_t *certificate)
+{
+     return  ctx->ops->set_certificate(ctx, env, certificate);
+}
+

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/certificate.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/certificate.c?view=auto&rev=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/certificate.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/certificate.c Sun Nov 12 22:04:56 2006
@@ -0,0 +1,407 @@
+/*
+ *   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 <axis2_util.h>
+#include <oxs_constants.h>
+#include <oxs_certificate.h>
+
+
+typedef struct oxs_certificate_impl
+{
+    oxs_certificate_t certificate;
+
+    axis2_char_t *serial_number;
+    axis2_char_t *subject;
+    axis2_char_t *issuer;
+    axis2_char_t *data;
+}
+oxs_certificate_impl_t;
+
+
+/** Interface to implementation conversion macro */
+#define AXIS2_INTF_TO_IMPL(oxs_certificate) ((oxs_certificate_impl_t *)oxs_certificate)
+
+/******************* function headers ******************************/
+/* private functions */
+static void
+oxs_certificate_init_ops(
+    oxs_certificate_t *certificate);
+
+/*public functions*/
+axis2_status_t AXIS2_CALL
+oxs_certificate_free_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env
+);
+
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_serial_number_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+);
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_subject_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+);
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_issuer_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+);
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_data_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+);
+
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_serial_number_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *serial_number
+);
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_subject_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *subject
+);
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_issuer_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *issuer
+);
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_data_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *data
+);
+
+
+/******************* end of function headers ******************************/
+AXIS2_EXTERN oxs_certificate_t *AXIS2_CALL
+oxs_certificate_create(const axis2_env_t *env)
+{
+    oxs_certificate_impl_t *certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+
+    certificate_impl = AXIS2_MALLOC(env->allocator, sizeof(oxs_certificate_impl_t));
+    if (!certificate_impl)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+
+    certificate_impl->serial_number  = NULL;
+    certificate_impl->subject  = NULL;
+    certificate_impl->issuer  = NULL;
+    certificate_impl->data  = NULL;
+
+
+    certificate_impl->certificate.ops =  AXIS2_MALLOC(env->allocator, sizeof(oxs_certificate_ops_t));
+    if (!certificate_impl->certificate.ops)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        oxs_certificate_free(&(certificate_impl->certificate), env);
+        return NULL;
+    }
+    oxs_certificate_init_ops(&(certificate_impl->certificate));
+
+    return &(certificate_impl->certificate);
+}
+
+/* private functions */
+static void
+oxs_certificate_init_ops(
+    oxs_certificate_t *certificate)
+{
+    certificate->ops->free = oxs_certificate_free_impl ;
+
+    certificate->ops->get_serial_number= oxs_certificate_get_serial_number_impl ;
+    certificate->ops->get_subject = oxs_certificate_get_subject_impl ;
+    certificate->ops->get_issuer = oxs_certificate_get_issuer_impl ;
+    certificate->ops->get_data = oxs_certificate_get_data_impl ;
+
+    certificate->ops->set_serial_number = oxs_certificate_set_serial_number_impl ;
+    certificate->ops->set_subject = oxs_certificate_set_subject_impl ;
+    certificate->ops->set_issuer = oxs_certificate_set_issuer_impl ;
+    certificate->ops->set_data = oxs_certificate_set_data_impl ;
+}
+
+/*public functions*/
+axis2_status_t AXIS2_CALL
+oxs_certificate_free_impl(oxs_certificate_t *certificate,
+        const axis2_env_t *env
+            )
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+
+
+    if (certificate_impl->serial_number)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->serial_number);
+        certificate_impl->serial_number = NULL;
+    }
+
+    if (certificate_impl->subject)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->subject);
+        certificate_impl->subject = NULL;
+    }
+
+    if (certificate_impl->issuer)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->issuer);
+        certificate_impl->issuer = NULL;
+    }
+
+    if (certificate_impl->data)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->data);
+        certificate_impl->data = NULL;
+    }
+
+    AXIS2_FREE(env->allocator,  certificate_impl);
+    certificate_impl = NULL;
+
+    return AXIS2_SUCCESS;
+}
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_serial_number_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+
+    return certificate_impl->serial_number ;
+}
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_subject_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+
+    return certificate_impl->subject ;
+}
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_issuer_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+
+    return certificate_impl->issuer ;
+}
+
+axis2_char_t *AXIS2_CALL
+oxs_certificate_get_data_impl(
+    const oxs_certificate_t *certificate,
+    const axis2_env_t *env
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+
+    return certificate_impl->data ;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_serial_number_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *serial_number
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, serial_number, AXIS2_FAILURE);
+
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+    if (certificate_impl->serial_number)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->serial_number);
+        certificate_impl->serial_number = NULL;
+    }
+    certificate_impl->serial_number = AXIS2_STRDUP(serial_number, env);
+
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_subject_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *subject
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, subject, AXIS2_FAILURE);
+
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+    if (certificate_impl->subject)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->subject);
+        certificate_impl->subject = NULL;
+    }
+    certificate_impl->subject = AXIS2_STRDUP(subject, env);
+
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_issuer_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *issuer
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, issuer, AXIS2_FAILURE);
+
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+    if (certificate_impl->issuer)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->issuer);
+        certificate_impl->issuer = NULL;
+    }
+    certificate_impl->issuer = AXIS2_STRDUP(issuer, env);
+
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_certificate_set_data_impl(
+    oxs_certificate_t *certificate,
+    const axis2_env_t *env,
+    axis2_char_t *data
+)
+{
+    oxs_certificate_impl_t * certificate_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE);
+
+    certificate_impl = AXIS2_INTF_TO_IMPL(certificate);
+    if (certificate_impl->data)
+    {
+        AXIS2_FREE(env->allocator, certificate_impl->data);
+        certificate_impl->data = NULL;
+    }
+    certificate_impl->data = AXIS2_STRDUP(data, env);
+
+    return AXIS2_SUCCESS;
+}
+
+
+/**********************Wrappers******************************************/
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_free(oxs_certificate_t *certificate,
+                    const axis2_env_t *env)
+{
+    return  certificate->ops->free(certificate, env);
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_serial_number(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env)
+{
+    return  certificate->ops->get_serial_number(certificate,env);   
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_subject(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env)
+{
+    return  certificate->ops->get_subject(certificate,env);   
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_issuer(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env)
+{
+    return  certificate->ops->get_issuer(certificate,env);   
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_certificate_get_data(const oxs_certificate_t *certificate,
+                    const axis2_env_t *env)
+{
+    return  certificate->ops->get_data(certificate,env);   
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_serial_number(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *serial_number)
+{
+    return  certificate->ops->set_serial_number(certificate,env, serial_number);   
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_subject(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *subject)
+{
+    return  certificate->ops->set_subject(certificate,env, subject);   
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_issuer(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *issuer)
+{
+    return  certificate->ops->set_issuer(certificate,env, issuer);   
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_certificate_set_data(oxs_certificate_t *certificate,
+                    const axis2_env_t *env,
+                    axis2_char_t *data)
+{
+    return  certificate->ops->set_data(certificate, env, data);   
+}
+
+

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/ctx.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/ctx.c?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/ctx.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/ctx.c Sun Nov 12 22:04:56 2006
@@ -47,6 +47,7 @@
     /*Used  in decryption process to keep the data to be decrypted*/
     axis2_char_t*           input_data;
 
+    /*TODO: Not in use. Remove later*/
     axiom_node_t*           enc_data_node;
     axiom_node_t*           enc_method_node;
     axiom_node_t*           key_info_node;

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=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c Sun Nov 12 22:04:56 2006
@@ -150,3 +150,63 @@
     return AXIS2_SUCCESS;
 }
 
+
+AXIS2_EXTERN  axis2_status_t AXIS2_CALL
+oxs_encryption_asymmetric_crypt(const axis2_env_t *env,
+    oxs_asym_ctx_t *ctx,
+    oxs_buffer_t *input,
+    oxs_buffer_t *result)
+{
+    openssl_pkey_t *pkey = NULL;
+    openssl_rsa_t *rsa = NULL;
+    oxs_asym_ctx_operation_t operation = -1;
+    axis2_char_t *file_name = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    /*TODO We support RSA encryption only. If any other algorithm is specified, reject*/
+
+    /*Create and Load the PKEY*/
+    file_name = oxs_asym_ctx_get_file_name(ctx, env);
+    pkey =  openssl_pkey_create(env);
+    status = OPENSSL_PKEY_LOAD(pkey, env, file_name, "");/*TODO password*/
+      
+    /*Check for the operation and call appropriate method*/
+    operation = oxs_asym_ctx_get_operation(ctx, env);
+    rsa = openssl_rsa_create(env);
+    if(   OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT == operation ){
+        axis2_char_t *encoded_str = NULL;
+        unsigned char *encrypted = NULL;
+        int enclen = -1;
+        int encodedlen = -1;
+        int ret = -1;
+        
+        /*Encrypt using the public key. Then base64 encode and populate the buffer */
+        enclen = OPENSSL_RSA_PUB_ENCRYPT(rsa, env, pkey, OXS_BUFFER_GET_DATA(input, env), &encrypted);
+        encodedlen = axis2_base64_encode_len(enclen);
+        encoded_str = AXIS2_MALLOC(env->allocator, encodedlen);
+        ret = axis2_base64_encode(encoded_str, (const char *)encrypted, enclen); 
+        status = OXS_BUFFER_POPULATE(result, env, (unsigned char*)AXIS2_STRDUP(encoded_str, env), encodedlen);
+
+    }else if(OXS_ASYM_CTX_OPERATION_PRV_DECRYPT == operation ){
+        unsigned char  *decoded_encrypted_str = NULL;
+        unsigned char *decrypted  =  NULL;
+        int ret = -1;
+        int  declen = -1;
+
+        /*Base64 decode first. Then do the decryption and populate the buffer*/
+        decoded_encrypted_str = AXIS2_MALLOC(env->allocator, axis2_base64_decode_len((char*)OXS_BUFFER_GET_DATA(input, env)));
+        ret = axis2_base64_decode((char*)decoded_encrypted_str, (char*)OXS_BUFFER_GET_DATA(input, env));
+        declen = OPENSSL_RSA_PRV_DECRYPT(rsa, env, pkey, decoded_encrypted_str, &decrypted);
+        status = OXS_BUFFER_POPULATE(result, env, decrypted, declen);
+    
+    }else if(OXS_ASYM_CTX_OPERATION_PRV_ENCRYPT == operation ){
+        /**/
+    }else if(OXS_ASYM_CTX_OPERATION_PRV_ENCRYPT == operation ){
+        /**/
+    }else{
+
+    }
+
+    /*TODO Set certificate information taken from the PEM file */
+    
+    return AXIS2_SUCCESS;
+}

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c Sun Nov 12 22:04:56 2006
@@ -396,6 +396,6 @@
             OXS_BUFFER_GET_DATA(key_buf, env), NULL,
             OXS_BUFFER_GET_SIZE(key_buf, env), OXS_KEY_USAGE_NONE);
 
-    /*free buffer*/
+    /* Duplicate key data and free key_buf*/
     return ret;
 }

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=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c Sun Nov 12 22:04:56 2006
@@ -184,3 +184,46 @@
     return oxs_encryption_symmetric_crypt(env, enc_ctx, input_buf, result_buf);
 }
 
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_encrypt_key(const axis2_env_t *env,
+                            oxs_asym_ctx_t * asym_ctx,
+                            axiom_node_t *parent,
+                            oxs_key_t *sym_key)
+{
+    axis2_char_t *algorithm = NULL;
+    axis2_char_t *encrypted_key_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 *key_info_node = NULL;*/
+    axiom_node_t *cd_node = NULL;
+    axiom_node_t *cv_node = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+
+    /*Create input buffer*/
+    input = oxs_buffer_create(env);
+    OXS_BUFFER_POPULATE(input, env, OXS_KEY_GET_DATA(sym_key, env), OXS_KEY_GET_SIZE(sym_key, env));
+
+    /*Create an empty buffer to collect results*/
+    result = oxs_buffer_create(env);
+    
+    /*Call encryption*/
+    status = oxs_encryption_asymmetric_crypt(env, asym_ctx, input, result);
+
+    /*Get the encrypted key*/
+    encrypted_key_data = (axis2_char_t *)OXS_BUFFER_GET_DATA(result, 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);
+    /*key_info_node = oxs_token_build_key_info_element(env, encrypted_key_node);*/
+    /*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);
+
+    return AXIS2_SUCCESS; 
+}
+
+

Modified: webservices/axis2/trunk/c/rampart/src/util/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/Makefile.am?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/util/Makefile.am Sun Nov 12 22:04:56 2006
@@ -2,7 +2,9 @@
 
 noinst_LTLIBRARIES = librampart_util.la
 
-librampart_util_la_SOURCES = rampart_action.c rampart_crypto_engine.c rampart_crypto_util.c rampart_util.c rampart_handler_util.c username_token.c  timestamp_token.c 
+librampart_util_la_SOURCES = rampart_action.c rampart_crypto_util.c \
+							rampart_util.c rampart_handler_util.c username_token.c  timestamp_token.c \
+							rampart_encryption.c
 
 librampart_util_la_LIBADD  = -lssl \
 						-lcrypto \

Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_action.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_action.c?view=diff&rev=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_action.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_action.c Sun Nov 12 22:04:56 2006
@@ -37,8 +37,8 @@
     axis2_char_t *user  ;
     axis2_char_t *password_type  ;
     axis2_char_t *password_callback_class  ;
-    axis2_char_t *encryption_prop_file;
-    axis2_char_t *decryption_prop_file;
+    axis2_char_t *encryption_key_file;
+    axis2_char_t *decryption_key_file;
     axis2_char_t *signature_prop_file ;
     axis2_char_t *signature_key_identifier  ;
     axis2_char_t *encryption_key_identifier  ;
@@ -102,13 +102,13 @@
 );
 
 static axis2_char_t *AXIS2_CALL
-rampart_actions_get_encryption_prop_file(
+rampart_actions_get_encryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env
 );
 
 static axis2_char_t *AXIS2_CALL
-rampart_actions_get_decryption_prop_file(
+rampart_actions_get_decryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env
 );
@@ -200,17 +200,17 @@
 );
 
 static axis2_status_t AXIS2_CALL
-rampart_actions_set_encryption_prop_file(
+rampart_actions_set_encryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env,
-    axis2_char_t *encryption_prop_file
+    axis2_char_t *encryption_key_file
 );
 
 static axis2_status_t AXIS2_CALL
-rampart_actions_set_decryption_prop_file(
+rampart_actions_set_decryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env,
-    axis2_char_t *decryption_prop_file
+    axis2_char_t *decryption_key_file
 );
 
 static axis2_status_t AXIS2_CALL
@@ -302,8 +302,8 @@
     actions_impl->password_type = NULL;
     actions_impl->user = NULL;
     actions_impl->password_callback_class = NULL;
-    actions_impl->encryption_prop_file = NULL;
-    actions_impl->decryption_prop_file = NULL;
+    actions_impl->encryption_key_file = NULL;
+    actions_impl->decryption_key_file = NULL;
     actions_impl->signature_prop_file = NULL;
     actions_impl->signature_key_identifier = NULL;
     actions_impl->encryption_key_identifier = NULL;
@@ -417,7 +417,7 @@
 }
 
 static axis2_char_t *AXIS2_CALL
-rampart_actions_get_encryption_prop_file(
+rampart_actions_get_encryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env
 )
@@ -426,11 +426,11 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     actions_impl = AXIS2_INTF_TO_IMPL(actions);
 
-    return actions_impl->encryption_prop_file ;
+    return actions_impl->encryption_key_file ;
 }
 
 static axis2_char_t *AXIS2_CALL
-rampart_actions_get_decryption_prop_file(
+rampart_actions_get_decryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env
 )
@@ -439,7 +439,7 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     actions_impl = AXIS2_INTF_TO_IMPL(actions);
 
-    return actions_impl->decryption_prop_file ;
+    return actions_impl->decryption_key_file ;
 }
 
 static axis2_char_t *AXIS2_CALL
@@ -695,24 +695,24 @@
     return AXIS2_SUCCESS;
 }
 static axis2_status_t AXIS2_CALL
-rampart_actions_set_encryption_prop_file(
+rampart_actions_set_encryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env,
-    axis2_char_t *encryption_prop_file
+    axis2_char_t *encryption_key_file
 )
 {
     rampart_actions_impl_t * actions_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, encryption_prop_file, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, encryption_key_file, AXIS2_FAILURE);
 
     actions_impl = AXIS2_INTF_TO_IMPL(actions);
-    if (actions_impl->encryption_prop_file)
+    if (actions_impl->encryption_key_file)
     {
-        AXIS2_FREE(env->allocator, actions_impl->encryption_prop_file);
-        actions_impl->encryption_prop_file = NULL;
+        AXIS2_FREE(env->allocator, actions_impl->encryption_key_file);
+        actions_impl->encryption_key_file = NULL;
     }
-    actions_impl->encryption_prop_file = AXIS2_STRDUP(encryption_prop_file, env) ;
-    if(!actions_impl->encryption_prop_file  ){
+    actions_impl->encryption_key_file = AXIS2_STRDUP(encryption_key_file, env) ;
+    if(!actions_impl->encryption_key_file  ){
         return AXIS2_FAILURE;
     }
 
@@ -720,24 +720,24 @@
 }
 
 static axis2_status_t AXIS2_CALL
-rampart_actions_set_decryption_prop_file(
+rampart_actions_set_decryption_key_file(
     rampart_actions_t *actions,
     const axis2_env_t *env,
-    axis2_char_t *decryption_prop_file
+    axis2_char_t *decryption_key_file
 )
 {
     rampart_actions_impl_t * actions_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, decryption_prop_file, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, decryption_key_file, AXIS2_FAILURE);
 
     actions_impl = AXIS2_INTF_TO_IMPL(actions);
-    if (actions_impl->decryption_prop_file)
+    if (actions_impl->decryption_key_file)
     {
-        AXIS2_FREE(env->allocator, actions_impl->decryption_prop_file);
-        actions_impl->decryption_prop_file = NULL;
+        AXIS2_FREE(env->allocator, actions_impl->decryption_key_file);
+        actions_impl->decryption_key_file = NULL;
     }
-    actions_impl->decryption_prop_file = AXIS2_STRDUP(decryption_prop_file, env) ;
-    if(!actions_impl->decryption_prop_file  ){
+    actions_impl->decryption_key_file = AXIS2_STRDUP(decryption_key_file, env) ;
+    if(!actions_impl->decryption_key_file  ){
         return AXIS2_FAILURE;
     }
 
@@ -904,8 +904,8 @@
     actions_impl->password_type = NULL;
     actions_impl->user = NULL;
     actions_impl->password_callback_class = NULL;
-    actions_impl->encryption_prop_file = NULL;
-    actions_impl->decryption_prop_file = NULL;
+    actions_impl->encryption_key_file = NULL;
+    actions_impl->decryption_key_file = NULL;
     actions_impl->signature_prop_file = NULL;
     actions_impl->signature_key_identifier = NULL;
     actions_impl->encryption_key_identifier = NULL;
@@ -965,16 +965,16 @@
         actions_impl->password_callback_class = NULL;
     }
 
-    if (actions_impl->encryption_prop_file)
+    if (actions_impl->encryption_key_file)
     {
-        AXIS2_FREE(env->allocator, actions_impl->encryption_prop_file);
-        actions_impl->encryption_prop_file = NULL;
+        AXIS2_FREE(env->allocator, actions_impl->encryption_key_file);
+        actions_impl->encryption_key_file = NULL;
     }
 
-    if (actions_impl->decryption_prop_file)
+    if (actions_impl->decryption_key_file)
     {
-        AXIS2_FREE(env->allocator, actions_impl->decryption_prop_file);
-        actions_impl->decryption_prop_file = NULL;
+        AXIS2_FREE(env->allocator, actions_impl->decryption_key_file);
+        actions_impl->decryption_key_file = NULL;
     }
 
     if (actions_impl->signature_prop_file)
@@ -1294,10 +1294,10 @@
     actions->ops->set_user = rampart_actions_set_user;
     actions->ops->get_password_callback_class = rampart_actions_get_password_callback_class;
     actions->ops->set_password_callback_class = rampart_actions_set_password_callback_class;
-    actions->ops->get_encryption_prop_file = rampart_actions_get_encryption_prop_file;
-    actions->ops->set_encryption_prop_file = rampart_actions_set_encryption_prop_file;
-    actions->ops->get_decryption_prop_file = rampart_actions_get_decryption_prop_file;
-    actions->ops->set_decryption_prop_file = rampart_actions_set_decryption_prop_file;
+    actions->ops->get_encryption_key_file = rampart_actions_get_encryption_key_file;
+    actions->ops->set_encryption_key_file = rampart_actions_set_encryption_key_file;
+    actions->ops->get_decryption_key_file = rampart_actions_get_decryption_key_file;
+    actions->ops->set_decryption_key_file = rampart_actions_set_decryption_key_file;
     actions->ops->get_signature_prop_file = rampart_actions_get_signature_prop_file;
     actions->ops->set_signature_prop_file = rampart_actions_set_signature_prop_file;
     actions->ops->get_signature_key_identifier = rampart_actions_get_signature_key_identifier;

Added: 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=auto&rev=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_encryption.c Sun Nov 12 22:04:56 2006
@@ -0,0 +1,173 @@
+/*
+ *   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 <axis2_utils.h>
+#include <oxs_ctx.h>
+#include <oxs_error.h>
+#include <oxs_utility.h>
+#include <oxs_enc_engine.h>
+#include <rampart_encryption.h>
+#include <oxs_token_encrypted_data.h>
+#include <oxs_token_encrypted_key.h>
+#include <oxs_token_encryption_method.h>
+#include <oxs_token_data_reference.h>
+#include <oxs_token_cipher_data.h>
+#include <oxs_token_cipher_value.h>
+#include <oxs_token_key_info.h>
+#include <oxs_token_key_name.h>
+#include <oxs_key.h>
+#include <rampart_action.h>
+#include <rampart_constants.h>
+#include <oxs_token_reference_list.h>
+#include <axis2_array_list.h>
+#include <oxs_axiom.h>
+#include <oxs_asym_ctx.h>
+
+/*Private functions*/
+/*
+ * Get encryption parts. Get node list to be encrypted. If nothing is found use the body.
+ * If body is specified in the encryption parts encrypt the immediate child of <body>
+ **/
+
+static axis2_status_t 
+rampart_enc_get_nodes_to_encrypt(const axis2_env_t *env,
+    rampart_actions_t *actions,
+    axiom_soap_envelope_t *soap_envelope,
+    axis2_array_list_t *nodes_to_encrypt
+);
+
+
+
+/*Public functions*/
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_enc_encrypt_message(const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+    rampart_actions_t *actions,
+    axiom_soap_envelope_t *soap_envelope,
+    axiom_node_t *sec_node)
+{
+    axis2_array_list_t *nodes_to_encrypt = NULL;
+    axis2_array_list_t *id_list = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_char_t *enc_sym_algo = NULL;
+    axis2_char_t *enc_asym_algo = NULL;
+    axis2_char_t *certificate_file = NULL;
+    oxs_key_t *session_key = NULL;
+    oxs_asym_ctx_t *asym_ctx = NULL;
+    int i = 0;
+    /*Get nodes to be encrypted*/
+    nodes_to_encrypt = axis2_array_list_create(env, 5);
+    status = rampart_enc_get_nodes_to_encrypt(env, actions, soap_envelope, nodes_to_encrypt);
+
+    /*Get the symmetric encryption algorithm*/
+    enc_sym_algo = RAMPART_ACTIONS_GET_ENC_SYM_ALGO(actions, env); 
+
+    /*Generate the  session key*/
+    session_key = oxs_key_create_key(env);
+    status = OXS_KEY_FOR_ALGO(session_key, env, enc_sym_algo); 
+
+    /*Create a list to store EncDataIds. This will be used in building the ReferenceList*/
+    id_list = axis2_array_list_create(env, 5);
+
+    /*Repeat until all encryption parts are encrypted*/
+    for(i=0 ; i < AXIS2_ARRAY_LIST_SIZE(nodes_to_encrypt, env); i++){
+        axiom_node_t *node_to_enc = NULL;
+        axiom_node_t *parent_of_node_to_enc = NULL;
+        axiom_node_t *enc_data_node = NULL;
+        oxs_ctx_t *enc_ctx = NULL;
+        axis2_char_t *id = NULL;
+        axis2_status_t enc_status = AXIS2_FAILURE;
+        
+        /*Get the node to be encrypted*/
+        node_to_enc = (axiom_node_t *)AXIS2_ARRAY_LIST_GET(nodes_to_encrypt, env, i);
+        /*Create the encryption context for OMXMLSEC*/
+        enc_ctx = oxs_ctx_create(env);
+        /*Set the key*/
+        OXS_CTX_SET_KEY(enc_ctx, env, session_key);
+        /*Create an empty EncryptedDataNode*/
+        parent_of_node_to_enc = AXIOM_NODE_GET_PARENT(node_to_enc, env);
+        id = oxs_util_generate_id(env,(axis2_char_t*)OXS_ENCDATA_ID);
+        enc_data_node = oxs_token_build_encrypted_data_element(env, parent_of_node_to_enc, OXS_TypeEncElement, id );
+        enc_status = oxs_xml_enc_encrypt_node(env, enc_ctx, node_to_enc, enc_data_node);
+        AXIS2_ARRAY_LIST_ADD(id_list, env, id);
+        if(AXIS2_FAILURE == enc_status){
+            return AXIS2_FAILURE;
+        }
+    }
+    /*Get the asymmetric key encryption algorithm*/
+    enc_asym_algo = RAMPART_ACTIONS_GET_ENC_KT_ALGO(actions, env);
+    /*Get the certificate file name*/
+    certificate_file = RAMPART_ACTIONS_GET_ENC_KEY_FILE(actions, env);
+    /*Create asymmetric encryption context*/
+    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_operation(asym_ctx, env, OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT);
+    /*Encrypt the session key*/
+    oxs_xml_enc_encrypt_key(env, asym_ctx, sec_node,session_key);    
+
+
+    return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_enc_decrypt_message(const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+    rampart_actions_t *actions,
+    axiom_soap_envelope_t *soap_envelope,
+    axiom_node_t *sec_node)
+{
+
+    return AXIS2_SUCCESS;
+}
+
+/*Private function implementations*/
+static axis2_status_t  
+rampart_enc_get_nodes_to_encrypt(const axis2_env_t *env,
+    rampart_actions_t *actions,
+    axiom_soap_envelope_t *soap_envelope,
+    axis2_array_list_t *nodes_to_encrypt)
+{
+    axis2_array_list_t *str_list =  NULL;
+    axis2_char_t *encryption_parts = NULL;
+    int size, i = 0;
+
+    /*Get encryption parts*/
+    encryption_parts =  AXIS2_STRDUP(RAMPART_ACTIONS_GET_ENCRYPTION_PARTS(actions, env), env);
+    /*If no encryption parts are specified use body as default*/
+    if((!encryption_parts) || (0 == AXIS2_STRCMP(encryption_parts, " "))){
+        axiom_soap_body_t *body = NULL;
+        axiom_node_t *body_node = NULL;
+
+        AXIS2_LOG_INFO(env->log, "[rampart][rampart_encryption] No encryption parts specified. Using the body as default");
+        body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+        body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(body, env);
+        AXIS2_ARRAY_LIST_ADD(nodes_to_encrypt, env, body_node);
+        return AXIS2_SUCCESS;
+    }
+
+    /*Tokenize*/
+    str_list = axis2_tokenize(env, encryption_parts, ' ');
+    size = AXIS2_ARRAY_LIST_SIZE(str_list, env);
+    /*Find the node and add to the list*/
+    for(i=0 ; i < size ; i++ ){
+        /*TODO*/
+    }
+    return AXIS2_SUCCESS;
+}
+

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=474165&r1=474164&r2=474165
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Sun Nov 12 22:04:56 2006
@@ -27,6 +27,7 @@
 #include <oxs_encryption.h>
 #include <oxs_xml_encryption.h>
 #include <oxs_token_encrypted_data.h>
+#include <oxs_certificate.h>
 
 
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
@@ -120,6 +121,13 @@
 
     env = test_init();
     printf("--Testing started--------------------------------------------\n");
+
+    /*additional code start*/
+    oxs_certificate_t *cert = NULL;
+    cert = oxs_certificate_create(env);
+    oxs_certificate_set_serial_number(cert, env, "MYSER-NUMBER");
+    printf("\nSER NO :%s\n", oxs_certificate_get_serial_number(cert, env));
+    /*additional code end*/
 
     if (argc > 1)
         filename = argv[1];



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