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 sh...@apache.org on 2008/02/11 12:15:16 UTC

svn commit: r620462 - in /webservices/rampart/trunk/c: samples/client/sec_echo/echo.c src/secconv/security_context_token.c

Author: shankar
Date: Mon Feb 11 03:15:11 2008
New Revision: 620462

URL: http://svn.apache.org/viewvc?rev=620462&view=rev
Log:
file encoding problem

Modified:
    webservices/rampart/trunk/c/samples/client/sec_echo/echo.c
    webservices/rampart/trunk/c/src/secconv/security_context_token.c

Modified: webservices/rampart/trunk/c/samples/client/sec_echo/echo.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/client/sec_echo/echo.c?rev=620462&r1=620461&r2=620462&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/client/sec_echo/echo.c (original)
+++ webservices/rampart/trunk/c/samples/client/sec_echo/echo.c Mon Feb 11 03:15:11 2008
@@ -1,216 +1,216 @@
-/*
- * 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 <axiom.h>
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-#include <rampart_constants.h>
-#include <neethi_util.h>
-#include <neethi_policy.h>
-
-axiom_node_t *
-build_om_payload_for_echo_svc(const axutil_env_t *env);
-
-
-int main(int argc, char** argv)
-{
-    const axutil_env_t *env = NULL;
-    const axis2_char_t *address = NULL;
-    const axis2_char_t *client_home = NULL;
-    axis2_char_t *file_name = NULL;
-    axis2_char_t *policy_file = NULL;
-    axis2_endpoint_ref_t* endpoint_ref = NULL;
-    axis2_options_t *options = NULL;
-    axis2_svc_client_t* svc_client = NULL;
-    axiom_node_t *payload = NULL;
-    axiom_node_t *ret_node = NULL;
-    axis2_status_t status = AXIS2_FAILURE;
-    neethi_policy_t *policy = NULL;
-	
-	/* Set up the environment */
-    env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
-
-    /* Set end-point-reference of echo service */
-    address = "http://localhost:9090/axis2/services/echo";
-    if (argc > 2)
-    {
-        address = argv[1];
-        client_home = argv[2];
-        printf("Using endpoint : %s\n", address);
-        printf("Using client_home : %s\n", client_home);
-    }
-
-    if (axutil_strcmp(address, "-h") == 0)
-    {
-        printf("Usage : %s [endpoint_url] [client_home]\n", argv[0]);
-        printf("use -h for help\n");
-        return 0;
-    }
-
-    /* Create end-point-reference with given address */
-    endpoint_ref = axis2_endpoint_ref_create(env, address);
-
-    /* Setup options */
-    options = axis2_options_create(env);
-    axis2_options_set_to(options, env, endpoint_ref);
-    axis2_options_set_action(options, env,
-            "http://example.com/ws/2004/09/policy/Test/EchoRequest");
-    /*axis2_options_set_action(options, env,
-            "urn:echo");*/
-
-
-    /*If the client home is not specified, use the AXIS2C_HOME*/
-    if (!client_home)
-    {
-        client_home = AXIS2_GETENV("AXIS2C_HOME");
-        printf("\nNo client_home specified. Using default %s", client_home);
-    }
-
-    /* Create service client */
-    printf("client_home= %s", client_home);
-    svc_client = axis2_svc_client_create(env, client_home);
-    if (!svc_client)
-    {
-        printf("Error creating service client\n");
-        return -1;
-    }
-
-    /* Set service client options */
-    axis2_svc_client_set_options(svc_client, env, options);
-
-    /*We need to specify the client's policy file location*/
-    if(client_home)
-    {
-        file_name = axutil_stracat(env, client_home, AXIS2_PATH_SEP_STR);
-        policy_file = axutil_stracat(env, file_name, "policy.xml" );
-        AXIS2_FREE(env->allocator, file_name);
-        file_name = NULL;        
-    }else{
-        printf("Client Home not Specified\n");
-        printf("echo client invoke FAILED!\n");
-        return 0;
-    }
-    /*Create the policy, from file*/   
-    policy = neethi_util_create_policy_from_file(env, policy_file);
-    if(policy_file){
-        AXIS2_FREE(env->allocator, policy_file);
-        policy_file = NULL;
-    }
-    if(!policy)
-    {
-        printf("\nPolicy creation failed from the file. %s\n", policy_file);
-    }
-
-    status = axis2_svc_client_set_policy(svc_client, env, policy);
-
-    if(status == AXIS2_FAILURE)
-    {
-        printf("Policy setting failed\n");
-    }
-    
-    /* Build the SOAP request message payload using OM API.*/
-    payload = build_om_payload_for_echo_svc(env);
-    
-    /*If not engaged in the client's axis2.xml, uncomment this line*/
-    /*axis2_svc_client_engage_module(svc_client, env, "rampart");*/
-    
-    /* Send request */
-    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
-
-
-    if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
-    {
-        axiom_soap_envelope_t *soap_envelope = NULL;
-        axiom_soap_body_t *soap_body = NULL;
-        axiom_soap_fault_t *soap_fault = NULL;
-
-        printf ("\nResponse has a SOAP fault\n");
-        soap_envelope =
-            axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
-        if (soap_envelope)
-            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
-        if (soap_body)
-            soap_fault = axiom_soap_body_get_fault(soap_body, env);
-        if (soap_fault)
-        {
-            printf("\nReturned SOAP fault: %s\n",
-            axiom_node_to_string(axiom_soap_fault_get_base_node(soap_fault,env),
-                env));
-        }
-            printf("echo client invoke FAILED!\n");
-            return -1;
-    }
-    
-    if (ret_node)
-    {
-        axis2_char_t *om_str = NULL;
-        om_str = axiom_node_to_string(ret_node, env);
-        if (om_str)
-        {
-            printf("\nReceived OM : %s\n", om_str);
-        }
-        printf("\necho client invoke SUCCESSFUL!\n");
-        AXIS2_FREE(env->allocator, om_str);
-        ret_node = NULL;
-    }
-    else
-    {
-        printf("echo client invoke FAILED!\n");
-        return -1;
-    }
-
-    if (svc_client)
-    {
-        axis2_svc_client_free(svc_client, env);
-        svc_client = NULL;
-    }
-    if (env)
-    {
-        axutil_env_free((axutil_env_t *) env);
-        env = NULL;
-    }
-    
-    return 0;
-}
-
-/* build SOAP request message content using OM */
-axiom_node_t *
-build_om_payload_for_echo_svc(const axutil_env_t *env)
-{
-    axiom_node_t *echo_om_node = NULL;
-    axiom_element_t* echo_om_ele = NULL;
-    axiom_node_t* text_om_node = NULL;
-    axiom_element_t * text_om_ele = NULL;
-    axiom_namespace_t *ns1 = NULL;
-    axis2_char_t *om_str = NULL;
-
+/*
+ * 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 <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+#include <rampart_constants.h>
+#include <neethi_util.h>
+#include <neethi_policy.h>
+
+axiom_node_t *
+build_om_payload_for_echo_svc(const axutil_env_t *env);
+
+
+int main(int argc, char** argv)
+{
+    const axutil_env_t *env = NULL;
+    const axis2_char_t *address = NULL;
+    const axis2_char_t *client_home = NULL;
+    axis2_char_t *file_name = NULL;
+    axis2_char_t *policy_file = NULL;
+    axis2_endpoint_ref_t* endpoint_ref = NULL;
+    axis2_options_t *options = NULL;
+    axis2_svc_client_t* svc_client = NULL;
+    axiom_node_t *payload = NULL;
+    axiom_node_t *ret_node = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    neethi_policy_t *policy = NULL;
+	
+	/* Set up the environment */
+    env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
+
+    /* Set end-point-reference of echo service */
+    address = "http://localhost:9090/axis2/services/echo";
+    if (argc > 2)
+    {
+        address = argv[1];
+        client_home = argv[2];
+        printf("Using endpoint : %s\n", address);
+        printf("Using client_home : %s\n", client_home);
+    }
+
+    if (axutil_strcmp(address, "-h") == 0)
+    {
+        printf("Usage : %s [endpoint_url] [client_home]\n", argv[0]);
+        printf("use -h for help\n");
+        return 0;
+    }
+
+    /* Create end-point-reference with given address */
+    endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+    /* Setup options */
+    options = axis2_options_create(env);
+    axis2_options_set_to(options, env, endpoint_ref);
+    axis2_options_set_action(options, env,
+            "http://example.com/ws/2004/09/policy/Test/EchoRequest");
+    /*axis2_options_set_action(options, env,
+            "urn:echo");*/
+
+
+    /*If the client home is not specified, use the AXIS2C_HOME*/
+    if (!client_home)
+    {
+        client_home = AXIS2_GETENV("AXIS2C_HOME");
+        printf("\nNo client_home specified. Using default %s", client_home);
+    }
+
+    /* Create service client */
+    printf("client_home= %s", client_home);
+    svc_client = axis2_svc_client_create(env, client_home);
+    if (!svc_client)
+    {
+        printf("Error creating service client\n");
+        return -1;
+    }
+
+    /* Set service client options */
+    axis2_svc_client_set_options(svc_client, env, options);
+
+    /*We need to specify the client's policy file location*/
+    if(client_home)
+    {
+        file_name = axutil_stracat(env, client_home, AXIS2_PATH_SEP_STR);
+        policy_file = axutil_stracat(env, file_name, "policy.xml" );
+        AXIS2_FREE(env->allocator, file_name);
+        file_name = NULL;        
+    }else{
+        printf("Client Home not Specified\n");
+        printf("echo client invoke FAILED!\n");
+        return 0;
+    }
+    /*Create the policy, from file*/   
+    policy = neethi_util_create_policy_from_file(env, policy_file);
+    if(policy_file){
+        AXIS2_FREE(env->allocator, policy_file);
+        policy_file = NULL;
+    }
+    if(!policy)
+    {
+        printf("\nPolicy creation failed from the file. %s\n", policy_file);
+    }
+
+    status = axis2_svc_client_set_policy(svc_client, env, policy);
+
+    if(status == AXIS2_FAILURE)
+    {
+        printf("Policy setting failed\n");
+    }
+    
+    /* Build the SOAP request message payload using OM API.*/
+    payload = build_om_payload_for_echo_svc(env);
+    
+    /*If not engaged in the client's axis2.xml, uncomment this line*/
+    /*axis2_svc_client_engage_module(svc_client, env, "rampart");*/
+    
+    /* Send request */
+    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+
+    if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
+    {
+        axiom_soap_envelope_t *soap_envelope = NULL;
+        axiom_soap_body_t *soap_body = NULL;
+        axiom_soap_fault_t *soap_fault = NULL;
+
+        printf ("\nResponse has a SOAP fault\n");
+        soap_envelope =
+            axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
+        if (soap_envelope)
+            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+        if (soap_body)
+            soap_fault = axiom_soap_body_get_fault(soap_body, env);
+        if (soap_fault)
+        {
+            printf("\nReturned SOAP fault: %s\n",
+            axiom_node_to_string(axiom_soap_fault_get_base_node(soap_fault,env),
+                env));
+        }
+            printf("echo client invoke FAILED!\n");
+            return -1;
+    }
+    
+    if (ret_node)
+    {
+        axis2_char_t *om_str = NULL;
+        om_str = axiom_node_to_string(ret_node, env);
+        if (om_str)
+        {
+            printf("\nReceived OM : %s\n", om_str);
+        }
+        printf("\necho client invoke SUCCESSFUL!\n");
+        AXIS2_FREE(env->allocator, om_str);
+        ret_node = NULL;
+    }
+    else
+    {
+        printf("echo client invoke FAILED!\n");
+        return -1;
+    }
+
+    if (svc_client)
+    {
+        axis2_svc_client_free(svc_client, env);
+        svc_client = NULL;
+    }
+    if (env)
+    {
+        axutil_env_free((axutil_env_t *) env);
+        env = NULL;
+    }
+    
+    return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_payload_for_echo_svc(const axutil_env_t *env)
+{
+    axiom_node_t *echo_om_node = NULL;
+    axiom_element_t* echo_om_ele = NULL;
+    axiom_node_t* text_om_node = NULL;
+    axiom_element_t * text_om_ele = NULL;
+    axiom_namespace_t *ns1 = NULL;
+    axis2_char_t *om_str = NULL;
+
     ns1 = axiom_namespace_create(env, "http://ws.apache.org/rampart/c/samples", "ns1");
-    echo_om_ele = axiom_element_create(env, NULL, "echoIn", ns1, &echo_om_node);    
-    
+    echo_om_ele = axiom_element_create(env, NULL, "echoIn", ns1, &echo_om_node);    
+    
     text_om_ele = axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node);
-    axiom_element_set_text(text_om_ele, env, "Hello", text_om_node);
-
-    om_str = axiom_node_to_string(echo_om_node, env);
-    if (om_str){
-        printf("\nSending OM : %s\n", om_str);
-        AXIS2_FREE(env->allocator, om_str);
-        om_str =  NULL;
-    }
-    return echo_om_node;
-}
+    axiom_element_set_text(text_om_ele, env, "Hello", text_om_node);
+
+    om_str = axiom_node_to_string(echo_om_node, env);
+    if (om_str){
+        printf("\nSending OM : %s\n", om_str);
+        AXIS2_FREE(env->allocator, om_str);
+        om_str =  NULL;
+    }
+    return echo_om_node;
+}

Modified: webservices/rampart/trunk/c/src/secconv/security_context_token.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/secconv/security_context_token.c?rev=620462&r1=620461&r2=620462&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/secconv/security_context_token.c (original)
+++ webservices/rampart/trunk/c/src/secconv/security_context_token.c Mon Feb 11 03:15:11 2008
@@ -1,357 +1,357 @@
-/*
- * 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 <secconv_security_context_token.h>
-#include <oxs_buffer.h>
-#include <oxs_tokens.h>
-#include <trust_constants.h>
-
-struct security_context_token_t
-{
-    oxs_buffer_t *buffer;
-    axis2_char_t *global_id;
-    axis2_char_t *local_id;
-};
-
-AXIS2_EXTERN security_context_token_t *AXIS2_CALL
-    security_context_token_create(
-    const axutil_env_t * env)
-{
-    security_context_token_t *sct = NULL;
-
-    AXIS2_ENV_CHECK(env, NULL);
-
-    sct =  (security_context_token_t *) AXIS2_MALLOC (env->allocator,
-                       sizeof (security_context_token_t));
-
-    if(sct == NULL)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-    
-    sct->buffer = NULL;
-    sct->global_id = NULL;
-    sct->local_id = NULL;
-    return sct;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-security_context_token_free(
-    security_context_token_t *sct, 
-    const axutil_env_t *env)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    if(sct->buffer)
-    {
-        oxs_buffer_free(sct->buffer, env);
-    }
-    AXIS2_FREE(env->allocator, sct);
-    return;
-}
-
-AXIS2_EXTERN oxs_buffer_t *AXIS2_CALL
-security_context_token_get_secret(
-    security_context_token_t * sct, 
-    const axutil_env_t * env)
-{
-    return sct->buffer;
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-security_context_token_get_global_identifier(
-    security_context_token_t * sct, 
-    const axutil_env_t * env)
-{
-    return sct->global_id;
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-security_context_token_get_local_identifier(
-    security_context_token_t * sct, 
-    const axutil_env_t * env)
-{
-    return sct->local_id;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_secret(
-    security_context_token_t * sct, 
-    const axutil_env_t * env,
-    oxs_buffer_t *buffer)
-{
-    sct->buffer = buffer;
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_global_identifier(
-    security_context_token_t * sct, 
-    const axutil_env_t * env,
-    axis2_char_t *global_id)
-{
-    sct->global_id = global_id;
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_local_identifier(
-    security_context_token_t * sct, 
-    const axutil_env_t * env,
-    axis2_char_t *local_id)
-{
-    sct->local_id = local_id;
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-security_context_token_get_requested_proof_token(
-    security_context_token_t *sct, 
-    const axutil_env_t * env)
-{
-    int encodedlen;
-    axis2_char_t *encoded_str = NULL;
-    axiom_node_t* proof_token = NULL;
-    axiom_element_t *proof_token_ele = NULL;
-    axiom_node_t* secret_node = NULL;
-    axiom_element_t *secret_ele = NULL;
-    axiom_namespace_t *ns_obj_wst = NULL;
-
-    if(!sct->buffer)
-    {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have a shared secret");
-        return NULL;
-    }
-
-    encodedlen = axutil_base64_encode_len(oxs_buffer_get_size(sct->buffer, env));
-    encoded_str = AXIS2_MALLOC(env->allocator, encodedlen);
-    axutil_base64_encode(encoded_str, (const char *)oxs_buffer_get_data(sct->buffer, env), oxs_buffer_get_size(sct->buffer, env));
-    
-    ns_obj_wst = axiom_namespace_create(env, TRUST_WST_XMLNS, TRUST_WST);
-    proof_token_ele = axiom_element_create(env, NULL, TRUST_REQUESTED_PROOF_TOKEN, ns_obj_wst, &proof_token);
-    if (!proof_token_ele)
-    {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot create requested proof token");
-        return NULL;
-    }
-
-    secret_ele = axiom_element_create(env, proof_token, TRUST_BINARY_SECRET, ns_obj_wst, &secret_node);
-    if(!secret_ele)
-    {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot create binary secret token");
-        return NULL;
-    }
-    axiom_element_set_text(secret_ele, env, encoded_str, secret_node);
-
-    return proof_token;
-}
-
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-security_context_token_get_attached_reference(
-    security_context_token_t *sct, 
-    const axutil_env_t * env)
-{
-    axiom_node_t *str_token = NULL;
-    axiom_node_t *ref_token = NULL;
-
-    if(!sct->local_id)
-    {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have a local identifier");
-        return NULL;
-    }
-
-    str_token = oxs_token_build_security_token_reference_element(env, NULL); 
-    ref_token = oxs_token_build_reference_element(env, str_token, sct->local_id, OXS_VALUE_TYPE_SECURITY_CONTEXT_TOKEN);   
-    return str_token; 
-}
-
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-security_context_token_get_unattached_reference(
-    security_context_token_t *sct, 
-    const axutil_env_t * env)
-{
-    axiom_node_t *str_token = NULL;
-    axiom_node_t *ref_token = NULL;
-    
-    if(!sct->global_id)
-    {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have a global identifier");
-        return NULL;
-    }
-
-    str_token = oxs_token_build_security_token_reference_element(env, NULL); 
-    ref_token = oxs_token_build_reference_element(env, str_token, sct->global_id, OXS_VALUE_TYPE_SECURITY_CONTEXT_TOKEN);   
-    return str_token; 
-}
-
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-security_context_token_get_token(
-    security_context_token_t *sct, 
-    const axutil_env_t * env)
-{
-    axiom_node_t* sct_token = NULL;
-    axiom_element_t *token_ele = NULL;
-    axiom_node_t* identifier_node = NULL;
-    axiom_element_t *identifier_ele = NULL;
-    axiom_namespace_t *ns_obj_sc = NULL;
-    axiom_namespace_t *ns_obj_wsu = NULL;
-    axiom_attribute_t *id_attr = NULL;
-
-    if(!sct->global_id)
-    {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have an identifier.");
-        return NULL;
-    }
-
-    ns_obj_sc = axiom_namespace_create(env, OXS_WSC_NS, OXS_WSC);
-    token_ele = axiom_element_create(env, NULL, OXS_NODE_SECURITY_CONTEXT_TOKEN, ns_obj_sc, &sct_token);
-    if (!token_ele)
-    {
-        oxs_error(env, ERROR_LOCATION,
-                  OXS_ERROR_ELEMENT_FAILED, "Error creating SecurityContextToken element");
-        return NULL;
-    }
-
-    if(sct->local_id)
-    {
-        ns_obj_wsu = axiom_namespace_create(env, OXS_WSU_XMLNS, OXS_WSU);
-        id_attr = axiom_attribute_create(env, OXS_ATTR_ID, axutil_string_substring_starting_at(axutil_strdup(env, sct->local_id), 1), ns_obj_wsu);
-        axiom_element_add_attribute(token_ele, env, id_attr, sct_token);
-    }
-
-    identifier_ele = axiom_element_create(env, sct_token, OXS_NODE_IDENTIFIER, ns_obj_sc, &identifier_node);
-    if(!identifier_ele)
-    {
-        oxs_error(env, ERROR_LOCATION,
-                  OXS_ERROR_ELEMENT_FAILED, "Error creating SecurityContextToken element");
-        return NULL;
-    }
-    axiom_element_set_text(identifier_ele, env, sct->global_id, identifier_node);
-
-    return sct_token;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_requested_proof_token(
-    security_context_token_t *sct, 
-    const axutil_env_t * env,
-    axiom_node_t *node)
-{
-    /*axiom_node_t *secret_node = NULL;*/
-    axis2_char_t *shared_secret = NULL;
-    int decoded_len = 0;
-    axis2_char_t *decoded_shared_secret = NULL;
-
-    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, sct, AXIS2_FAILURE);
-
+/*
+ * 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 <secconv_security_context_token.h>
+#include <oxs_buffer.h>
+#include <oxs_tokens.h>
+#include <trust_constants.h>
+
+struct security_context_token_t
+{
+    oxs_buffer_t *buffer;
+    axis2_char_t *global_id;
+    axis2_char_t *local_id;
+};
+
+AXIS2_EXTERN security_context_token_t *AXIS2_CALL
+    security_context_token_create(
+    const axutil_env_t * env)
+{
+    security_context_token_t *sct = NULL;
+
+    AXIS2_ENV_CHECK(env, NULL);
+
+    sct =  (security_context_token_t *) AXIS2_MALLOC (env->allocator,
+                       sizeof (security_context_token_t));
+
+    if(sct == NULL)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    
+    sct->buffer = NULL;
+    sct->global_id = NULL;
+    sct->local_id = NULL;
+    return sct;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+security_context_token_free(
+    security_context_token_t *sct, 
+    const axutil_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    if(sct->buffer)
+    {
+        oxs_buffer_free(sct->buffer, env);
+    }
+    AXIS2_FREE(env->allocator, sct);
+    return;
+}
+
+AXIS2_EXTERN oxs_buffer_t *AXIS2_CALL
+security_context_token_get_secret(
+    security_context_token_t * sct, 
+    const axutil_env_t * env)
+{
+    return sct->buffer;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+security_context_token_get_global_identifier(
+    security_context_token_t * sct, 
+    const axutil_env_t * env)
+{
+    return sct->global_id;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+security_context_token_get_local_identifier(
+    security_context_token_t * sct, 
+    const axutil_env_t * env)
+{
+    return sct->local_id;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_secret(
+    security_context_token_t * sct, 
+    const axutil_env_t * env,
+    oxs_buffer_t *buffer)
+{
+    sct->buffer = buffer;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_global_identifier(
+    security_context_token_t * sct, 
+    const axutil_env_t * env,
+    axis2_char_t *global_id)
+{
+    sct->global_id = global_id;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_local_identifier(
+    security_context_token_t * sct, 
+    const axutil_env_t * env,
+    axis2_char_t *local_id)
+{
+    sct->local_id = local_id;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+security_context_token_get_requested_proof_token(
+    security_context_token_t *sct, 
+    const axutil_env_t * env)
+{
+    int encodedlen;
+    axis2_char_t *encoded_str = NULL;
+    axiom_node_t* proof_token = NULL;
+    axiom_element_t *proof_token_ele = NULL;
+    axiom_node_t* secret_node = NULL;
+    axiom_element_t *secret_ele = NULL;
+    axiom_namespace_t *ns_obj_wst = NULL;
+
+    if(!sct->buffer)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have a shared secret");
+        return NULL;
+    }
+
+    encodedlen = axutil_base64_encode_len(oxs_buffer_get_size(sct->buffer, env));
+    encoded_str = AXIS2_MALLOC(env->allocator, encodedlen);
+    axutil_base64_encode(encoded_str, (const char *)oxs_buffer_get_data(sct->buffer, env), oxs_buffer_get_size(sct->buffer, env));
+    
+    ns_obj_wst = axiom_namespace_create(env, TRUST_WST_XMLNS, TRUST_WST);
+    proof_token_ele = axiom_element_create(env, NULL, TRUST_REQUESTED_PROOF_TOKEN, ns_obj_wst, &proof_token);
+    if (!proof_token_ele)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot create requested proof token");
+        return NULL;
+    }
+
+    secret_ele = axiom_element_create(env, proof_token, TRUST_BINARY_SECRET, ns_obj_wst, &secret_node);
+    if(!secret_ele)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot create binary secret token");
+        return NULL;
+    }
+    axiom_element_set_text(secret_ele, env, encoded_str, secret_node);
+
+    return proof_token;
+}
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+security_context_token_get_attached_reference(
+    security_context_token_t *sct, 
+    const axutil_env_t * env)
+{
+    axiom_node_t *str_token = NULL;
+    axiom_node_t *ref_token = NULL;
+
+    if(!sct->local_id)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have a local identifier");
+        return NULL;
+    }
+
+    str_token = oxs_token_build_security_token_reference_element(env, NULL); 
+    ref_token = oxs_token_build_reference_element(env, str_token, sct->local_id, OXS_VALUE_TYPE_SECURITY_CONTEXT_TOKEN);   
+    return str_token; 
+}
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+security_context_token_get_unattached_reference(
+    security_context_token_t *sct, 
+    const axutil_env_t * env)
+{
+    axiom_node_t *str_token = NULL;
+    axiom_node_t *ref_token = NULL;
+    
+    if(!sct->global_id)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have a global identifier");
+        return NULL;
+    }
+
+    str_token = oxs_token_build_security_token_reference_element(env, NULL); 
+    ref_token = oxs_token_build_reference_element(env, str_token, sct->global_id, OXS_VALUE_TYPE_SECURITY_CONTEXT_TOKEN);   
+    return str_token; 
+}
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+security_context_token_get_token(
+    security_context_token_t *sct, 
+    const axutil_env_t * env)
+{
+    axiom_node_t* sct_token = NULL;
+    axiom_element_t *token_ele = NULL;
+    axiom_node_t* identifier_node = NULL;
+    axiom_element_t *identifier_ele = NULL;
+    axiom_namespace_t *ns_obj_sc = NULL;
+    axiom_namespace_t *ns_obj_wsu = NULL;
+    axiom_attribute_t *id_attr = NULL;
+
+    if(!sct->global_id)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Security context token does not have an identifier.");
+        return NULL;
+    }
+
+    ns_obj_sc = axiom_namespace_create(env, OXS_WSC_NS, OXS_WSC);
+    token_ele = axiom_element_create(env, NULL, OXS_NODE_SECURITY_CONTEXT_TOKEN, ns_obj_sc, &sct_token);
+    if (!token_ele)
+    {
+        oxs_error(env, ERROR_LOCATION,
+                  OXS_ERROR_ELEMENT_FAILED, "Error creating SecurityContextToken element");
+        return NULL;
+    }
+
+    if(sct->local_id)
+    {
+        ns_obj_wsu = axiom_namespace_create(env, OXS_WSU_XMLNS, OXS_WSU);
+        id_attr = axiom_attribute_create(env, OXS_ATTR_ID, axutil_string_substring_starting_at(axutil_strdup(env, sct->local_id), 1), ns_obj_wsu);
+        axiom_element_add_attribute(token_ele, env, id_attr, sct_token);
+    }
+
+    identifier_ele = axiom_element_create(env, sct_token, OXS_NODE_IDENTIFIER, ns_obj_sc, &identifier_node);
+    if(!identifier_ele)
+    {
+        oxs_error(env, ERROR_LOCATION,
+                  OXS_ERROR_ELEMENT_FAILED, "Error creating SecurityContextToken element");
+        return NULL;
+    }
+    axiom_element_set_text(identifier_ele, env, sct->global_id, identifier_node);
+
+    return sct_token;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_requested_proof_token(
+    security_context_token_t *sct, 
+    const axutil_env_t * env,
+    axiom_node_t *node)
+{
+    /*axiom_node_t *secret_node = NULL;*/
+    axis2_char_t *shared_secret = NULL;
+    int decoded_len = 0;
+    axis2_char_t *decoded_shared_secret = NULL;
+
+    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, sct, AXIS2_FAILURE);
+
     /*secret_node = oxs_axiom_get_first_child_node_by_name(env, node, TRUST_BINARY_SECRET, TRUST_WST_XMLNS, NULL);
     if(!secret_node)
     {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get binary secret node from proof token");
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get binary secret node from proof token");
         return AXIS2_FAILURE;
     }*/
 
     shared_secret = oxs_axiom_get_node_content(env, node);
     if(!shared_secret)
     {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get content of binary secret node");
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get content of binary secret node");
         return AXIS2_FAILURE;
     }
-    
-    decoded_len = axutil_base64_decode_len(shared_secret);
-	decoded_shared_secret = AXIS2_MALLOC(env->allocator, decoded_len);
-	axutil_base64_decode_binary((unsigned char*)decoded_shared_secret, shared_secret);
-
-    sct->buffer = oxs_buffer_create(env);
-    oxs_buffer_populate(sct->buffer, env, (unsigned char*)decoded_shared_secret, decoded_len);
-
-    AXIS2_FREE(env->allocator, decoded_shared_secret);
-
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_attached_reference(
-    security_context_token_t *sct, 
-    const axutil_env_t * env,
-    axiom_node_t *node)
-{
-    axiom_node_t *ref_token = NULL;
-    axis2_char_t *local_id = NULL;
-
-    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, sct, AXIS2_FAILURE);
-
+    
+    decoded_len = axutil_base64_decode_len(shared_secret);
+	decoded_shared_secret = AXIS2_MALLOC(env->allocator, decoded_len);
+	axutil_base64_decode_binary((unsigned char*)decoded_shared_secret, shared_secret);
+
+    sct->buffer = oxs_buffer_create(env);
+    oxs_buffer_populate(sct->buffer, env, (unsigned char*)decoded_shared_secret, decoded_len);
+
+    AXIS2_FREE(env->allocator, decoded_shared_secret);
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_attached_reference(
+    security_context_token_t *sct, 
+    const axutil_env_t * env,
+    axiom_node_t *node)
+{
+    axiom_node_t *ref_token = NULL;
+    axis2_char_t *local_id = NULL;
+
+    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, sct, AXIS2_FAILURE);
+
     ref_token = oxs_axiom_get_first_child_node_by_name(env, node, OXS_NODE_REFERENCE, OXS_WSSE_XMLNS, NULL);
     if(!ref_token)
     {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get reference node from attached reference");
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get reference node from attached reference");
         return AXIS2_FAILURE;
     }
 
     local_id = oxs_token_get_reference(env, ref_token);
     if(!local_id)
     {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get attached reference");
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get attached reference");
         return AXIS2_FAILURE;
     }
-    
-    sct->local_id = local_id;
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_unattached_reference(
-    security_context_token_t *sct, 
-    const axutil_env_t * env,
-    axiom_node_t *node)
-{
-    axiom_node_t *ref_token = NULL;
-    axis2_char_t *reference_id = NULL;
-
-    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, sct, AXIS2_FAILURE);
-
+    
+    sct->local_id = local_id;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_unattached_reference(
+    security_context_token_t *sct, 
+    const axutil_env_t * env,
+    axiom_node_t *node)
+{
+    axiom_node_t *ref_token = NULL;
+    axis2_char_t *reference_id = NULL;
+
+    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, sct, AXIS2_FAILURE);
+
     ref_token = oxs_axiom_get_first_child_node_by_name(env, node, OXS_NODE_REFERENCE, OXS_WSSE_XMLNS, NULL);
     if(!ref_token)
     {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get reference node from unattached reference");
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get reference node from unattached reference");
         return AXIS2_FAILURE;
     }
 
     reference_id = oxs_token_get_reference(env, ref_token);
     if(!reference_id)
     {
-        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get unattached reference");
+        AXIS2_LOG_INFO(env->log, "[rampart][security context token] Cannot get unattached reference");
         return AXIS2_FAILURE;
     }
-    
-    sct->global_id = reference_id;
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-security_context_token_set_token(
-    security_context_token_t *sct, 
-    const axutil_env_t * env,
-    axiom_node_t *node)
-{
-    return AXIS2_SUCCESS;
-}
-
-
+    
+    sct->global_id = reference_id;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+security_context_token_set_token(
+    security_context_token_t *sct, 
+    const axutil_env_t * env,
+    axiom_node_t *node)
+{
+    return AXIS2_SUCCESS;
+}
+
+