Author: milinda
Date: Wed Apr 23 05:49:38 2008
New Revision: 650851

URL: http://svn.apache.org/viewvc?rev=650851&view=rev
Log:
PKCS12 Support.

Modified:
    webservices/rampart/scratch/c/pkcs/c/include/rampart_callback.h
    webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h
    webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c
    webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c
    webservices/rampart/scratch/c/pkcs/c/src/util/rampart_engine.c

Modified: webservices/rampart/scratch/c/pkcs/c/include/rampart_callback.h
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/include/rampart_callback.h?rev=650851&r1=650850&r2=650851&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/include/rampart_callback.h (original)
+++ webservices/rampart/scratch/c/pkcs/c/include/rampart_callback.h Wed Apr 23 
05:49:38 2008
@@ -31,7 +31,7 @@
 {
 #endif
        
-       #define RAMPART_PKCS
+       #define RAMPART_PKCS "PKCS"
 
     /**
      * Struct to get password using callbacks

Modified: webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h?rev=650851&r1=650850&r2=650851&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h (original)
+++ webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h Wed Apr 23 
05:49:38 2008
@@ -710,7 +710,12 @@
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     rampart_context_set_key_mgr(rampart_context_t *rampart_context, 
                                                          const axutil_env_t 
*env, 
-                              oxs_key_mgr_t *key_mgr);  
+                              oxs_key_mgr_t *key_mgr); 
+    
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    rampart_context_get_pkcs12_file_name(
+       rampart_context_t *rampart_context,
+       const axutil_env_t *env);
 
 #ifdef __cplusplus
 }

Modified: webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c?rev=650851&r1=650850&r2=650851&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c Wed Apr 23 
05:49:38 2008
@@ -468,6 +468,16 @@
        key_mgr->pem_buf = pem_buf;
        return AXIS2_SUCCESS;
 }
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_key_store(
+       oxs_key_mgr_t *key_mgr,
+       const axutil_env_t *env,
+       pkcs12_keystore_t *key_store)
+{
+       key_mgr->key_store = key_store;
+       return AXIS2_SUCCESS;
+}
 /**
  * Loads the key
  * 1. If the key buffer is specified, Take that as the source.

Modified: webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c?rev=650851&r1=650850&r2=650851&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c Wed Apr 23 
05:49:38 2008
@@ -2023,6 +2023,19 @@
     return rp_rampart_config_get_sct_provider(config,env);
 }
 
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+rampart_context_get_pkcs12_file_name(
+       rampart_context_t *rampart_context,
+       const axutil_env_t *env)
+{
+       rp_rampart_config_t *config = NULL;
+       config = 
rp_secpolicy_get_rampart_config(rampart_context->secpolicy,env);
+       if(!config)
+           return NULL;
+
+       return rp_rampart_config_get_pkcs12_file(config,env);   
+}
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 rampart_context_set_password_type_from_file(
     rampart_context_t *rampart_context,

Modified: webservices/rampart/scratch/c/pkcs/c/src/util/rampart_engine.c
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/util/rampart_engine.c?rev=650851&r1=650850&r2=650851&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/util/rampart_engine.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/util/rampart_engine.c Wed Apr 23 
05:49:38 2008
@@ -35,6 +35,7 @@
 #include <rampart_handler_util.h>
 #include <rampart_config.h>
 #include <axis2_options.h>
+#include <openssl_pkcs12_keystore.h>
 
 /*This method sets all the configurations
  loads required modules and start rampart.*/
@@ -79,9 +80,12 @@
     oxs_key_mgr_t *key_mgr = NULL;
     axis2_char_t *password = NULL;
     axis2_char_t *enc_user = NULL;
+    axis2_char_t *pkcs12_file = NULL;
+    axis2_char_t *pkcs12_password = NULL;
     password_callback_fn password_function = NULL;
     rampart_callback_t *password_callback = NULL;
     void *param = NULL;
+    pkcs12_keystore_t *key_store = NULL;
 
     is_server_side = axis2_msg_ctx_get_server_side(msg_ctx, env);
 
@@ -185,16 +189,31 @@
                 if(password_callback)
                 {
                                        password = 
rampart_callback_password(env, password_callback, enc_user);
+                                       if((pkcs12_file = 
rampart_context_get_pkcs12_file_name(rampart_context, env)))
+                                       {
+                                               pkcs12_password = 
RAMPART_CALLBACK_CALLBACK_PASSWORD(password_callback, env, enc_user, 
RAMPART_PKCS);                                           
+                                       }
                 }
             }
-        }        
+        }  
+        
                key_mgr = oxs_key_mgr_create(env);
                if (!key_mgr)
                {
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                                "[rampart][engine] Key mgr 
creation failed.");
                        return NULL;
-               }  
+               }
+               
+               key_store = pkcs12_keystore_create(env, pkcs12_file, 
pkcs12_password);
+        if(!key_store)
+        {
+               AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                                                               
"[rampart][engine] PKCS12 KeyStore creation failed.");
+               return NULL;    
+        }
+        oxs_key_mgr_set_key_store(key_mgr, env, key_store);
+                       
                if (password)
                {
                        oxs_key_mgr_set_prv_key_password(key_mgr, env, 
password);


Reply via email to