You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ka...@apache.org on 2007/03/07 06:45:02 UTC

svn commit: r515463 - in /webservices/axis2/trunk/c/rampart: include/ src/omxmlsec/ src/omxmlsec/tokens/ src/util/

Author: kaushalye
Date: Tue Mar  6 21:45:00 2007
New Revision: 515463

URL: http://svn.apache.org/viewvc?view=rev&rev=515463
Log:
Adding a token processor for Rampart. 

Added:
    webservices/axis2/trunk/c/rampart/include/rampart_token_processor.h
    webservices/axis2/trunk/c/rampart/src/util/rampart_token_processor.c
Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_token_reference.h
    webservices/axis2/trunk/c/rampart/include/oxs_x509_cert.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_reference.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_key_processor.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
    webservices/axis2/trunk/c/rampart/src/util/Makefile.am

Modified: webservices/axis2/trunk/c/rampart/include/oxs_token_reference.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_reference.h?view=diff&rev=515463&r1=515462&r2=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_reference.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_reference.h Tue Mar  6 21:45:00 2007
@@ -47,6 +47,8 @@
 AXIS2_EXTERN axis2_char_t* AXIS2_CALL
 oxs_token_get_reference(const axis2_env_t *env, axiom_node_t *ref_node);
 
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+oxs_token_get_reference_value_type(const axis2_env_t *env, axiom_node_t *ref_node);
 /** @} */
 #ifdef __cplusplus
 }

Modified: webservices/axis2/trunk/c/rampart/include/oxs_x509_cert.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_x509_cert.h?view=diff&rev=515463&r1=515462&r2=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_x509_cert.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_x509_cert.h Tue Mar  6 21:45:00 2007
@@ -261,7 +261,13 @@
 oxs_x509_cert_set_public_key(oxs_x509_cert_t *x509_cert,
     const axis2_env_t *env,
     openssl_pkey_t *public_key);
-
+/**
+ * Copy contents of a certificate to another
+ * @param x509_cert the X509 certificate, the source
+ * @param env pointer to environment struct
+ * @param to, another x509 certificate, the target
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_x509_cert_copy_to(oxs_x509_cert_t *x509_cert,
     const axis2_env_t *env,

Added: webservices/axis2/trunk/c/rampart/include/rampart_token_processor.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart_token_processor.h?view=auto&rev=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart_token_processor.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart_token_processor.h Tue Mar  6 21:45:00 2007
@@ -0,0 +1,66 @@
+/*
+ *   Copyright 2003-2004 The Apache Software Foundation.
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+
+
+#include <axis2_utils_defines.h>
+#include <axis2_defines.h>
+#include <axis2_date_time.h>
+#include <axis2_env.h>
+#include <axis2_property.h>
+#include <axis2_msg_ctx.h>
+#include <rampart_authn_provider.h>
+#include <rampart_credentials.h>
+#include <rampart_callback.h>
+/**
+  * @file rampart_token_processor.h
+  * @brief Token processing of rampart
+  */
+#ifndef RAMPART_TOKEN_PROCESSOR_H
+#define RAMPART_TOKEN_PROCESSOR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_direct_ref(const axis2_env_t *env,
+    axiom_node_t *ref_node,
+    axoim_node_t *scope_node,   
+    oxs_x509_cert_t *cert);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_embedded(const axis2_env_t *env,
+    axiom_node_t *embed_node,
+    oxs_x509_cert_t *cert);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_key_identifier(const axis2_env_t *env,
+    axiom_node_t *ki_node,
+    oxs_x509_cert_t *cert);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_x509_data(const axis2_env_t *env,
+    axiom_node_t *x509_data_node,
+        oxs_x509_cert_t *cert);
+/* @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* !RAMPART_TOKEN_PROCESSOR_H */
+                                                                                                                           
+

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_reference.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_reference.c?view=diff&rev=515463&r1=515462&r2=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_reference.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_reference.c Tue Mar  6 21:45:00 2007
@@ -80,3 +80,20 @@
 
 }
 
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+oxs_token_get_reference_value_type(const axis2_env_t *env, axiom_node_t *ref_node)
+{
+    axis2_char_t *val_type = NULL;
+    axiom_element_t *reference_ele = NULL;
+
+    reference_ele = AXIOM_NODE_GET_DATA_ELEMENT(ref_node, env);
+    if (!reference_ele)
+    {
+        oxs_error(env, ERROR_LOCATION,
+                OXS_ERROR_ELEMENT_FAILED, "Error retrieving data reference element");
+        return NULL;
+    }
+
+    val_type = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(reference_ele, env, OXS_ATTR_VALUE_TYPE);
+    return val_type;
+}

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_key_processor.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_key_processor.c?view=diff&rev=515463&r1=515462&r2=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_key_processor.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_key_processor.c Tue Mar  6 21:45:00 2007
@@ -140,8 +140,6 @@
     return status;
 }
 
-
-
 AXIS2_EXTERN  axis2_status_t AXIS2_CALL
 oxs_xml_key_process_X509Data(const axis2_env_t *env,
     axiom_node_t *X509_data_node,

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c?view=diff&rev=515463&r1=515462&r2=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c Tue Mar  6 21:45:00 2007
@@ -332,9 +332,7 @@
     oxs_sign_part_set_id(sign_part, env, ref_id);
 
     /*Remove the # from the id*/ 
-    AXIS2_LOG_INFO(env->log, "[oxs][xml_sig] XXX1 node= %s ", axiom_node_to_string(scope_node, env) );
     ref_id2 =  axis2_string_substring_starting_at(axis2_strdup(ref_id, env), 1);
-    AXIS2_LOG_INFO(env->log, "[oxs][xml_sig] XXX2 node= %s ", axiom_node_to_string(scope_node, env) );
 
     /*Find the node refered by this ref_id2 and set to the sign part*/
     reffed_node = oxs_axiom_get_node_by_id(env, scope_node, "wsu:Id", ref_id2 );

Modified: webservices/axis2/trunk/c/rampart/src/util/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/Makefile.am?view=diff&rev=515463&r1=515462&r2=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/util/Makefile.am Tue Mar  6 21:45:00 2007
@@ -5,7 +5,7 @@
 librampart_util_la_SOURCES = rampart_action.c rampart_crypto_util.c \
 							rampart_util.c rampart_handler_util.c username_token.c  timestamp_token.c \
 							rampart_encryption.c rampart_sec_header_processor.c rampart_sec_processed_result.c \
-							rampart_sec_header_builder.c rampart_context.c rampart_engine.c rampart_signature.c
+							rampart_sec_header_builder.c rampart_context.c rampart_engine.c rampart_token_processor.c rampart_signature.c
 
 
 librampart_util_la_LIBADD  = -lssl \

Added: webservices/axis2/trunk/c/rampart/src/util/rampart_token_processor.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_token_processor.c?view=auto&rev=515463
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_token_processor.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_token_processor.c Tue Mar  6 21:45:00 2007
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* 
+ *
+ */
+#include <stdio.h>
+#include <rampart_util.h>
+#include <axis2_util.h>
+#include <axis2_base64.h>
+#include <oxs_buffer.h>
+#include <rampart_constants.h>
+#include <oxs_constants.h>
+#include <oxs_key_mgr.h>
+#include <oxs_axiom.h>
+#include <oxs_x509_cert.h>
+#include <oxs_token_reference.h>
+#include <oxs_token_binary_security_token.h>
+#include <oxs_xml_key_processor.h>
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_security_token_reference(const axis2_env_t *env,
+    axiom_node_t *st_ref_node,
+    axiom_node_t *scope_node,/*Can be NULL for all other scenarios but the Direct Reference*/
+    oxs_x509_cert_t *cert)
+{
+    axis2_char_t *child_name = NULL;
+    axiom_node_t *child_node = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+
+    child_node = AXIOM_NODE_GET_FIRST_CHILD(st_ref_node, env);
+    child_name = axiom_util_get_localname(child_node, env);
+
+    if(0 == axis2_strcmp(child_name, OXS_NODE_REFERENCE)){
+        status = rampart_token_process_direct_ref(env, child_node, scope_node, cert);
+    }else if(0 == axis2_strcmp(child_name, OXS_NODE_EMBEDDED)){
+        status = rampart_token_process_embedded(env, child_node, cert);
+    }else if(0 == axis2_strcmp(child_name, OXS_NODE_KEY_IDENTIFIER)){
+        status = rampart_token_process_key_identifier(env, child_node, cert);
+    }else if(0 == axis2_strcmp(child_name, OXS_NODE_X509_DATA)){
+        status = rampart_token_process_x509_data(env, child_node, cert);
+    }else{
+        /*We do not support*/
+        return AXIS2_FAILURE;
+    }
+
+    return status;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_direct_ref(const axis2_env_t *env, 
+    axiom_node_t *ref_node,
+    axiom_node_t *scope_node,
+    oxs_x509_cert_t *cert)
+{
+    axis2_char_t *ref = NULL;
+    axis2_char_t *ref_id = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axiom_node_t *bst_node = NULL;
+    axis2_char_t *data = NULL;
+    oxs_x509_cert_t *_cert = NULL;
+
+    /*Select ref using node*/
+    ref = oxs_token_get_reference(env, ref_node);
+    ref_id = axis2_string_substring_starting_at(axis2_strdup(ref, env), 1);
+
+    /*Find the token with the id=ref_id within the scope of scope_node*/
+    bst_node = oxs_axiom_get_node_by_id(env, scope_node, OXS_ATTR_ID, ref_id);
+    if(!bst_node){
+        oxs_error(env, ERROR_LOCATION, OXS_ERROR_ELEMENT_FAILED, "Error retrieving element with ID=%s", ref_id);
+        return AXIS2_FAILURE;
+    }
+
+    data = oxs_axiom_get_node_content(env, bst_node);
+    /*Process data*/
+    _cert = oxs_key_mgr_load_x509_cert_from_string(env, data);
+    if(_cert){
+        status =  AXIS2_SUCCESS;
+    }else{
+        status =  AXIS2_FAILURE;
+    }
+ 
+    oxs_x509_cert_copy_to(_cert, env, cert);
+    return status;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_embedded(const axis2_env_t *env,
+    axiom_node_t *embed_node,
+    oxs_x509_cert_t *cert)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_char_t *data = NULL;
+    oxs_x509_cert_t *_cert = NULL;
+    
+    data = oxs_axiom_get_node_content(env, embed_node);
+    /*Process data*/
+    _cert = oxs_key_mgr_load_x509_cert_from_string(env, data);
+    if(_cert){
+        status =  AXIS2_SUCCESS;
+    }else{
+        status =  AXIS2_FAILURE;
+    }
+
+    oxs_x509_cert_copy_to(_cert, env, cert);
+    return status;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_key_identifier(const axis2_env_t *env,
+    axiom_node_t *ki_node,
+    oxs_x509_cert_t *cert)
+{
+    axis2_char_t *ki = NULL;
+
+    ki = oxs_axiom_get_node_content(env, ki_node);
+    oxs_x509_cert_set_key_identifier(cert, env, ki);
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_token_process_x509_data(const axis2_env_t *env,
+    axiom_node_t *x509_data_node,
+    oxs_x509_cert_t *cert)
+{
+    return oxs_xml_key_process_X509Data(env, x509_data_node, cert);
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org