You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by mi...@apache.org on 2008/05/26 12:03:12 UTC
svn commit: r660152 [1/2] - in /webservices/rampart/trunk/c: include/
samples/callback/ samples/keys/ahome/ samples/keys/bhome/
samples/secpolicy/ samples/secpolicy/scenario21/
samples/secpolicy/scenario22/ src/omxmlsec/ src/omxmlsec/openssl/ src/util/
Author: milinda
Date: Mon May 26 03:03:08 2008
New Revision: 660152
URL: http://svn.apache.org/viewvc?rev=660152&view=rev
Log:
Adding PKCS12 support and improvements to key management logic.
Added:
webservices/rampart/trunk/c/samples/keys/ahome/alice_kstore.p12 (with props)
webservices/rampart/trunk/c/samples/keys/bhome/bob_kstore.p12 (with props)
webservices/rampart/trunk/c/samples/secpolicy/scenario21/
webservices/rampart/trunk/c/samples/secpolicy/scenario21/client-policy.xml
webservices/rampart/trunk/c/samples/secpolicy/scenario21/services.xml
webservices/rampart/trunk/c/samples/secpolicy/scenario21/tcpmon-trace3.txt
webservices/rampart/trunk/c/samples/secpolicy/scenario22/
webservices/rampart/trunk/c/samples/secpolicy/scenario22/client-policy.xml
webservices/rampart/trunk/c/samples/secpolicy/scenario22/services.xml
webservices/rampart/trunk/c/samples/secpolicy/scenario22/tcpmon-trace4.txt
Modified:
webservices/rampart/trunk/c/include/axis2_key_type.h
webservices/rampart/trunk/c/include/openssl_pkcs12_keystore.h
webservices/rampart/trunk/c/include/openssl_x509.h
webservices/rampart/trunk/c/include/oxs_asym_ctx.h
webservices/rampart/trunk/c/include/oxs_key_mgr.h
webservices/rampart/trunk/c/include/oxs_utility.h
webservices/rampart/trunk/c/include/oxs_x509_cert.h
webservices/rampart/trunk/c/include/rampart_callback.h
webservices/rampart/trunk/c/include/rampart_context.h
webservices/rampart/trunk/c/include/rampart_util.h
webservices/rampart/trunk/c/include/trust_sts_client.h
webservices/rampart/trunk/c/samples/callback/pwcb.c
webservices/rampart/trunk/c/samples/keys/ahome/Makefile.am
webservices/rampart/trunk/c/samples/keys/bhome/Makefile.am
webservices/rampart/trunk/c/samples/secpolicy/run_all.sh
webservices/rampart/trunk/c/src/omxmlsec/asym_ctx.c
webservices/rampart/trunk/c/src/omxmlsec/encryption.c
webservices/rampart/trunk/c/src/omxmlsec/key_mgr.c
webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12.c
webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12_keystore.c
webservices/rampart/trunk/c/src/omxmlsec/openssl/rsa.c
webservices/rampart/trunk/c/src/omxmlsec/openssl/x509.c
webservices/rampart/trunk/c/src/omxmlsec/utility.c
webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c
webservices/rampart/trunk/c/src/util/rampart_context.c
webservices/rampart/trunk/c/src/util/rampart_encryption.c
webservices/rampart/trunk/c/src/util/rampart_engine.c
webservices/rampart/trunk/c/src/util/rampart_sec_header_processor.c
webservices/rampart/trunk/c/src/util/rampart_signature.c
webservices/rampart/trunk/c/src/util/rampart_util.c
Modified: webservices/rampart/trunk/c/include/axis2_key_type.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/axis2_key_type.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/axis2_key_type.h (original)
+++ webservices/rampart/trunk/c/include/axis2_key_type.h Mon May 26 03:03:08 2008
@@ -41,7 +41,8 @@
{
AXIS2_KEY_TYPE_UNKNOWN = 0,
AXIS2_KEY_TYPE_PEM,
- AXIS2_KEY_TYPE_DER
+ AXIS2_KEY_TYPE_DER,
+ AXIS2_KEY_TYPE_OTHER
}axis2_key_type_t;
Modified: webservices/rampart/trunk/c/include/openssl_pkcs12_keystore.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/openssl_pkcs12_keystore.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/openssl_pkcs12_keystore.h (original)
+++ webservices/rampart/trunk/c/include/openssl_pkcs12_keystore.h Mon May 26 03:03:08 2008
@@ -81,6 +81,11 @@
pkcs12_keystore_t *keystore,
const axutil_env_t *env,
axis2_char_t *ski);
+
+ AXIS2_EXTERN oxs_x509_cert_t * AXIS2_CALL
+ pkcs12_keystore_get_other_certificate(
+ pkcs12_keystore_t *keystore,
+ const axutil_env_t *env);
#ifdef __cplusplus
Modified: webservices/rampart/trunk/c/include/openssl_x509.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/openssl_x509.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/openssl_x509.h (original)
+++ webservices/rampart/trunk/c/include/openssl_x509.h Mon May 26 03:03:08 2008
@@ -56,7 +56,8 @@
OPENSSL_X509_INFO_VERSION ,
OPENSSL_X509_INFO_PUBKEY ,
OPENSSL_X509_INFO_PUBKEY_ALGO ,
- OPENSSL_X509_INFO_DATA_CERT
+ OPENSSL_X509_INFO_DATA_CERT,
+ OPENSSL_X509_INFO_COMMON_NAME
} openssl_x509_info_type_t;
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -111,6 +112,11 @@
openssl_x509_get_info(const axutil_env_t *env,
openssl_x509_info_type_t type,
X509 *cert);
+
+ AXIS2_EXTERN axis2_char_t * AXIS2_CALL
+ openssl_x509_get_common_name(
+ const axutil_env_t *env,
+ X509 *cert);
AXIS2_EXTERN void AXIS2_CALL
openssl_x509_print(const axutil_env_t *env,
Modified: webservices/rampart/trunk/c/include/oxs_asym_ctx.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/oxs_asym_ctx.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/oxs_asym_ctx.h (original)
+++ webservices/rampart/trunk/c/include/oxs_asym_ctx.h Mon May 26 03:03:08 2008
@@ -78,45 +78,6 @@
const axutil_env_t *env);
/**
- *Returns the filename. This is usually the filename of the certificate or the PKCS12 file
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- oxs_asym_ctx_get_file_name(const oxs_asym_ctx_t *ctx,
- const axutil_env_t *env);
-
- /**
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- oxs_asym_ctx_get_pem_buf(const oxs_asym_ctx_t *ctx,
- const axutil_env_t *env);
- /**
- *Returns the password. Usually the password for the keystore. But alternatively may kepe the
- *password for the private key in a PEM file.
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- oxs_asym_ctx_get_password(const oxs_asym_ctx_t *ctx,
- const axutil_env_t *env);
-
- /**
- *Get the format. Can be either PEM or PKCS12
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN oxs_asym_ctx_format_t AXIS2_CALL
- oxs_asym_ctx_get_format(const oxs_asym_ctx_t *ctx,
- const axutil_env_t *env);
-
- /**
*Get the algorithm used to encrypt
*@ctx pointer to the OMXMLSec asymmetric context struct
*@env pointer to environment struct
@@ -167,49 +128,6 @@
const axutil_env_t *env);
/**
- * Set the file name. May be a PKCS12 file or a X509 certificate in PEM format.
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- oxs_asym_ctx_set_file_name(oxs_asym_ctx_t *ctx,
- const axutil_env_t *env,
- axis2_char_t *file_name);
- /**
- *Set the base46 encoded certificate/key.
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- oxs_asym_ctx_set_pem_buf(oxs_asym_ctx_t *ctx,
- const axutil_env_t *env,
- axis2_char_t *pem_buf);
- /**
- * Set the password. Usually the password for the keystore. But alternatively may kepe the
- *password for the private key in a PEM file.
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@password the password
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- oxs_asym_ctx_set_password(oxs_asym_ctx_t *ctx,
- const axutil_env_t *env,
- axis2_char_t *password);
- /**
- * Sets the format. Can be either PEM or PKCS12
- *@ctx pointer to the OMXMLSec asymmetric context struct
- *@env pointer to environment struct
- *@format Can be either PEM or PKCS12
- *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- oxs_asym_ctx_set_format(oxs_asym_ctx_t *ctx,
- const axutil_env_t *env,
- oxs_asym_ctx_format_t format);
- /**
* Sets the algorithm used to encrypt
*@ctx pointer to the OMXMLSec asymmetric context struct
*@env pointer to environment struct
Modified: webservices/rampart/trunk/c/include/oxs_key_mgr.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/oxs_key_mgr.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/oxs_key_mgr.h (original)
+++ webservices/rampart/trunk/c/include/oxs_key_mgr.h Mon May 26 03:03:08 2008
@@ -38,12 +38,23 @@
#include <openssl_pkey.h>
#include <openssl_x509.h>
#include <openssl_pkcs12.h>
+#include <axis2_key_type.h>
+#include <openssl_pkcs12.h>
+#include <openssl_pkcs12_keystore.h>
#ifdef __cplusplus
extern "C"
{
#endif
+ typedef struct oxs_key_mgr_t oxs_key_mgr_t;
+ /* Enum which is used to specify the key format. */
+ typedef enum {
+ OXS_KEY_MGR_FORMAT_UNKNOWN=0,
+ OXS_KEY_MGR_FORMAT_PEM,
+ OXS_KEY_MGR_FORMAT_PKCS12
+ }oxs_key_mgr_format_t;
+
/**
* Loads keys/certificates from a keystore or a PEm file depending on information available in the @ctx
* @ctx pointer to the OMXMLSec asymmetric encryption context struct
@@ -52,9 +63,10 @@
* @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
- oxs_key_mgr_load_key(const axutil_env_t *env,
- oxs_asym_ctx_t *ctx,
- axis2_char_t *password);
+ oxs_key_mgr_load_key(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ oxs_asym_ctx_t *ctx);
/**
* Loads a private key from a string buffer @pem_buf which of PEM format.
* -----BEGIN RSA PRIVATE KEY-----
@@ -119,7 +131,188 @@
axis2_char_t *password,
oxs_x509_cert_t **cert,
openssl_pkey_t **prv_key);
+
+ /**
+ * Creates the key manager strucutre.
+ * @env pointer to environment struct
+ * @return pointer to the key manager (oxs_key_mgr_t *)
+ */
+ AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
+ oxs_key_mgr_create(const axutil_env_t *env);
+
+ /**
+ * Free the key manager struct
+ * @key_mgr pointer to key manager struct which is going to free
+ * @env pointer to environment struct
+ * @return status of the free operation
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_free(oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ /**
+ * Set the password used to encrypt the private key (if any)
+ * @key_mgr Pointer to key manager struct
+ * @env pointer to environment struct
+ * @password password used to encrypt the private key
+ * @return status of the operation
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_prv_key_password(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *password);
+
+ /**
+ * Return the private key file password
+ * @key_mgr pointer to key manager struct
+ * @env pointer to environment struct
+ * @return password of the private key file
+ */
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ oxs_key_mgr_get_prv_key_password(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ /**
+ * Returns the private key file location
+ * @key_mgr pointer to key manager struct
+ * @env pointer to environment struct
+ * @return location of the private key file
+ */
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ oxs_key_mgr_get_private_key_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ oxs_key_mgr_get_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ oxs_key_mgr_get_reciever_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_private_key_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *file_name);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *file_name);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_reciever_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *file_name);
+
+
+ AXIS2_EXTERN void *AXIS2_CALL
+ oxs_key_mgr_get_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
+ oxs_key_mgr_get_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN void *AXIS2_CALL
+ oxs_key_mgr_get_prv_key(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
+ oxs_key_mgr_get_prv_key_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN void *AXIS2_CALL
+ oxs_key_mgr_get_receiver_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
+ oxs_key_mgr_get_receiver_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *certificate);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_key_type_t type);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_prv_key(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *key);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_prv_key_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_key_type_t type);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_receiver_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *certificate);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_receiver_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_key_type_t type);
+
+ AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL
+ oxs_key_mgr_get_format(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_format(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ oxs_key_mgr_format_t format);
+
+ AXIS2_EXTERN void * AXIS2_CALL
+ oxs_key_mgr_get_pem_buf(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_key_mgr_set_pem_buf(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *pem_buf);
+
+ AXIS2_EXTERN pkcs12_keystore_t* AXIS2_CALL
+ oxs_key_mgr_get_key_store(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env);
+
+ 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);
+
/** @} */
#ifdef __cplusplus
}
Modified: webservices/rampart/trunk/c/include/oxs_utility.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/oxs_utility.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/oxs_utility.h (original)
+++ webservices/rampart/trunk/c/include/oxs_utility.h Mon May 26 03:03:08 2008
@@ -32,6 +32,7 @@
#include <axis2_defines.h>
#include <axutil_env.h>
#include <oxs_asym_ctx.h>
+#include <oxs_key_mgr.h>
#ifdef __cplusplus
extern "C"
@@ -65,7 +66,7 @@
* @param env pointer to environment struct
* @param file_name the file name
**/
- AXIS2_EXTERN oxs_asym_ctx_format_t AXIS2_CALL
+ AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL
oxs_util_get_format_by_file_extension(const axutil_env_t *env,
axis2_char_t *file_name);
Modified: webservices/rampart/trunk/c/include/oxs_x509_cert.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/oxs_x509_cert.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/oxs_x509_cert.h (original)
+++ webservices/rampart/trunk/c/include/oxs_x509_cert.h Mon May 26 03:03:08 2008
@@ -273,6 +273,15 @@
oxs_x509_cert_copy_to(oxs_x509_cert_t *x509_cert,
const axutil_env_t *env,
oxs_x509_cert_t *to);
+
+ AXIS2_EXTERN axis2_char_t * AXIS2_CALL
+ oxs_x509_cert_get_common_name(oxs_x509_cert_t *x509_cert,
+ const axutil_env_t *env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ oxs_x509_cert_set_common_name(oxs_x509_cert_t *x509_cert,
+ const axutil_env_t *env,
+ axis2_char_t *common_name);
/** @} */
#ifdef __cplusplus
}
Modified: webservices/rampart/trunk/c/include/rampart_callback.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/rampart_callback.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/rampart_callback.h (original)
+++ webservices/rampart/trunk/c/include/rampart_callback.h Mon May 26 03:03:08 2008
@@ -69,8 +69,23 @@
const axutil_env_t *env,
const axis2_char_t *username,
void *param);
-
- /**
+ /**
+ * Returns a password for PKCS12 key store
+ * By providing a function to this pointer user can write
+ * cutom password callback module to support PKCS12
+ * key store usage.
+ * @param callback rampart callback pointer
+ * @param env pointer to environment struct, must not be null
+ * @param username The username of the owner of the key store
+ * @param any parameter that is to be passed to the callback function.
+ * @returns returns password if any. Otherwise NULL
+ */
+ axis2_char_t *(AXIS2_CALL*
+ callback_pkcs12_password)(rampart_callback_t *callback,
+ const axutil_env_t *env,
+ const axis2_char_t *username,
+ void *param);
+ /**
* Free function of the rampart callback
* @param callback rampart callback pointer
* @param env environment must not be null
@@ -95,6 +110,9 @@
#define RAMPART_CALLBACK_CALLBACK_PASSWORD(callback, env, username, param) \
((callback)->ops->callback_password(callback, env, username, param))
+#define RAMPART_CALLBACK_CALLBACK_PKCS12_PASSWORD(callback, env, username, param) \
+ ((callback)->ops->callback_pkcs12_password(callback, env, username, param))
+
/** @} */
#ifdef __cplusplus
}
Modified: webservices/rampart/trunk/c/include/rampart_context.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/rampart_context.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/rampart_context.h (original)
+++ webservices/rampart/trunk/c/include/rampart_context.h Mon May 26 03:03:08 2008
@@ -41,6 +41,7 @@
#include <axutil_array_list.h>
#include <rampart_saml_token.h>
#include <rampart_issued_token.h>
+#include <oxs_key_mgr.h>
#ifdef __cplusplus
extern "C"
@@ -1521,6 +1522,21 @@
rampart_context_t *rampart_context,
const axutil_env_t *env);
+ AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
+ 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);
+
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ rampart_context_get_pkcs12_file_name(
+ rampart_context_t *rampart_context,
+ const axutil_env_t *env);
+
/**
* Set the a node list to the context. These nodes will be append to
* the Security header
Modified: webservices/rampart/trunk/c/include/rampart_util.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/rampart_util.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/rampart_util.h (original)
+++ webservices/rampart/trunk/c/include/rampart_util.h Mon May 26 03:03:08 2008
@@ -163,6 +163,19 @@
rampart_callback_t *callback_module,
const axis2_char_t *username);
+ /**
+ * Get the password for pkcs12 key store.
+ * @env pointer to environment struct
+ * @callback pointer to rampart callback module
+ * @username name of the pkcs12 owner
+ * @return the password for the user or NULL if username is incorrect
+ */
+ AXIS2_EXTERN axis2_char_t * AXIS2_CALL
+ rampart_callback_pkcs12_password(
+ const axutil_env_t *env,
+ rampart_callback_t *callback_module,
+ const axis2_char_t *username);
+
/**
* Generates the nonce. Nonce is a base64 encoded random string.
* User MUST free memory
Modified: webservices/rampart/trunk/c/include/trust_sts_client.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/trust_sts_client.h?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/trust_sts_client.h (original)
+++ webservices/rampart/trunk/c/include/trust_sts_client.h Mon May 26 03:03:08 2008
@@ -38,7 +38,7 @@
#include <trust_util.h>
#include <trust_policy_util.h>
#include <trust_token.h>
-
+#include <rampart_config.h>
#include <trust_rst.h>
#include <trust_rstr.h>
#include <trust_context.h>
Modified: webservices/rampart/trunk/c/samples/callback/pwcb.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/callback/pwcb.c?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/callback/pwcb.c (original)
+++ webservices/rampart/trunk/c/samples/callback/pwcb.c Mon May 26 03:03:08 2008
@@ -94,8 +94,27 @@
/*sprintf(pw, "%s%s", username, "12345");*/
}
return pw;
-};
+}
+
+axis2_char_t * AXIS2_CALL
+get_pkcs12_sample_password(
+ rampart_callback_t *rcb,
+ const axutil_env_t *env,
+ const axis2_char_t *username,
+ const void *param)
+{
+ axis2_char_t *pw = NULL;
+ if(0 == axutil_strcmp(username, "a"))
+ {
+ pw = "a12345";
+ }
+ else if (0 == axutil_strcmp(username, "b"))
+ {
+ pw = "b12345";
+ }
+ return pw;
+}
/**
* Following block distinguish the exposed part of the dll.
@@ -116,6 +135,7 @@
rcb->ops->callback_password = get_sample_password;
rcb->ops->free = my_free_function;
+ rcb->ops->callback_pkcs12_password = get_pkcs12_sample_password;
*inst = rcb;
Modified: webservices/rampart/trunk/c/samples/keys/ahome/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/keys/ahome/Makefile.am?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/keys/ahome/Makefile.am (original)
+++ webservices/rampart/trunk/c/samples/keys/ahome/Makefile.am Mon May 26 03:03:08 2008
@@ -1,3 +1,3 @@
resdir=$(prefix)/bin/samples/rampart/keys/ahome
-res_DATA= a_key.pem a_req.pem b_cert.cert a_cert.cert alice_key.pem alice_cert.cert bob_cert.cert
-EXTRA_DIST= a_key.pem a_req.pem b_cert.cert a_cert.cert alice_key.pem alice_cert.cert bob_cert.cert
+res_DATA= a_key.pem a_req.pem b_cert.cert a_cert.cert alice_key.pem alice_cert.cert bob_cert.cert alice_kstore.p12
+EXTRA_DIST= a_key.pem a_req.pem b_cert.cert a_cert.cert alice_key.pem alice_cert.cert bob_cert.cert alice_kstore.p12
Added: webservices/rampart/trunk/c/samples/keys/ahome/alice_kstore.p12
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/keys/ahome/alice_kstore.p12?rev=660152&view=auto
==============================================================================
Binary file - no diff available.
Propchange: webservices/rampart/trunk/c/samples/keys/ahome/alice_kstore.p12
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: webservices/rampart/trunk/c/samples/keys/bhome/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/keys/bhome/Makefile.am?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/keys/bhome/Makefile.am (original)
+++ webservices/rampart/trunk/c/samples/keys/bhome/Makefile.am Mon May 26 03:03:08 2008
@@ -1,3 +1,3 @@
resdir=$(prefix)/bin/samples/rampart/keys/bhome
-res_DATA= a_cert.cert b_key.pem b_req.pem b_cert.cert alice_cert.cert bob_cert.cert bob_key.pem
-EXTRA_DIST= a_cert.cert b_key.pem b_req.pem b_cert.cert alice_cert.cert bob_cert.cert bob_key.pem
+res_DATA= a_cert.cert b_key.pem b_req.pem b_cert.cert alice_cert.cert bob_cert.cert bob_key.pem bob_kstore.p12
+EXTRA_DIST= a_cert.cert b_key.pem b_req.pem b_cert.cert alice_cert.cert bob_cert.cert bob_key.pem bob_kstore.p12
Added: webservices/rampart/trunk/c/samples/keys/bhome/bob_kstore.p12
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/keys/bhome/bob_kstore.p12?rev=660152&view=auto
==============================================================================
Binary file - no diff available.
Propchange: webservices/rampart/trunk/c/samples/keys/bhome/bob_kstore.p12
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: webservices/rampart/trunk/c/samples/secpolicy/run_all.sh
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/run_all.sh?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/run_all.sh (original)
+++ webservices/rampart/trunk/c/samples/secpolicy/run_all.sh Mon May 26 03:03:08 2008
@@ -4,7 +4,7 @@
_PORT=9090
_SLEEP=3
#You may change these to scenarios u need to run
-_LST="1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 17 18 19"
+_LST="1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 17 18 19 21 22 23"
if [ $# -eq 1 ]
then
Added: webservices/rampart/trunk/c/samples/secpolicy/scenario21/client-policy.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/scenario21/client-policy.xml?rev=660152&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/scenario21/client-policy.xml (added)
+++ webservices/rampart/trunk/c/samples/secpolicy/scenario21/client-policy.xml Mon May 26 03:03:08 2008
@@ -0,0 +1,55 @@
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic256Rsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefEmbeddedToken/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:EncryptedParts>
+ <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+ <rampc:User>Alice</rampc:User>
+ <rampc:EncryptionUser>a</rampc:EncryptionUser>
+ <rampc:PasswordType>Digest</rampc:PasswordType>
+ <rampc:PasswordCallbackClass>AXIS2C_HOME/bin/samples/rampart/callback/libpwcb.so</rampc:PasswordCallbackClass>
+ <rampc:PKCS12KeyStore>AXIS2C_HOME/bin/samples/rampart/keys/ahome/alice_kstore.p12</rampc:PKCS12KeyStore>
+ </rampc:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
Added: webservices/rampart/trunk/c/samples/secpolicy/scenario21/services.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/scenario21/services.xml?rev=660152&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/scenario21/services.xml (added)
+++ webservices/rampart/trunk/c/samples/secpolicy/scenario21/services.xml Mon May 26 03:03:08 2008
@@ -0,0 +1,68 @@
+<service name="sec_echo">
+ <parameter name="ServiceClass" locked="xsd:false">sec_echo</parameter>
+
+ <description>
+ This is a testing service , to test the system is working or not
+ </description>
+ <module ref="rampart"/>
+
+ <operation name="echoString">
+ <parameter name="wsamapping">http://example.com/ws/2004/09/policy/Test/EchoRequest</parameter>
+ </operation>
+
+ <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic256Rsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefEmbeddedToken/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:EncryptedParts>
+ <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+ <rampc:User>Bob</rampc:User>
+ <rampc:EncryptionUser>b</rampc:EncryptionUser>
+ <rampc:PasswordType>Digest</rampc:PasswordType>
+ <rampc:PasswordCallbackClass>AXIS2C_HOME/bin/samples/rampart/callback/libpwcb.so</rampc:PasswordCallbackClass>
+ <rampc:PKCS12KeyStore>AXIS2C_HOME/bin/samples/rampart/keys/bhome/bob_kstore.p12</rampc:PKCS12KeyStore>
+ </rampc:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+</service>
Added: webservices/rampart/trunk/c/samples/secpolicy/scenario21/tcpmon-trace3.txt
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/scenario21/tcpmon-trace3.txt?rev=660152&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/scenario21/tcpmon-trace3.txt (added)
+++ webservices/rampart/trunk/c/samples/secpolicy/scenario21/tcpmon-trace3.txt Mon May 26 03:03:08 2008
@@ -0,0 +1,81 @@
+
+==============
+Listen Port: 9090
+Target Host: 127.0.0.1
+Target Port: 8080
+==== Request ====
+POST /axis2/services/sec_echo/echoString HTTP/1.1
+User-Agent: Axis2/C
+Content-Length: 2122
+Content-Type: application/soap+xml;charset=UTF-8
+Host: 127.0.0.1:9090
+
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
+ <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:To>http://localhost:9090/axis2/services/sec_echo/echoString</wsa:To>
+ <wsa:Action>http://example.com/ws/2004/09/policy/Test/EchoRequest</wsa:Action>
+ <wsa:MessageID>6d6e2b90-5909-1dc1-3126-000000000000</wsa:MessageID>
+ <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+ <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
+ <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier">Xeg55vRyK3ZhAEhEf+YT0z986L0=</wsse:KeyIdentifier>
+ </wsse:SecurityTokenReference>
+ </ds:KeyInfo>
+ <xenc:CipherData>
+ <xenc:CipherValue>KB05MgYiFAKB9kX6gvRsE3uX3EWJWKxJa8yyTp3OJVQDMYzpBWY3sxuGgmD3rTD5UEs8xTSR6YvdOFnCS0Z18/nvbUrpeRJ/US58BEj9/FEg30qYXd2pk9C4kwsds/UAlAif2MinmwKj0fAnXOnv3qMB7oGRA0EEvCTAwusS8x4=</xenc:CipherValue>
+ </xenc:CipherData>
+ <xenc:ReferenceList xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+ <xenc:DataReference URI="#EncDataID-6d72a698-5909-1dc1"/>
+ </xenc:ReferenceList>
+ </xenc:EncryptedKey>
+ </wsse:Security>
+ </soapenv:Header>
+ <soapenv:Body>
+ <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" Id="EncDataID-6d72a698-5909-1dc1" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+ <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
+ <xenc:CipherData>
+ <xenc:CipherValue>NUmieCaPymk5GsYgP0jwELoeIlanY8yz6bnxbnfTDCfzLnCRBAvogyJoVnFv3llOTFVqhRmAht979JHfTN+L3A34ZywlhJZmQxC4gkd7Bt0zWwloX2ybATy8iZwh+PgPHbL6MgArlCgAj1xiAF8Tew==</xenc:CipherValue>
+ </xenc:CipherData>
+ </xenc:EncryptedData>
+ </soapenv:Body></soapenv:Envelope>==== Response ====
+HTTP/1.1 200 OK
+Content-Type: application/soap+xml;charset=UTF-8
+Content-Length: 2326
+
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
+ <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Action>http://example.com/ws/2004/09/policy/Test/EchoRequest</wsa:Action>
+ <wsa:From>
+ <wsa:Address>http://localhost:9090/axis2/services/sec_echo/echoString</wsa:Address>
+ </wsa:From>
+ <wsa:MessageID>6d8d8490-5909-1dc1-29ca-000000000000</wsa:MessageID>
+ <wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply">6d6e2b90-5909-1dc1-3126-000000000000</wsa:RelatesTo>
+ <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+ <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
+ <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier">CuJdE1B2dUFd1dkLZSzQ5vj6MYg=</wsse:KeyIdentifier>
+ </wsse:SecurityTokenReference>
+ </ds:KeyInfo>
+ <xenc:CipherData>
+ <xenc:CipherValue>hpA7gXdzhzZEDFETA3ZHW4XrkaZJFfkImpEJPSZMM91Opf8sPvvCG6HYnaJVRoYpUEOBiKS6EMS/c28BGd8zK4omqjhZzOc/tfZOK68btb/d3Yg/8ySzK+lSjNByxMESuusifNO8I9alFYk+Yq/+n7ir1y3crTfS9akFH+JHT3w=</xenc:CipherValue>
+ </xenc:CipherData>
+ <xenc:ReferenceList xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+ <xenc:DataReference URI="#EncDataID-6d8d9dd6-5909-1dc1"/>
+ </xenc:ReferenceList>
+ </xenc:EncryptedKey>
+ </wsse:Security>
+ </soapenv:Header>
+ <soapenv:Body>
+ <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" Id="EncDataID-6d8d9dd6-5909-1dc1" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+ <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
+ <xenc:CipherData>
+ <xenc:CipherValue>cVautFsLrrsG0gzoDE2IK+d0keL0mmKvwozkdujFUJ+v4j61+tpJz0E8OFl2JU6uCEx/3FV4NsxpEx1FlynGj+zkbR9ZMLPRnAHUqkjBSLpb4c0jF1ErhkgZ943LQ2DnREV7WE7UgFm0sOZM4b1cARFuNRF5iZ9TCWGHzBNB8QKgUncqFwxnFbn/Me91BZ4n</xenc:CipherValue>
+ </xenc:CipherData>
+ </xenc:EncryptedData>
+ </soapenv:Body></soapenv:Envelope>
+
+==============
Added: webservices/rampart/trunk/c/samples/secpolicy/scenario22/client-policy.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/scenario22/client-policy.xml?rev=660152&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/scenario22/client-policy.xml (added)
+++ webservices/rampart/trunk/c/samples/secpolicy/scenario22/client-policy.xml Mon May 26 03:03:08 2008
@@ -0,0 +1,56 @@
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic256Rsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefEmbeddedToken/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ <sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
+ </sp:SignedParts>
+ <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+ <rampc:User>Alice</rampc:User>
+ <rampc:EncryptionUser>a</rampc:EncryptionUser>
+ <rampc:PasswordType>Digest</rampc:PasswordType>
+ <rampc:PasswordCallbackClass>AXIS2C_HOME/bin/samples/rampart/callback/libpwcb.so</rampc:PasswordCallbackClass>
+ <rampc:PKCS12KeyStore>AXIS2C_HOME/bin/samples/rampart/keys/ahome/alice_kstore.p12</rampc:PKCS12KeyStore>
+ </rampc:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
Added: webservices/rampart/trunk/c/samples/secpolicy/scenario22/services.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/scenario22/services.xml?rev=660152&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/scenario22/services.xml (added)
+++ webservices/rampart/trunk/c/samples/secpolicy/scenario22/services.xml Mon May 26 03:03:08 2008
@@ -0,0 +1,67 @@
+<service name="sec_echo">
+ <parameter name="ServiceClass" locked="xsd:false">sec_echo</parameter>
+
+ <description>
+ This is a testing service , to test the system is working or not
+ </description>
+ <module ref="rampart"/>
+
+ <operation name="echoString">
+ <parameter name="wsamapping">http://example.com/ws/2004/09/policy/Test/EchoRequest</parameter>
+ </operation>
+
+ <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic256Rsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefEmbeddedToken/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ <sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
+ </sp:SignedParts>
+ <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+ <rampc:EncryptionUser>b</rampc:EncryptionUser>
+ <rampc:PasswordCallbackClass>AXIS2C_HOME/bin/samples/rampart/callback/libpwcb.so</rampc:PasswordCallbackClass>
+ <rampc:PKCS12KeyStore>AXIS2C_HOME/bin/samples/rampart/keys/bhome/bob_kstore.p12</rampc:PKCS12KeyStore>
+ </rampc:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+</service>
Added: webservices/rampart/trunk/c/samples/secpolicy/scenario22/tcpmon-trace4.txt
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/secpolicy/scenario22/tcpmon-trace4.txt?rev=660152&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/secpolicy/scenario22/tcpmon-trace4.txt (added)
+++ webservices/rampart/trunk/c/samples/secpolicy/scenario22/tcpmon-trace4.txt Mon May 26 03:03:08 2008
@@ -0,0 +1,135 @@
+
+==============
+Listen Port: 9090
+Target Host: 127.0.0.1
+Target Port: 8080
+==== Request ====
+POST /axis2/services/sec_echo/echoString HTTP/1.1
+User-Agent: Axis2/C
+Content-Length: 4610
+Content-Type: application/soap+xml;charset=UTF-8
+Host: 127.0.0.1:9090
+
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
+ <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:To wsu:Id="SigID-6e96ba8c-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">http://localhost:9090/axis2/services/sec_echo/echoString</wsa:To>
+ <wsa:Action wsu:Id="SigID-6e96bbf4-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">http://example.com/ws/2004/09/policy/Test/EchoRequest</wsa:Action>
+ <wsa:MessageID wsu:Id="SigID-6e96bc9e-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">6e96831e-5909-1dc1-21bb-000000000000</wsa:MessageID>
+ <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" wsu:Id="CertID-6e96b85c-5909-1dc1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">MIIDDDCCAfSgAwIBAgIQM6YEf7FVYx/tZyEXgVComTANBgkqhkiG9w0BAQUFADAwMQ4wDAYDVQQKDAVPQVNJUzEeMBwGA1UEAwwVT0FTSVMgSW50ZXJvcCBUZXN0IENBMB4XDTA1MDMxOTAwMDAwMFoXDTE4MDMxOTIzNTk1OVowQjEOMAwGA1UECgwFT0FTSVMxIDAeBgNVBAsMF09BU0lTIEludGVyb3AgVGVzdCBDZXJ0MQ4wDAYDVQQDDAVBbGljZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAoqi99By1VYo0aHrkKCNT4DkIgPL/SgahbeKdGhrbu3K2XG7arfD9tqIBIKMfrX4Gp90NJa85AV1yiNsEyvq+mUnMpNcKnLXLOjkTmMCqDYbbkehJlXPnaWLzve+mW0pJdPxtf3rbD4PS/cBQIvtpjmrDAU8VsZKT8DN5Kyz+EZsCAwEAAaOBkzCBkDAJBgNVHRMEAjAAMDMGA1UdHwQsMCowKKImhiRodHRwOi8vaW50ZXJvcC5iYnRlc3QubmV0L2NybC9jYS5jcmwwDgYDVR0PAQH/BAQDAgSwMB0GA1UdDgQWBBQK4l0TUHZ1
QV3V2QtlLNDm+PoxiDAfBgNVHSMEGDAWgBTAnSj8wes1oR3WqqqgHBpNwkkPDzANBgkqhkiG9w0BAQUFAAOCAQEABTqpOpvW+6yrLXyUlP2xJbEkohXHI5OWwKWleOb9hlkhWntUalfcFOJAgUyH30TTpHldzx1+vK2LPzhoUFKYHE1IyQvokBN2JjFO64BQukCKnZhldLRPxGhfkTdxQgdf5rCK/wh3xVsZCNTfuMNmlAM6lOAg8QduDah3WFZpEA0s2nwQaCNQTNMjJC8tav1CBr6+E5FAmwPXP7pJxn9Fw9OXRyqbRA4v2y7YpbGkG2GI9UvOHw6SGvf4FRSthMMO35YbpikGsLix3vAsXWWi4rwfVOYzQK0OFPNi9RMCUdSH06m9uLWckiCxjos0FQODZE9l4ATGy9s9hNVwryOJTw==</wsse:BinarySecurityToken>
+ <ds:Signature Id="SigID-6e96c234-5909-1dc1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <ds:SignedInfo>
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
+ <ds:Reference URI="#SigID-6e96ba8c-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>iGBAYABXvaLHO3c1vWSnvosxDaw=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6e96bbf4-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>A1sz0XbuHSEowHtJK0C68Aj+e/o=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6e96bc9e-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>Q8OhlaeE34Ahgr8r97AYiKkKJPM=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6e96bd34-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>iPFCg9M9nm8d3ob7swnq2ER5IXI=</ds:DigestValue>
+ </ds:Reference>
+ </ds:SignedInfo>
+ <ds:SignatureValue>GdDs/FHF2Xuw0IWW30i1aI+WVnN9WDWtRZi67cRZUTlHRSlb8FgeimMuVODuvrZuVpp2Lvix9WvL95Uvl/KHfbJ/btpwTjrh/Gxl9vWtOtUAYeI39xyLyWA0FvTsrgYbb1HBs3TEla5WSoSr+f7v+4+BOQ/KHiyrjjah4iTcXHY=</ds:SignatureValue>
+ <ds:KeyInfo>
+ <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <wsse:Reference URI="#CertID-6e96b85c-5909-1dc1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
+ </wsse:SecurityTokenReference>
+ </ds:KeyInfo>
+ </ds:Signature>
+ </wsse:Security>
+ </soapenv:Header>
+ <soapenv:Body wsu:Id="SigID-6e96bd34-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+ <ns1:echoIn xmlns:ns1="http://ws.apache.org/rampart/c/samples">
+ <text>Hello</text>
+ </ns1:echoIn>
+ </soapenv:Body></soapenv:Envelope>==== Response ====
+HTTP/1.1 200 OK
+Content-Type: application/soap+xml;charset=UTF-8
+Content-Length: 3928
+
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
+ <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Action wsu:Id="SigID-6ea8f58a-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">http://example.com/ws/2004/09/policy/Test/EchoRequest</wsa:Action>
+ <wsa:From wsu:Id="SigID-6ea8f6b6-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+ <wsa:Address>http://localhost:9090/axis2/services/sec_echo/echoString</wsa:Address>
+ </wsa:From>
+ <wsa:MessageID wsu:Id="SigID-6ea8f760-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">6ea8dcda-5909-1dc1-2e7f-000000000000</wsa:MessageID>
+ <wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply" wsu:Id="SigID-6ea8f80a-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">6e96831e-5909-1dc1-21bb-000000000000</wsa:RelatesTo>
+ <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <ds:Signature Id="SigID-6ea8ff62-5909-1dc1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <ds:SignedInfo>
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
+ <ds:Reference URI="#SigID-6ea8f58a-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>fujMpRP6TwjdkNbmfor9wrYqgLc=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6ea8f6b6-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>NhzhAAogdwTYC8XtL5XYX1kJN9M=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6ea8f760-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>FiqEZGG+mVi27dMEk6XGO9ULkqM=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6ea8f80a-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>9n/o/G0iTmSABKQ1UTpRUa3WRI8=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference URI="#SigID-6ea8f8a0-5909-1dc1">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>PiQ9q2i68wAeyJyp+CdWwdS2inI=</ds:DigestValue>
+ </ds:Reference>
+ </ds:SignedInfo>
+ <ds:SignatureValue>NLwut9i+jI6QxhUDUGYOcM3yUY1xkXyOTB7qSED6j9ZTnKSeq+loSiAwjSU0GiZ9wcePcgqBWmdABMyPChmLRyxPJHEXd9n+gFlFcygjhFbZecGKHeEtTfPexUGzyaO6iRcTxBHN0hHo5xjb32kViTs+WUoF+HdDoLhd7/5hHAQ=</ds:SignatureValue>
+ <ds:KeyInfo>
+ <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier">Xeg55vRyK3ZhAEhEf+YT0z986L0=</wsse:KeyIdentifier>
+ </wsse:SecurityTokenReference>
+ </ds:KeyInfo>
+ </ds:Signature>
+ </wsse:Security>
+ </soapenv:Header>
+ <soapenv:Body wsu:Id="SigID-6ea8f8a0-5909-1dc1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+ <ns1:RecievedNode xmlns:ns1="http://ws.apache.org/axis2/rampart/samples">
+ <LocalName>echoIn</LocalName>
+ </ns1:RecievedNode>
+ </soapenv:Body></soapenv:Envelope>
+
+==============
Modified: webservices/rampart/trunk/c/src/omxmlsec/asym_ctx.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/asym_ctx.c?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/asym_ctx.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/asym_ctx.c Mon May 26 03:03:08 2008
@@ -23,53 +23,75 @@
struct oxs_asym_ctx_t
{
- axis2_char_t *file_name;
- axis2_char_t *pem_buf;
- axis2_char_t *password;
axis2_char_t *algorithm;
axis2_char_t *st_ref_pattern;
oxs_asym_ctx_operation_t operation;
- oxs_asym_ctx_format_t format;
oxs_x509_cert_t *certificate;
openssl_pkey_t *private_key;
-
};
/*Public functions*/
AXIS2_EXTERN
-axis2_char_t *AXIS2_CALL
-oxs_asym_ctx_get_file_name(
- const oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env)
+oxs_asym_ctx_t *AXIS2_CALL
+oxs_asym_ctx_create(const axutil_env_t *env)
{
- return asym_ctx->file_name;
-}
+ oxs_asym_ctx_t *asym_ctx = NULL;
-AXIS2_EXTERN
-axis2_char_t *AXIS2_CALL
-oxs_asym_ctx_get_pem_buf(
- const oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env)
-{
- return asym_ctx->pem_buf;
-}
-AXIS2_EXTERN
-axis2_char_t *AXIS2_CALL
-oxs_asym_ctx_get_password(
- const oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env)
-{
- return asym_ctx->password;
+ AXIS2_ENV_CHECK(env, NULL);
+
+ asym_ctx = AXIS2_MALLOC(env->allocator, sizeof(oxs_asym_ctx_t));
+ if (!asym_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ asym_ctx->algorithm = NULL;
+ asym_ctx->st_ref_pattern = NULL;
+ asym_ctx->operation = -1;
+ asym_ctx->certificate = NULL;
+ asym_ctx->private_key = NULL;
+
+ return asym_ctx;
}
+
+
AXIS2_EXTERN
-oxs_asym_ctx_format_t AXIS2_CALL
-oxs_asym_ctx_get_format(
- const oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env)
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_free(oxs_asym_ctx_t *asym_ctx,
+ const axutil_env_t *env)
{
- return asym_ctx->format;
+
+ if (asym_ctx->algorithm)
+ {
+ AXIS2_FREE(env->allocator, asym_ctx->algorithm);
+ asym_ctx->algorithm = NULL;
+ }
+
+ if (asym_ctx->st_ref_pattern)
+ {
+ AXIS2_FREE(env->allocator, asym_ctx->st_ref_pattern);
+ asym_ctx->st_ref_pattern = NULL;
+ }
+
+ if (asym_ctx->certificate)
+ {
+ oxs_x509_cert_free(asym_ctx->certificate, env);
+ asym_ctx->certificate = NULL;
+ }
+
+ if (asym_ctx->private_key)
+ {
+ openssl_pkey_free(asym_ctx->private_key, env);
+ asym_ctx->private_key = NULL;
+ }
+
+ AXIS2_FREE(env->allocator, asym_ctx);
+ asym_ctx = NULL;
+
+ return AXIS2_SUCCESS;
}
AXIS2_EXTERN
@@ -121,69 +143,6 @@
AXIS2_EXTERN
axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_file_name(
- oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env,
- axis2_char_t *file_name)
-{
-
- if (asym_ctx->file_name)
- {
- AXIS2_FREE(env->allocator, asym_ctx->file_name);
- asym_ctx->file_name = NULL;
- }
- asym_ctx->file_name = axutil_strdup(env, file_name);
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_pem_buf(
- oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env,
- axis2_char_t *pem_buf)
-{
-
- if (asym_ctx->pem_buf)
- {
- AXIS2_FREE(env->allocator, asym_ctx->pem_buf);
- asym_ctx->pem_buf = NULL;
- }
- asym_ctx->pem_buf = axutil_strdup(env, pem_buf);
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_password(
- oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env,
- axis2_char_t *password)
-{
-
- if (asym_ctx->password)
- {
- AXIS2_FREE(env->allocator, asym_ctx->password);
- asym_ctx->password = NULL;
- }
- asym_ctx->password = axutil_strdup(env, password);
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_format(
- oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env,
- oxs_asym_ctx_format_t format)
-{
-
- asym_ctx->format = format;
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
oxs_asym_ctx_set_algorithm(
oxs_asym_ctx_t *asym_ctx,
const axutil_env_t *env,
@@ -263,89 +222,5 @@
}
-AXIS2_EXTERN
-oxs_asym_ctx_t *AXIS2_CALL
-oxs_asym_ctx_create(const axutil_env_t *env)
-{
- oxs_asym_ctx_t *asym_ctx = NULL;
-
- AXIS2_ENV_CHECK(env, NULL);
-
- asym_ctx = AXIS2_MALLOC(env->allocator, sizeof(oxs_asym_ctx_t));
- if (!asym_ctx)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- return NULL;
- }
-
- asym_ctx->file_name= NULL;
- asym_ctx->pem_buf= NULL;
- asym_ctx->password= NULL;
- asym_ctx->format= -1;
- asym_ctx->algorithm = NULL;
- asym_ctx->st_ref_pattern = NULL;
- asym_ctx->operation = -1;
- asym_ctx->certificate = NULL;
- asym_ctx->private_key = NULL;
-
- return asym_ctx;
-}
-
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_free(oxs_asym_ctx_t *asym_ctx,
- const axutil_env_t *env)
-{
-
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- if (asym_ctx->file_name)
- {
- AXIS2_FREE(env->allocator, asym_ctx->file_name);
- asym_ctx->file_name = NULL;
- }
-
- if (asym_ctx->pem_buf)
- {
- AXIS2_FREE(env->allocator, asym_ctx->pem_buf);
- asym_ctx->pem_buf = NULL;
- }
-
- if (asym_ctx->password)
- {
- AXIS2_FREE(env->allocator, asym_ctx->password);
- asym_ctx->password = NULL;
- }
-
- if (asym_ctx->algorithm)
- {
- AXIS2_FREE(env->allocator, asym_ctx->algorithm);
- asym_ctx->algorithm = NULL;
- }
-
- if (asym_ctx->st_ref_pattern)
- {
- AXIS2_FREE(env->allocator, asym_ctx->st_ref_pattern);
- asym_ctx->st_ref_pattern = NULL;
- }
-
- if (asym_ctx->certificate)
- {
- oxs_x509_cert_free(asym_ctx->certificate, env);
- asym_ctx->certificate = NULL;
- }
-
- if (asym_ctx->private_key)
- {
- openssl_pkey_free(asym_ctx->private_key, env);
- asym_ctx->private_key = NULL;
- }
-
- AXIS2_FREE(env->allocator, asym_ctx);
- asym_ctx = NULL;
-
- return AXIS2_SUCCESS;
-}
Modified: webservices/rampart/trunk/c/src/omxmlsec/encryption.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/encryption.c?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/encryption.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/encryption.c Mon May 26 03:03:08 2008
@@ -211,7 +211,6 @@
openssl_pkey_t *pkey = NULL;
oxs_asym_ctx_operation_t operation = -1;
axis2_status_t status = AXIS2_FAILURE;
- axis2_char_t *password = NULL;
axis2_char_t *algorithm = NULL;
axis2_char_t *padding = NULL;
@@ -232,17 +231,6 @@
padding = OPENSSL_RSA_PKCS1_PADDING;
}
- /*Load the key using key manager*/
- password = oxs_asym_ctx_get_password(asym_ctx, env);
- status = oxs_key_mgr_load_key(env, asym_ctx, password);
- if (status == AXIS2_FAILURE)
- {
- oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
- "Key loading failed for Key encryption");
-
- return AXIS2_FAILURE;
- }
-
/*Check for the operation and call appropriate method*/
operation = oxs_asym_ctx_get_operation(asym_ctx, env);
if (operation == OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT)
Modified: webservices/rampart/trunk/c/src/omxmlsec/key_mgr.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/key_mgr.c?rev=660152&r1=660151&r2=660152&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/key_mgr.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/key_mgr.c Mon May 26 03:03:08 2008
@@ -20,18 +20,521 @@
#include <oxs_error.h>
#include <oxs_key_mgr.h>
#include <openssl_pem.h>
+#include <oxs_utility.h>
+struct oxs_key_mgr_t
+{
+ /* Location of the private key file */
+ axis2_char_t *private_key_file;
+
+ /*Pasword of the private key */
+ axis2_char_t *prv_key_password;
+
+ /*Location of the cert file of the private key owner */
+ axis2_char_t *certificate_file;
+
+ /*Location of the cert file of the user at the other end */
+ axis2_char_t *reciever_certificate_file;
+
+ /* Priate key */
+ void *prv_key;
+
+ /*Type of the private key */
+ axis2_key_type_t prv_key_type;
+
+ /*Owner certificate */
+ void *certificate;
+
+ /* type of the certificate */
+ axis2_key_type_t certificate_type;
+
+ /*Certificate of the enityt at the other end*/
+ void *receiver_certificate;
+
+ /*Type of Certificate at the other end*/
+ axis2_key_type_t receiver_certificate_type;
+
+ /* PKCS12 Key store */
+ pkcs12_keystore_t *key_store;
+
+ /* Buffer holding keys and certs */
+ void *pem_buf;
+
+ /* Format of the current key */
+ oxs_key_mgr_format_t format;
+};
+
+AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
+oxs_key_mgr_create(const axutil_env_t *env)
+{
+ oxs_key_mgr_t *key_mgr = NULL;
+ key_mgr = AXIS2_MALLOC(env->allocator, sizeof(oxs_key_mgr_t));
+ if (key_mgr)
+ {
+ key_mgr->private_key_file = NULL;
+ key_mgr->certificate_file = NULL;
+ key_mgr->reciever_certificate_file = NULL;
+ key_mgr->prv_key_password = NULL;
+ key_mgr->prv_key = NULL;
+ key_mgr->prv_key_type = AXIS2_KEY_TYPE_UNKNOWN;
+ key_mgr->certificate = NULL;
+ 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->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, const axutil_env_t *env)
+{
+ if(key_mgr->certificate)
+ {
+ oxs_x509_cert_free(key_mgr->certificate, env);
+ key_mgr->certificate = NULL;
+ }
+ if(key_mgr->receiver_certificate)
+ {
+ oxs_x509_cert_free(key_mgr->receiver_certificate, env);
+ key_mgr->receiver_certificate = NULL;
+ }
+ AXIS2_FREE(env->allocator, key_mgr);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN pkcs12_keystore_t* AXIS2_CALL
+oxs_key_mgr_get_key_store(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->key_store;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+oxs_key_mgr_get_prv_key_password(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->prv_key_password;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_prv_key_password(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *password)
+{
+ if (key_mgr->prv_key_password)
+ {
+ AXIS2_FREE(env->allocator, password);
+ }
+ key_mgr->prv_key_password = axutil_strdup(env, password);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+oxs_key_mgr_get_private_key_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->private_key_file;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+oxs_key_mgr_get_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->certificate_file;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+oxs_key_mgr_get_reciever_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->reciever_certificate_file;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_private_key_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *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;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *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;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_reciever_certificate_file(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_char_t *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, file_name);
+ return AXIS2_SUCCESS;
+}
+AXIS2_EXTERN void *AXIS2_CALL
+oxs_key_mgr_get_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ /*void *key_buf = NULL;*/
+ /* axis2_key_type_t type = 0;*/
+ oxs_x509_cert_t *cert = NULL;
+ axis2_char_t *certificate_file = NULL;
+
+
+ if (key_mgr->certificate)
+ {
+ if(key_mgr->certificate_type == AXIS2_KEY_TYPE_PEM)
+ {
+ cert = oxs_key_mgr_load_x509_cert_from_string(env, (axis2_char_t *)key_mgr->certificate);
+ if(!cert)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Certificate cannot be loaded from the buffer.");
+ return NULL;
+ }
+ else
+ {
+ key_mgr->certificate = cert;
+ return cert;
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Key file type unknown.");
+ return NULL;
+ }
+ }
+
+ certificate_file = oxs_key_mgr_get_certificate_file(key_mgr, env);
+ if(certificate_file)
+ {
+ cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, certificate_file);
+ if(!cert)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Certificate cannot be loaded from the file.");
+ return NULL;
+ }
+ }
+ else if(oxs_key_mgr_get_key_store(key_mgr, env))
+ {
+ cert = pkcs12_keystore_get_owner_certificate(key_mgr->key_store, env);
+ if(!cert)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Certificate cannot be loaded from the key store.");
+ return NULL;
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Public key certificate file is not specified.");
+ return NULL;
+ }
+
+ key_mgr->certificate = cert;
+ return key_mgr->certificate;
+}
+
+AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
+oxs_key_mgr_get_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->certificate_type;
+}
+
+AXIS2_EXTERN void * AXIS2_CALL
+oxs_key_mgr_get_prv_key(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ 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
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Key file type unknown.");
+ return NULL;
+ }
+ }
+ else
+ { /*Buffer is null load from the file*/
+ prv_key_file = axutil_strdup(env, oxs_key_mgr_get_private_key_file(key_mgr, env));
+
+ /*Get the password to retrieve the key from key store*/
+ password = axutil_strdup(env, oxs_key_mgr_get_prv_key_password(key_mgr, env));
+
+ if(prv_key_file)
+ {
+ 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][key_mgr] Cannot load the private key from file.");
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ if(key_mgr->key_store)
+ {
+ prvkey = pkcs12_keystore_get_owner_private_key(key_mgr->key_store, env);
+ if(!prvkey)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][key_mgr] Cannot load the private key from pkcs12 key store.");
+ return NULL;
+ }
+ key_mgr->prv_key_type = AXIS2_KEY_TYPE_PEM;
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][key_mgr] Cannot find a way to load the private key.");
+ return NULL;
+ }
+ }
+ }
+ return prvkey;
+}
+
+AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
+oxs_key_mgr_get_prv_key_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->prv_key_type;
+}
+
+AXIS2_EXTERN void *AXIS2_CALL
+oxs_key_mgr_get_receiver_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ oxs_x509_cert_t *oxs_cert = NULL;
+
+ if (key_mgr->receiver_certificate)
+ {
+ if(key_mgr->receiver_certificate_type == AXIS2_KEY_TYPE_PEM)
+ {
+ oxs_cert = oxs_key_mgr_load_x509_cert_from_string(env, (axis2_char_t *)key_mgr->receiver_certificate);
+ if(!oxs_cert)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Certificate cannot be loaded from the buffer.");
+ return NULL;
+ }
+ else
+ {
+ key_mgr->receiver_certificate = oxs_cert;
+ return oxs_cert;
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[rampart][rampart_signature] Key file type unknown.");
+ return NULL;
+ }
+ }
+ else
+ {
+ /* If user has specified the certificate/private key directly we will extract the information from it.
+ * Else we will look for a file name to load the certificate/private key*/
+ if(key_mgr->reciever_certificate_file)
+ {
+ oxs_cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, key_mgr->reciever_certificate_file);
+ }
+ else if(key_mgr->key_store)
+ {
+ oxs_cert = pkcs12_keystore_get_other_certificate(key_mgr->key_store, env);
+ }
+ }
+ return oxs_cert;
+}
+
+AXIS2_EXTERN axis2_key_type_t AXIS2_CALL
+oxs_key_mgr_get_receiver_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->receiver_certificate_type;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *certificate)
+{
+ key_mgr->certificate = certificate;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_key_type_t type)
+{
+ key_mgr->certificate_type = type;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_prv_key(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *key)
+{
+ key_mgr->prv_key = key;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_prv_key_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_key_type_t type)
+{
+ key_mgr->prv_key_type = type;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_receiver_certificate(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *certificate)
+{
+ key_mgr->receiver_certificate = certificate;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_receiver_certificate_type(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ axis2_key_type_t type)
+{
+ key_mgr->receiver_certificate_type = type;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL
+oxs_key_mgr_get_format(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->format;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_format(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ oxs_key_mgr_format_t format)
+{
+ key_mgr->format = format;
+ return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN void * AXIS2_CALL
+oxs_key_mgr_get_pem_buf(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env)
+{
+ return key_mgr->pem_buf;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_pem_buf(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ void *pem_buf)
+{
+ 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.
* 2. Else if the key file name has specified, Take that as the source.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
-oxs_key_mgr_load_key(const axutil_env_t *env,
- oxs_asym_ctx_t *ctx,
- axis2_char_t *password)
+oxs_key_mgr_load_key(
+ oxs_key_mgr_t *key_mgr,
+ const axutil_env_t *env,
+ oxs_asym_ctx_t *ctx)
{
axis2_char_t *filename = NULL;
axis2_char_t *pem_buf = NULL;
@@ -48,32 +551,48 @@
/* If user has specified the certificate/private key directly we will extract the information from it.
* Else we will look for a file name to load the certificate/private key*/
- pem_buf = oxs_asym_ctx_get_pem_buf(ctx, env);
- if(pem_buf){
+ pem_buf = oxs_key_mgr_get_pem_buf(key_mgr, env);
+ if(pem_buf)
+ {
if( OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT == oxs_asym_ctx_get_operation(ctx, env) ||
- OXS_ASYM_CTX_OPERATION_PUB_DECRYPT == oxs_asym_ctx_get_operation(ctx, env)){
+ OXS_ASYM_CTX_OPERATION_PUB_DECRYPT == oxs_asym_ctx_get_operation(ctx, env))
+ {
/*load certificate from buf*/
status = openssl_x509_load_from_buffer(env, pem_buf, &cert);
- }else{
-
+ }
+ else
+ {
/*load private key from buf*/
- status = openssl_pem_buf_read_pkey(env, pem_buf, password, OPENSSL_PEM_PKEY_TYPE_PRIVATE_KEY, &prvkey);
- if(status == AXIS2_FAILURE){
+ status = openssl_pem_buf_read_pkey(env, pem_buf, key_mgr->prv_key_password, OPENSSL_PEM_PKEY_TYPE_PRIVATE_KEY, &prvkey);
+ if(status == AXIS2_FAILURE)
+ {
prvkey = NULL;
}
}
- }else{
-
+ }
+ else
+ {
+ oxs_asym_ctx_operation_t operation = oxs_asym_ctx_get_operation(ctx, env);
+ if((operation == OXS_ASYM_CTX_OPERATION_PRV_DECRYPT) || (operation == OXS_ASYM_CTX_OPERATION_PRV_ENCRYPT))
+ {
+ filename = oxs_key_mgr_get_private_key_file(key_mgr, env);
+ }
+ else if(operation == OXS_ASYM_CTX_OPERATION_PUB_DECRYPT)
+ {
+ filename = oxs_key_mgr_get_reciever_certificate_file(key_mgr, env);
+ }
+ else if(operation == OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT)
+ {
+ filename = oxs_key_mgr_get_reciever_certificate_file(key_mgr, env);
+ }
/* pem_buf is NULL. So we have to fetch the key in a file*/
- /* Get file to be loaded. Can be either in PEM or PKCS12 format*/
- filename = oxs_asym_ctx_get_file_name(ctx, env);
+ /* Get file to be loaded. Can be either in PEM or PKCS12 format*/
if(!filename){
return AXIS2_FAILURE;
}
- if(OXS_ASYM_CTX_FORMAT_PEM == oxs_asym_ctx_get_format(ctx, env)){
- oxs_asym_ctx_operation_t operation ;
+ if(OXS_ASYM_CTX_FORMAT_PEM == oxs_key_mgr_get_format(key_mgr, env)){
format = OPENSSL_X509_FORMAT_PEM;
@@ -87,22 +606,22 @@
operation = oxs_asym_ctx_get_operation(ctx, env);
if((operation == OXS_ASYM_CTX_OPERATION_PRV_DECRYPT) || (operation == OXS_ASYM_CTX_OPERATION_PRV_ENCRYPT)){
- status = openssl_pem_read_pkey(env, filename, password, OPENSSL_PEM_PKEY_TYPE_PRIVATE_KEY, &prvkey);
+ status = openssl_pem_read_pkey(env, filename, key_mgr->prv_key_password, OPENSSL_PEM_PKEY_TYPE_PRIVATE_KEY, &prvkey);
if(status == AXIS2_FAILURE){
prvkey = NULL;
}
} else if((operation == OXS_ASYM_CTX_OPERATION_PUB_DECRYPT) || (operation == OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT)){
- status = openssl_pem_read_pkey(env, filename, password, OPENSSL_PEM_PKEY_TYPE_PUBLIC_KEY, &pubkey);
+ status = openssl_pem_read_pkey(env, filename, key_mgr->prv_key_password, OPENSSL_PEM_PKEY_TYPE_PUBLIC_KEY, &pubkey);
if(status == AXIS2_FAILURE){
pubkey = NULL;
}
}
}
- }else if(OXS_ASYM_CTX_FORMAT_PKCS12 == oxs_asym_ctx_get_format(ctx, env)){
+ }else if(OXS_ASYM_CTX_FORMAT_PKCS12 == oxs_key_mgr_get_format(key_mgr, env)){
format = OPENSSL_X509_FORMAT_PKCS12;
/* Here we load both key and the certificate*/
- status = openssl_x509_load_from_pkcs12(env, filename, password, &cert, &prvkey, &ca);
+ status = openssl_x509_load_from_pkcs12(env, filename, key_mgr->prv_key_password, &cert, &prvkey, &ca);
if(AXIS2_FAILURE == status){
oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT,
"Error reading the certificate");
@@ -139,6 +658,7 @@
axis2_char_t *x509_cert_subject = NULL;
axis2_char_t *x509_cert_finger = NULL;
axis2_char_t *x509_cert_key_id = NULL;
+ axis2_char_t *x509_common_name = NULL;
x509_cert_data = openssl_x509_get_cert_data(env, cert);
x509_cert_date = openssl_x509_get_info(env, OPENSSL_X509_INFO_VALID_TO ,cert);
@@ -146,6 +666,7 @@
x509_cert_subject = openssl_x509_get_info(env, OPENSSL_X509_INFO_SUBJECT ,cert);
x509_cert_finger = openssl_x509_get_info(env, OPENSSL_X509_INFO_FINGER,cert);
x509_cert_key_id = openssl_x509_get_subject_key_identifier(env, cert);
+ x509_common_name = openssl_x509_get_common_name(env,cert);
/*Create certificate*/
oxs_cert = oxs_x509_cert_create(env);
@@ -158,6 +679,7 @@
oxs_x509_cert_set_fingerprint(oxs_cert, env, x509_cert_finger);
oxs_x509_cert_set_serial_number(oxs_cert, env, openssl_x509_get_serial(env, cert));
oxs_x509_cert_set_key_identifier(oxs_cert, env, x509_cert_key_id);
+ oxs_x509_cert_set_common_name(oxs_cert, env, x509_common_name);
/*Additionally we need to set the public key*/
openssl_x509_get_pubkey(env, cert, &pubkey);
@@ -181,6 +703,8 @@
x509_cert_finger = NULL;
AXIS2_FREE(env->allocator, x509_cert_key_id);
x509_cert_key_id = NULL;
+ AXIS2_FREE(env->allocator, x509_common_name);
+ x509_common_name = NULL;
X509_free(cert);
cert = NULL;
@@ -223,7 +747,8 @@
}
AXIS2_EXTERN openssl_pkey_t* AXIS2_CALL
-oxs_key_mgr_load_private_key_from_pem_file(const axutil_env_t *env,
+oxs_key_mgr_load_private_key_from_pem_file(
+ const axutil_env_t *env,
axis2_char_t *filename,
axis2_char_t *password)
{
@@ -261,6 +786,7 @@
axis2_char_t *x509_cert_subject = NULL;
axis2_char_t *x509_cert_fingerprint = NULL;
axis2_char_t *x509_cert_key_id = NULL;
+ axis2_char_t *x509_common_name = NULL;
x509_cert_data = openssl_x509_get_cert_data(env, cert);
x509_cert_date = openssl_x509_get_info(env, OPENSSL_X509_INFO_VALID_TO ,cert);
@@ -268,6 +794,7 @@
x509_cert_subject = openssl_x509_get_info(env, OPENSSL_X509_INFO_SUBJECT ,cert);
x509_cert_fingerprint = openssl_x509_get_info(env, OPENSSL_X509_INFO_FINGER,cert);
x509_cert_key_id = openssl_x509_get_subject_key_identifier(env, cert);
+ x509_common_name = openssl_x509_get_common_name(env,cert);
/*Create X509 certificate*/
oxs_cert = oxs_x509_cert_create(env);
@@ -278,6 +805,7 @@
oxs_x509_cert_set_fingerprint(oxs_cert, env, x509_cert_fingerprint);
oxs_x509_cert_set_serial_number(oxs_cert, env, openssl_x509_get_serial(env, cert));
oxs_x509_cert_set_key_identifier(oxs_cert, env, x509_cert_key_id);
+ oxs_x509_cert_set_common_name(oxs_cert, env, x509_common_name);
/*Additionally we need to set the public key*/
openssl_x509_get_pubkey(env, cert, &pubkey);
@@ -302,6 +830,8 @@
x509_cert_fingerprint = NULL;
AXIS2_FREE(env->allocator, x509_cert_key_id);
x509_cert_key_id = NULL;
+ AXIS2_FREE(env->allocator, x509_common_name);
+ x509_common_name = NULL;
/*Free the certificate*/
X509_free(cert);
cert = NULL;