Author: supun
Date: Thu Apr 3 01:08:02 2008
New Revision: 644210
URL: http://svn.apache.org/viewvc?rev=644210&view=rev
Log: (empty)
Modified:
webservices/rampart/scratch/c/pkcs/c/build/win32/configure.in
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/omxmlsec/utility.c
webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c
webservices/rampart/scratch/c/pkcs/c/src/util/rampart_encryption.c
webservices/rampart/scratch/c/pkcs/c/src/util/rampart_engine.c
webservices/rampart/scratch/c/pkcs/c/src/util/rampart_signature.c
Modified: webservices/rampart/scratch/c/pkcs/c/build/win32/configure.in
URL:
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/build/win32/configure.in?rev=644210&r1=644209&r2=644210&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/build/win32/configure.in (original)
+++ webservices/rampart/scratch/c/pkcs/c/build/win32/configure.in Thu Apr 3
01:08:02 2008
@@ -1,11 +1,11 @@
# Set the path to axis2 binary installation.
-AXIS2_BIN_DIR = E:\axis2c\build\axis2c-bin-1.1.0-win32
+AXIS2_BIN_DIR = E:\axis2c\ides\vc\axis2c\deploy
# Set the path to OpenSSL binary installation (ver 0.9.8a or above).
-OPENSSL_BIN_DIR = E:\OpenSSL
+OPENSSL_BIN_DIR = C:\OpenSSL
# Set this to 1 if debug code should be generated, 0 otherwise.
-DEBUG = 0
+DEBUG = 1
#CRUNTIME Libaray ( Use /MT or /MD)
CRUNTIME=/MD
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=644210&r1=644209&r2=644210&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h (original)
+++ webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h Thu Apr 3
01:08:02 2008
@@ -706,8 +706,11 @@
rampart_context_get_key_mgr(
rampart_context_t *rampart_context,
const axutil_env_t *env);
-
+ 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);
#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=644210&r1=644209&r2=644210&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 Thu Apr 3
01:08:02 2008
@@ -20,6 +20,7 @@
#include <oxs_error.h>
#include <oxs_key_mgr.h>
#include <openssl_pem.h>
+#include <oxs_utility.h>
struct oxs_key_mgr_t
{
@@ -66,7 +67,7 @@
AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
oxs_key_mgr_create(axutil_env_t *env)
{
- oxs_key_mgr_t *key_mgr = NULL;
+ oxs_key_mgr_t *key_mgr = NULL;
key_mgr = AXIS2_MALLOC(env->allocator, sizeof(oxs_key_mgr_t));
if (key_mgr)
{
@@ -80,13 +81,14 @@
key_mgr->certificate_type = AXIS2_KEY_TYPE_UNKNOWN;
key_mgr->receiver_certificate = NULL;
key_mgr->receiver_certificate_type = AXIS2_KEY_TYPE_UNKNOWN;
- key_mgr->key_store = NULL;
+ key_mgr->key_store = NULL;
key_mgr->pem_buf = NULL;
key_mgr->format = -1;
}
return key_mgr;
}
+
AXIS2_EXTERN axis2_status_t AXIS2_CALL
oxs_key_mgr_free(oxs_key_mgr_t *key_mgr, axutil_env_t *env)
{
@@ -117,7 +119,11 @@
const axutil_env_t *env,
axis2_char_t *password)
{
- key_mgr->prv_key_password = password;
+ if (key_mgr->prv_key_password)
+ {
+ AXIS2_FREE(env->allocator, password);
+ }
+ key_mgr->prv_key_password = axutil_strdup(env, password);
return AXIS2_SUCCESS;
}
@@ -151,7 +157,11 @@
const axutil_env_t *env,
axis2_char_t *file_name)
{
- key_mgr->private_key_file = file_name;
+ if (key_mgr->private_key_file)
+ {
+ AXIS2_FREE(env->allocator, key_mgr->private_key_file);
+ }
+ key_mgr->private_key_file = axutil_strdup(env, file_name);
return AXIS2_SUCCESS;
}
@@ -161,7 +171,11 @@
const axutil_env_t *env,
axis2_char_t *file_name)
{
- key_mgr->certificate_file = file_name;
+ if (key_mgr->certificate_file)
+ {
+ AXIS2_FREE(env->allocator, key_mgr->certificate_file);
+ }
+ key_mgr->certificate_file = axutil_strdup(env, file_name);
return AXIS2_SUCCESS;
}
@@ -171,7 +185,11 @@
const axutil_env_t *env,
axis2_char_t *file_name)
{
- key_mgr->reciever_certificate_file = file_name;
+ if (key_mgr->reciever_certificate_file)
+ {
+ AXIS2_FREE(env->allocator, key_mgr->reciever_certificate_file);
+ }
+ key_mgr->reciever_certificate_file = axutil_strdup(env,
key_mgr->reciever_certificate_file);
return AXIS2_SUCCESS;
}
@@ -192,12 +210,75 @@
return key_mgr->certificate_type;
}
-AXIS2_EXTERN void *AXIS2_CALL
+AXIS2_EXTERN void * AXIS2_CALL
oxs_key_mgr_get_prv_key(
oxs_key_mgr_t *key_mgr,
const axutil_env_t *env)
{
- return key_mgr->prv_key;
+ void *key_buf = NULL;
+ openssl_pkey_t *prvkey = NULL;
+ axis2_char_t *prv_key_file = NULL;
+ axis2_char_t *password = NULL;
+
+ key_buf = key_mgr->prv_key;
+ if(key_buf)
+ {
+ if(key_mgr->prv_key_type == AXIS2_KEY_TYPE_PEM)
+ {
+ prvkey = oxs_key_mgr_load_private_key_from_string(
+ env, (axis2_char_t *)key_buf, NULL);
+ if(!prvkey)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[oxs][key_mgr] Can't load the key from buffer");
+ return NULL;
+ }
+ }
+ }
+ else
+ { /*Buffer is null load from the file*/
+ prv_key_file = key_mgr->private_key_file;
+ if(!prv_key_file)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[oxs][key_mgr]Private Key file is not
specified.");
+ return NULL;
+ }
+
+ /*Get the password to retrieve the key from key store*/
+ password = key_mgr->prv_key_password;
+
+ if(oxs_util_get_format_by_file_extension(env, prv_key_file) ==
+ OXS_ASYM_CTX_FORMAT_PKCS12)
+ {
+ oxs_x509_cert_t *c = NULL;
+ if((oxs_key_mgr_read_pkcs12_key_store(env, prv_key_file,
+ password, &c,
&prvkey)==AXIS2_FAILURE) || !prvkey)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Cannot load the
private key from pfx file.");
+ return AXIS2_FAILURE;
+ }
+ }
+ else if(oxs_util_get_format_by_file_extension(env, prv_key_file)
+ ==OXS_ASYM_CTX_FORMAT_PEM)
+ {
+ prvkey = oxs_key_mgr_load_private_key_from_pem_file(
+ env, prv_key_file, password);
+ if(!prvkey)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Cannot load the
private key from file.");
+ return AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Unknown Private key
format.");
+ return AXIS2_FAILURE;
+ }
+ }
}
AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
Modified: webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c
URL:
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c?rev=644210&r1=644209&r2=644210&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c Thu Apr 3
01:08:02 2008
@@ -22,6 +22,7 @@
#include <oxs_buffer.h>
#include <oxs_asym_ctx.h>
#include <openssl_util.h>
+#include <oxs_key_mgr.h>
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
oxs_util_generate_nonce(const axutil_env_t *env, int length)
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=644210&r1=644209&r2=644210&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 Thu Apr 3
01:08:02 2008
@@ -203,7 +203,7 @@
rampart_context->signature_token_id = NULL;
rampart_context->key_list = axutil_array_list_create(env, 2);
- rampart_context->key_mgr = oxs_key_mgr_create(env);
+ rampart_context->key_mgr = NULL;
return rampart_context;
}
@@ -2989,6 +2989,18 @@
}
}
return NULL;
+}
+
+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)
+{
+ if (rampart_context->key_mgr)
+ oxs_key_mgr_free(rampart_context->key_mgr, env);
+
+ rampart_context->key_mgr = key_mgr;
+ return AXIS2_SUCCESS;
}
AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL