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 da...@apache.org on 2010/02/12 11:19:42 UTC

svn commit: r909338 - in /webservices/rampart/trunk/c: include/oxs_x509_cert.h src/omxmlsec/openssl/pkcs12_keystore.c src/omxmlsec/x509_cert.c

Author: danushka
Date: Fri Feb 12 10:19:42 2010
New Revision: 909338

URL: http://svn.apache.org/viewvc?rev=909338&view=rev
Log:
Added new members and required method in to oxs_x509_cert to have valid from date, version and alias

Modified:
    webservices/rampart/trunk/c/include/oxs_x509_cert.h
    webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12_keystore.c
    webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c

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=909338&r1=909337&r2=909338&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/oxs_x509_cert.h (original)
+++ webservices/rampart/trunk/c/include/oxs_x509_cert.h Fri Feb 12 10:19:42 2010
@@ -153,6 +153,36 @@
     oxs_x509_cert_get_public_key(oxs_x509_cert_t *x509_cert,
                                  const axutil_env_t *env);
 
+	/**
+     * Get the date from when the X509 Certificate is valid
+     * @param x509_cert the X509 certificate
+     * @param env pointer to environment struct
+     * @return the date from when the X509 Certificate is valid
+     */
+	AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+	oxs_x509_cert_get_valid_from(oxs_x509_cert_t *x509_cert,
+								 const axutil_env_t* env);
+
+	/**
+     * Get the version of X509 Certificate
+     * @param x509_cert the X509 certificate
+     * @param env pointer to environment struct
+     * @return the version of X509 certificate
+     */
+	AXIS2_EXTERN int AXIS2_CALL
+	oxs_x509_cert_get_version(oxs_x509_cert_t* x509_cert,
+							  const axutil_env_t* env);
+
+	/**
+     * Get the alias (i.e. friendly name) of X509 Certificate
+     * @param x509_cert the X509 certificate
+     * @param env pointer to environment struct
+     * @return the alias of X509 certificate
+     */
+	AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+	oxs_x509_cert_get_alias(oxs_x509_cert_t* x509_cert,
+							const axutil_env_t* env);
+
     /*Setters*/
     /**
      * Set the serial number of X509 Certificate

Modified: webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12_keystore.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12_keystore.c?rev=909338&r1=909337&r2=909338&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12_keystore.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/openssl/pkcs12_keystore.c Fri Feb 12 10:19:42 2010
@@ -208,6 +208,9 @@
     axis2_char_t *x509_common_name = NULL;
     EVP_PKEY *pub_key = NULL;
     openssl_pkey_t *open_pubkey = NULL;
+	axis2_char_t* x509_cert_valid_from = NULL;
+	int x509_cert_version = 0;
+	axis2_char_t* x509_cert_alias = NULL;
     oxs_x509_cert_t *cert_out = NULL;
 
     x509_cert_data = openssl_x509_get_cert_data(env, cert_in);
@@ -217,6 +220,9 @@
     x509_cert_finger = openssl_x509_get_info(env, OPENSSL_X509_INFO_FINGER, cert_in);
     x509_cert_key_id = openssl_x509_get_subject_key_identifier(env, cert_in);
     x509_common_name = openssl_x509_get_common_name(env, cert_in);
+	x509_cert_valid_from = openssl_x509_get_info(env, OPENSSL_X509_INFO_VALID_FROM, cert_in);
+	x509_cert_version = atoi(openssl_x509_get_info(env, OPENSSL_X509_INFO_VERSION, cert_in));
+	x509_cert_alias = openssl_x509_get_alias(env, cert_in);
 
     cert_out = oxs_x509_cert_create(env);
     if (!cert_out) {
@@ -231,6 +237,9 @@
     oxs_x509_cert_set_serial_number(cert_out, env, openssl_x509_get_serial(env, cert_in));
     oxs_x509_cert_set_key_identifier(cert_out, env, x509_cert_key_id);
     oxs_x509_cert_set_common_name(cert_out, env, x509_common_name);
+	oxs_x509_cert_set_valid_from(cert_out, env, x509_cert_valid_from);
+	oxs_x509_cert_set_version(cert_out, env, x509_cert_version);
+	oxs_x509_cert_set_alias(cert_out, env, x509_cert_alias);
 
     openssl_x509_get_pubkey(env, cert_in, &pub_key);
     open_pubkey = openssl_pkey_create(env);

Modified: webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c?rev=909338&r1=909337&r2=909338&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c Fri Feb 12 10:19:42 2010
@@ -33,6 +33,9 @@
     axis2_char_t *data;
 	axis2_char_t *common_name;
     openssl_pkey_t *public_key;
+	axis2_char_t *valid_from;
+	int version;
+	axis2_char_t *alias;
 };
 
 
@@ -63,6 +66,9 @@
     x509_cert->data =NULL;
     x509_cert->public_key =NULL;
 	x509_cert->common_name = NULL;
+	x509_cert->valid_from = NULL;
+	x509_cert->version = 0;
+	x509_cert->alias = NULL;
 
     return x509_cert;
 }
@@ -110,6 +116,17 @@
         	x509_cert->common_name = NULL;
     }
 
+	if(x509_cert->valid_from)
+	{
+		AXIS2_FREE(env->allocator, x509_cert->valid_from);
+		x509_cert->valid_from = NULL;
+	}
+	if(x509_cert->alias)
+	{
+		AXIS2_FREE(env->allocator, x509_cert->alias);
+		x509_cert->alias = NULL;
+	}
+
     AXIS2_FREE(env->allocator,  x509_cert);
     x509_cert = NULL;
 
@@ -132,6 +149,9 @@
     openssl_pkey_increment_ref(x509_cert->public_key, env);
     oxs_x509_cert_set_public_key(to, env, x509_cert->public_key);
 	oxs_x509_cert_set_common_name(to, env, x509_cert->common_name);
+	oxs_x509_cert_set_valid_from(to, env, x509_cert->valid_from);
+	oxs_x509_cert_set_version(to, env, x509_cert->version);
+	oxs_x509_cert_set_alias(to, env, x509_cert->alias);
 
     return AXIS2_SUCCESS;
 }
@@ -192,6 +212,27 @@
     return x509_cert->public_key;
 }
 
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_x509_cert_get_valid_from(oxs_x509_cert_t *x509_cert,
+							 const axutil_env_t* env)
+{
+	return x509_cert->valid_from;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+oxs_x509_cert_get_version(oxs_x509_cert_t* x509_cert,
+						  const axutil_env_t* env)
+{
+	return x509_cert->version;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_x509_cert_get_alias(oxs_x509_cert_t* x509_cert,
+						const axutil_env_t* env)
+{
+	return x509_cert->alias;
+}
+
 AXIS2_EXTERN axis2_char_t * AXIS2_CALL
 oxs_x509_cert_get_common_name(oxs_x509_cert_t *x509_cert,
 							  const axutil_env_t *env)
@@ -330,3 +371,43 @@
     return AXIS2_SUCCESS;
 }
 
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_x509_cert_set_valid_from(oxs_x509_cert_t* x509_cert,
+							 const axutil_env_t* env,
+							 axis2_char_t* valid_from)
+{
+	if(x509_cert->valid_from)
+	{
+		AXIS2_FREE(env->allocator, x509_cert->valid_from);
+		x509_cert->valid_from = NULL;
+	}
+
+	x509_cert->valid_from = axutil_strdup(env, valid_from);
+	return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_x509_cert_set_version(oxs_x509_cert_t* x509_cert,
+						  const axutil_env_t* env,
+						  int version)
+{
+	x509_cert->version = version;
+	return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_x509_cert_set_alias(oxs_x509_cert_t* x509_cert,
+					    const axutil_env_t* env,
+						axis2_char_t* alias)
+{
+	if(x509_cert->alias)
+	{
+		AXIS2_FREE(env->allocator, x509_cert->alias);
+		x509_cert->alias = NULL;
+	}
+
+	x509_cert->alias = axutil_strdup(env, alias);
+	return AXIS2_SUCCESS;
+}
\ No newline at end of file