Author: supun Date: Sun Dec 9 22:30:38 2007 New Revision: 602787 URL: http://svn.apache.org/viewvc?rev=602787&view=rev Log: Added the new RST and RSTR models according to Kasun's patch Rampart-39
Added: webservices/rampart/scratch/c/trust/c/include/trust_rst_context.h (with props) webservices/rampart/scratch/c/trust/c/include/trust_rstr_context.h (with props) webservices/rampart/scratch/c/trust/c/src/trust/rst_context.c (with props) webservices/rampart/scratch/c/trust/c/src/trust/rstr_context.c (with props) Removed: webservices/rampart/scratch/c/trust/c/include/trust_rst.h webservices/rampart/scratch/c/trust/c/include/trust_rstr.h webservices/rampart/scratch/c/trust/c/src/trust/rst.c webservices/rampart/scratch/c/trust/c/src/trust/rstr.c Added: webservices/rampart/scratch/c/trust/c/include/trust_rst_context.h URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/trust/c/include/trust_rst_context.h?rev=602787&view=auto ============================================================================== --- webservices/rampart/scratch/c/trust/c/include/trust_rst_context.h (added) +++ webservices/rampart/scratch/c/trust/c/include/trust_rst_context.h Sun Dec 9 22:30:38 2007 @@ -0,0 +1,198 @@ +/* + * 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. + */ + +#ifndef TRUST_RST_CONTEXT_H +#define TRUST_RST_CONTEXT_H + +#include <stdio.h> +#include <stdlib.h> +#include <axutil_utils.h> +#include <axutil_base64.h> +#include <axiom_soap.h> +#include <axiom.h> +#include <trust_constants.h> +#include <trust_entropy.h> +#include <trust_claims.h> +#include <trust_life_time.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct trust_rst_context trust_rst_context_t; + + /* Create RST Context*/ + AXIS2_EXTERN trust_rst_context_t * AXIS2_CALL + trust_rst_context_create( + int trust_version, + const axutil_env_t *env); + + /* Populate RST Context from axiom_node*/ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_populate_rst( + trust_rst_context_t *rst, + const axutil_env_t *env, + axiom_node_t *rst_node + /*axis2_msg_ctx_t *in_msg_ctx*/); + + /*Build RST message from the created RST Context */ + AXIS2_EXTERN axiom_node_t * AXIS2_CALL + trust_rst_context_build_rst( + trust_rst_context_t *rst, + const axutil_env_t *env, + axiom_node_t *parent); + + /* Getters & Setters */ + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rst_context_get_attr_context( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_attr_context( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *attr_context); + + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rst_context_get_token_type( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_token_type( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *token_type); + + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rst_context_get_request_type( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_request_type( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *request_type); + + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rst_context_get_applies_to_addr( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_appliesto( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *applies_to_addr); + + + AXIS2_EXTERN trust_claims_t * AXIS2_CALL + trust_rst_context_get_claims( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_claims( + trust_rst_context_t *rst, + const axutil_env_t *env, + trust_claims_t *claims); + + AXIS2_EXTERN trust_entropy_t * AXIS2_CALL + trust_rst_context_get_entropy( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_entropy( + trust_rst_context_t *rst, + const axutil_env_t *env, + trust_entropy_t *entropy); + + + AXIS2_EXTERN trust_life_time_t * AXIS2_CALL + trust_rst_context_get_life_time( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_life_time( + trust_rst_context_t *rst, + const axutil_env_t *env, + trust_life_time_t *life_time); + + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_key_type( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *key_type); + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rst_context_get_key_type( + trust_rst_context_t *rst, + const axutil_env_t *env); + + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_key_size( + trust_rst_context_t *rst, + const axutil_env_t *env, + int key_size); + + AXIS2_EXTERN int AXIS2_CALL + trust_rst_context_get_key_size( + trust_rst_context_t *rst, + const axutil_env_t *env); + + + + + /*Trust Version 1 -2005/02 - http://schemas.xmlsoap.org/ws/2005/02/trust */ + /*Trust Version 2 -2005/12 - http://docs.oasis-open.org/ws-sx/ws-trust/200512 */ + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rst_context_get_wst_ns_uri( + trust_rst_context_t *rst, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_wst_ns_uri( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *wst_ns_uri); + + + + + AXIS2_EXTERN void AXIS2_CALL + trust_rst_context_free( + trust_rst_context_t *rst, + const axutil_env_t *env); + + +#ifdef __cplusplus +} +#endif + +#endif + Propchange: webservices/rampart/scratch/c/trust/c/include/trust_rst_context.h ------------------------------------------------------------------------------ svn:executable = * Added: webservices/rampart/scratch/c/trust/c/include/trust_rstr_context.h URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/trust/c/include/trust_rstr_context.h?rev=602787&view=auto ============================================================================== --- webservices/rampart/scratch/c/trust/c/include/trust_rstr_context.h (added) +++ webservices/rampart/scratch/c/trust/c/include/trust_rstr_context.h Sun Dec 9 22:30:38 2007 @@ -0,0 +1,190 @@ + +/* + * 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. + */ + +#ifndef TRUST_RSTR_CONTEXT_H +#define TRUST_RSTR_CONTEXT_H + +#include <stdio.h> +#include <stdlib.h> +#include <axutil_utils.h> +#include <axutil_string.h> +#include <axutil_base64.h> +#include <axiom_soap.h> +#include <axiom.h> +#include <trust_constants.h> +#include <trust_entropy.h> +#include <trust_life_time.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct trust_rstr_context trust_rstr_context_t; + + AXIS2_EXTERN trust_rstr_context_t * AXIS2_CALL + trust_rstr_context_create( + int trust_version, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_free( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_populate_rstr( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *rstr_node); + + AXIS2_EXTERN axiom_node_t * AXIS2_CALL + trust_rstr_context_build_rstr( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *parent); + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rstr_context_get_token_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_token_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_char_t *token_type); + + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rstr_context_get_request_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_request_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_char_t *request_type); + + AXIS2_EXTERN axiom_node_t * AXIS2_CALL + trust_rstr_context_get_requested_security_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_requested_security_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *security_token); + + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + trust_rstr_context_get_applies_to( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_applies_to( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_char_t *applies_to); + + AXIS2_EXTERN axiom_node_t * AXIS2_CALL + trust_rstr_context_get_requested_attached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_requested_attached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *ref_node); + + AXIS2_EXTERN axiom_node_t * AXIS2_CALL + trust_rstr_context_get_requested_unattached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_requested_unattached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *ref_node); + + AXIS2_EXTERN axiom_node_t * AXIS2_CALL + trust_rstr_context_get_requested_proof_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_requested_proof_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *proof_token); + + AXIS2_EXTERN trust_entropy_t * AXIS2_CALL + trust_rstr_context_get_entropy( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_entropy( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + trust_entropy_t *entropy); + + AXIS2_EXTERN trust_life_time_t* AXIS2_CALL + trust_rstr_context_get_life_time( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_life_time( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + trust_life_time_t *life_time); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + trust_rstr_context_get_in_header( + trust_rstr_context_t *rstr, + const axutil_env_t *env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rstr_context_set_in_header( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_bool_t in_header); + + + + + + + + + + + + + + +#ifdef __cplusplus +} +#endif + +#endif Propchange: webservices/rampart/scratch/c/trust/c/include/trust_rstr_context.h ------------------------------------------------------------------------------ svn:executable = * Added: webservices/rampart/scratch/c/trust/c/src/trust/rst_context.c URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/trust/c/src/trust/rst_context.c?rev=602787&view=auto ============================================================================== --- webservices/rampart/scratch/c/trust/c/src/trust/rst_context.c (added) +++ webservices/rampart/scratch/c/trust/c/src/trust/rst_context.c Sun Dec 9 22:30:38 2007 @@ -0,0 +1,712 @@ +/* + * 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 <trust_rst_context.h> + + +struct trust_rst_context +{ + + axis2_char_t *attr_context; + + axis2_char_t *token_type; + + axis2_char_t *request_type; + + axis2_char_t *applies_to_addr; + + trust_claims_t *claims; + + trust_entropy_t *entropy; + + axis2_char_t *key_type; + + int key_size; + + axis2_bool_t allow_postdating; + + axis2_bool_t renewing; + + axis2_bool_t attr_allow; + + axis2_bool_t attr_ok; + + axiom_node_t *renew_target; + + axiom_node_t *cancel_target; + + axis2_char_t *wst_ns_uri; + + int trust_version; + + trust_life_time_t *life_time; + + /*ToDo : Federation - Trust Extensions + * - Authorization : AdditionalContext and CommonClaim Dialect + * - Prefix:auth + */ + +}; + +AXIS2_EXTERN trust_rst_context_t * AXIS2_CALL +trust_rst_context_create( + int trust_version, + const axutil_env_t *env) +{ + trust_rst_context_t *rst = NULL; + + rst = (trust_rst_context_t*)AXIS2_MALLOC(env->allocator, sizeof(trust_rst_context_t)); + + rst->attr_context = NULL; + rst->token_type = NULL; + rst->request_type = NULL; + rst->applies_to_addr = NULL; + rst->claims = NULL; + rst->entropy = NULL; + rst->key_type = NULL; + rst->key_size = -1; + rst->allow_postdating = AXIS2_FALSE; + rst->renewing = AXIS2_FALSE; + rst->attr_allow = AXIS2_FALSE; + rst->attr_ok = AXIS2_FALSE; + rst->renew_target = NULL; + rst->cancel_target = NULL; + + + rst->trust_version = trust_version; + switch (trust_version) + { + case TRUST_VERSION_05_02: + rst->wst_ns_uri = axutil_strdup(env, TRUST_WST_XMLNS_05_02); + case TRUST_VERSION_05_12: + rst->wst_ns_uri = axutil_strdup(env, TRUST_WST_XMLNS_05_12); + default: + { + /*If anything goes wrong the default wst namespace is set : WST_05_02 */ + rst->trust_version = 1; + rst->wst_ns_uri = axutil_strdup(env, TRUST_WST_XMLNS_05_02); + } + + } + + rst->life_time = NULL; + + return rst; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_populate_rst( + trust_rst_context_t *rst, + const axutil_env_t *env, + axiom_node_t *rst_node) +{ + /*axiom_node_t *rst_node = NULL;*/ + axiom_element_t *rst_ele = NULL; + axutil_qname_t *attr_ctx_qname = NULL; + axis2_char_t *attr_ctx = NULL; + + axiom_node_t *token_type_node = NULL; + axiom_element_t *token_type_ele = NULL; + axutil_qname_t *token_type_qname = NULL; + axis2_char_t *token_type = NULL; + + axiom_element_t *req_type_ele = NULL; + axiom_node_t *req_type_node = NULL; + axutil_qname_t *req_type_qname = NULL; + axis2_char_t *req_type = NULL; + + axutil_qname_t *applies_to_qname = NULL; /*AppliesTo*/ + axiom_node_t *applies_to_node = NULL; + axiom_element_t *applies_to_ele = NULL; + axutil_qname_t *applies_to_epr_qname = NULL; /*EPR*/ + axiom_node_t *applies_to_epr_node = NULL; + axiom_element_t *applies_to_epr_ele = NULL; + axutil_qname_t *applies_to_addr_qname = NULL; /*Addr*/ + axiom_node_t *applies_to_addr_node = NULL; + axiom_element_t *applies_to_addr_ele = NULL; + + trust_claims_t *claims = NULL; + axiom_node_t *claims_node = NULL; + axiom_element_t *claims_ele = NULL; + axutil_qname_t *claims_qname = NULL; + + trust_entropy_t *entropy = NULL; + axiom_node_t *entropy_node = NULL; + axiom_element_t *entropy_ele = NULL; + axutil_qname_t *entropy_qname = NULL; + + axiom_node_t *lifetime_node = NULL; + axiom_element_t *lifetime_ele = NULL; + axutil_qname_t *lifetime_qname = NULL; + + axiom_node_t *key_type_node = NULL; + axiom_element_t *key_type_ele = NULL; + axutil_qname_t *key_type_qname = NULL; + axis2_char_t *key_type = NULL; + + axiom_node_t *key_size_node = NULL; + axiom_element_t *key_size_ele = NULL; + axutil_qname_t *key_size_qname = NULL; + axis2_char_t *key_size = NULL; + + + /*ToBe Fixed with the use of in_message_context ----------*/ + /*soap_env = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env); + soap_body = axiom_soap_envelope_get_body(soap_env, env); + body_base_node = axiom_soap_body_get_base_node(soap_body, env); + + rst_node = axiom_node_get_first_child(body_base_node, env);*/ + + if(NULL == rst_node || NULL == rst) + { + return AXIS2_FAILURE; + } + + rst_ele = (axiom_element_t*)axiom_node_get_data_element(rst_node, env); + + if(NULL == rst_ele) + { + return AXIS2_FAILURE; + } + + /[EMAIL PROTECTED]/ + attr_ctx_qname = axutil_qname_create(env, TRUST_RST_CONTEXT, rst->wst_ns_uri, TRUST_WST); + if (!attr_ctx_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Context Attribute Qname creation failed."); + return AXIS2_FAILURE; + } + attr_ctx = axiom_element_get_attribute_value(rst_ele, env, attr_ctx_qname); + if (attr_ctx) + { + rst->attr_context = attr_ctx; + } + + + /*TokenType*/ + token_type_qname = axutil_qname_create(env, TRUST_TOKEN_TYPE, rst->wst_ns_uri, TRUST_WST); + if (!token_type_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] TokenType Qname creation failed."); + return AXIS2_FAILURE; + } + + token_type_ele = axiom_element_get_first_child_with_qname(rst_ele, env, token_type_qname, rst_node, &token_type_node); + if (token_type_ele) + { + token_type = axiom_element_get_text(token_type_ele, env, token_type_node); + if(token_type) + { + rst->token_type = token_type; + } + } + + + /* RequestType */ + req_type_qname = axutil_qname_create(env, TRUST_REQUEST_TYPE, rst->wst_ns_uri, TRUST_WST); + if (!req_type_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RequestType Qname creation failed."); + return AXIS2_FAILURE; + } + + req_type_ele = axiom_element_get_first_child_with_qname(rst_ele, env, req_type_qname, rst_node, &req_type_node); + if(req_type_ele) + { + req_type = axiom_element_get_text(req_type_ele, env, req_type_node); + if(req_type) + { + rst->request_type = req_type; + } + } + + /* AppliesTo */ + applies_to_qname = axutil_qname_create(env, TRUST_APPLIES_TO, TRUST_WSP_XMLNS, TRUST_WSP); + applies_to_epr_qname = axutil_qname_create(env, TRUST_EPR, TRUST_WSA_XMLNS, TRUST_WSA); + applies_to_addr_qname = axutil_qname_create(env, TRUST_EPR_ADDRESS, TRUST_WSA_XMLNS, TRUST_WSA); + if (!applies_to_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Appliesto Qname creation failed."); + return AXIS2_FAILURE; + } + + applies_to_ele = axiom_element_get_first_child_with_qname(rst_ele, env, applies_to_qname, rst_node, &applies_to_node); + if(applies_to_ele) + { + applies_to_epr_ele = axiom_element_get_first_child_with_qname(applies_to_ele, env, applies_to_epr_qname, + applies_to_node, &applies_to_epr_node); + + if(applies_to_epr_ele) + { + applies_to_addr_ele = axiom_element_get_first_child_with_qname(applies_to_epr_ele, env, applies_to_addr_qname, + applies_to_epr_node, &applies_to_addr_node); + + if(applies_to_addr_ele) + { + rst->applies_to_addr = axiom_element_get_text(applies_to_addr_ele, env, applies_to_addr_node); + } + } + } + + + /* Claims */ + claims_qname = axutil_qname_create(env, TRUST_CLAIMS, rst->wst_ns_uri, TRUST_WST); + if (!claims_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Claims Qname creation failed."); + return AXIS2_FAILURE; + } + + claims_ele = axiom_element_get_first_child_with_qname(rst_ele, env, claims_qname, rst_node, &claims_node); + if (claims_ele) + { + if(AXIS2_SUCCESS == trust_claims_deserialize(claims, env, claims_node)) + { + rst->claims = claims; + } + } + + /*Entropy */ + entropy_qname = axutil_qname_create(env, TRUST_ENTROPY, rst->wst_ns_uri, TRUST_WST); + if (!entropy_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Entropy Qname creation failed."); + return AXIS2_FAILURE; + } + + entropy_ele = axiom_element_get_first_child_with_qname(rst_ele, env, entropy_qname, rst_node, &entropy_node); + if(entropy_ele) + { + entropy = trust_entropy_create(env); + trust_entropy_set_ns_uri(entropy, env, rst->wst_ns_uri); + + if(AXIS2_SUCCESS == trust_entropy_deserialize(entropy, env, entropy_node)) + { + rst->entropy = entropy; + } + } + + /*LifeTime*/ + lifetime_qname = axutil_qname_create(env, TRUST_LIFE_TIME, rst->wst_ns_uri, TRUST_WST); + if(!lifetime_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] LifeTime Qname creation failed."); + return AXIS2_FAILURE; + } + + lifetime_ele = axiom_element_get_first_child_with_qname(rst_ele, env, lifetime_qname, rst_node, &lifetime_node); + if(lifetime_ele) + { + if(AXIS2_SUCCESS == trust_life_time_deserialize(rst->life_time, env, lifetime_node)) + { + rst->life_time = NULL; + } + } + + + /* KeyType */ + key_type_qname = axutil_qname_create(env, TRUST_KEY_TYPE, rst->wst_ns_uri, TRUST_WST); + if(!key_type_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] KeyType Qname creation failed."); + return AXIS2_FAILURE; + } + + key_type_ele = axiom_element_get_first_child_with_qname(rst_ele, env, key_type_qname, rst_node, &key_type_node); + if(key_type_ele) + { + key_type = axiom_element_get_text(key_type_ele, env, key_type_node); + if(key_type) + { + rst->key_type = key_type; + } + } + + + /* KeySize */ + key_size_qname = axutil_qname_create(env, TRUST_KEY_SIZE, rst->wst_ns_uri, TRUST_WST); + key_size_ele = axiom_element_get_first_child_with_qname(rst_ele, env, key_size_qname, rst_node, &key_size_node); + if(key_size_ele) + { + key_size = axiom_element_get_text(key_size_ele, env, key_size_node); + if(key_size) + { + rst->key_size = atoi(key_size); + } + } + + AXIS2_FREE(env->allocator, key_size_qname); + AXIS2_FREE(env->allocator, key_type_qname); + AXIS2_FREE(env->allocator, lifetime_qname); + AXIS2_FREE(env->allocator, entropy_qname); + AXIS2_FREE(env->allocator, claims_qname); + AXIS2_FREE(env->allocator, applies_to_qname); + AXIS2_FREE(env->allocator, applies_to_epr_qname); + AXIS2_FREE(env->allocator, applies_to_addr_qname); + AXIS2_FREE(env->allocator, req_type_qname); + AXIS2_FREE(env->allocator, token_type_qname); + AXIS2_FREE(env->allocator, attr_ctx_qname); + + /*Free Intermediate Objects.. */ + + return AXIS2_SUCCESS; +} + + + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +trust_rst_context_build_rst( + trust_rst_context_t *rst, + const axutil_env_t *env, + axiom_node_t *parent) +{ + axiom_node_t *rst_node = NULL; + axis2_char_t *key_size = NULL; + + rst_node = (axiom_node_t*)trust_util_create_rst_element(env, rst->trust_version, parent, rst->attr_context); + + if(rst_node) + { + if(rst->token_type || rst->applies_to_addr) + { + if(rst->token_type) + { + if(NULL == (axiom_node_t*)trust_util_create_token_type_element(env, rst->trust_version, rst_node, rst->token_type)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] TokenType element creation failed."); + return NULL; + } + } + + if(rst->applies_to_addr) + { + /*AppliesTo in WSP - No Need to pass the trust version*/ + if(NULL == (axiom_node_t*)trust_util_create_applies_to_element(env, rst_node, rst->applies_to_addr, TRUST_WSA_XMLNS)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] AppliesTo element creation failed."); + return NULL; + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] You must at least give token type or applies to address."); + return NULL; + } + + if(rst->request_type) + { + if(NULL == (axiom_node_t*)trust_util_create_request_type_element(env, rst->wst_ns_uri, rst_node, rst->request_type)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RequestType element creation failed."); + return NULL; + } + } + + if(rst->claims) + { + if(NULL == trust_claims_serialize(rst->claims, env, rst_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Claims element creation failed."); + return NULL; + } + } + + if(rst->entropy) + { + if(NULL == trust_entropy_serialize(rst->entropy, env, rst_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Entropy element creation failed."); + return NULL; + } + } + + if(rst->life_time) + { + if(NULL == trust_life_time_serialize(rst->life_time, env, rst_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] LifeTime element creation failed."); + return NULL; + } + } + + if(rst->key_type) + { + if(NULL == (axiom_node_t*)trust_util_create_key_type_element(env, rst->trust_version, rst_node, rst->key_type)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] KeyType element creation failed."); + return NULL; + } + } + + if(rst->key_size > 0) + { + /*INFO -keysize Malloc Size = 128 */ + key_size = AXIS2_MALLOC( env->allocator, sizeof(char)*128); + sprintf(key_size, "%d", rst->key_size); + if(NULL == (axiom_node_t*)trust_util_create_key_size_element(env, rst->trust_version, rst_node, key_size)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] KeySize element creation failed."); + return NULL; + } + } + + return rst_node; + } + + return NULL; +} + + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rst_context_get_attr_context( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->attr_context; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_attr_context( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *attr_context) +{ + if(attr_context) + { + rst->attr_context = attr_context; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rst_context_get_token_type( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->token_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_token_type( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *token_type) +{ + if(token_type) + { + rst->token_type = token_type; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rst_context_get_request_type( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->request_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_request_type( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *request_type) +{ + if(request_type) + { + rst->request_type = request_type; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rst_context_get_applies_to_addr( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->applies_to_addr; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_appliesto( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *applies_to_addr) +{ + if(applies_to_addr) + { + rst->applies_to_addr = applies_to_addr; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN trust_claims_t * AXIS2_CALL +trust_rst_context_get_claims( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->claims; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_claims( + trust_rst_context_t *rst, + const axutil_env_t *env, + trust_claims_t *claims) +{ + if(claims) + { + rst->claims = claims; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN trust_entropy_t * AXIS2_CALL +trust_rst_context_get_entropy( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->entropy; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_entropy( + trust_rst_context_t *rst, + const axutil_env_t *env, + trust_entropy_t *entropy) +{ + if(entropy) + { + rst->entropy = entropy; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN trust_life_time_t * AXIS2_CALL +trust_rst_context_get_life_time( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->life_time; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_life_time( + trust_rst_context_t *rst, + const axutil_env_t *env, + trust_life_time_t *life_time) +{ + if(life_time) + { + rst->life_time = life_time; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL + trust_rst_context_set_key_type( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *key_type) +{ + if(key_type) + { + rst->key_type = key_type; + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rst_context_get_key_type( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->key_type; +} + + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_key_size( + trust_rst_context_t *rst, + const axutil_env_t *env, + int key_size) +{ + if(key_size > 0) + { + rst->key_size = key_size; + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN int AXIS2_CALL +trust_rst_context_get_key_size( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->key_size; +} + + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rst_context_get_wst_ns_uri( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return rst->wst_ns_uri; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rst_context_set_wst_ns_uri( + trust_rst_context_t *rst, + const axutil_env_t *env, + axis2_char_t *wst_ns_uri) +{ + if(wst_ns_uri) + { + rst->wst_ns_uri = wst_ns_uri; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + + +AXIS2_EXTERN void AXIS2_CALL +trust_rst_context_free( + trust_rst_context_t *rst, + const axutil_env_t *env) +{ + return; +} + Propchange: webservices/rampart/scratch/c/trust/c/src/trust/rst_context.c ------------------------------------------------------------------------------ svn:executable = * Added: webservices/rampart/scratch/c/trust/c/src/trust/rstr_context.c URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/trust/c/src/trust/rstr_context.c?rev=602787&view=auto ============================================================================== --- webservices/rampart/scratch/c/trust/c/src/trust/rstr_context.c (added) +++ webservices/rampart/scratch/c/trust/c/src/trust/rstr_context.c Sun Dec 9 22:30:38 2007 @@ -0,0 +1,589 @@ +/* + * 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 <trust_rstr_context.h> + +struct trust_rstr_context{ + + axis2_char_t *attr_context; /*Context Attribute of RSTR : same as RST context attribute */ + + axis2_char_t *token_type; + + axis2_char_t *request_type; + + axiom_node_t *requested_sec_token; + + axis2_char_t *applies_to; + + axiom_node_t *requested_attached_ref; + + axiom_node_t *requested_unattached_ref; + + axiom_node_t *requested_proof_token; + + trust_entropy_t *entropy; + + trust_life_time_t *life_time; + + int key_size; + + /*Trsut Version */ + int trust_version; + + axis2_char_t *wst_ns_uri; + + /*Use state whether response is going inside soap header or soap body*/ + axis2_bool_t in_header; +}; + +AXIS2_EXTERN trust_rstr_context_t * AXIS2_CALL +trust_rstr_context_create( + int trust_version, + const axutil_env_t *env) +{ + trust_rstr_context_t *rstr = NULL; + + rstr = (trust_rstr_context_t*)AXIS2_MALLOC(env->allocator, sizeof(trust_rstr_context_t)); + + rstr->token_type = NULL; + rstr->request_type = NULL; + rstr->requested_sec_token = NULL; + rstr->applies_to = NULL; + rstr->requested_attached_ref = NULL; + rstr->requested_unattached_ref = NULL; + rstr->requested_proof_token = NULL; + rstr->entropy = NULL; + rstr->life_time = NULL; + rstr->key_size = -1; + + rstr->trust_version = trust_version; + switch (trust_version) + { + case TRUST_VERSION_05_02: + rstr->wst_ns_uri = axutil_strdup(env, TRUST_WST_XMLNS_05_02); + case TRUST_VERSION_05_12: + rstr->wst_ns_uri = axutil_strdup(env, TRUST_WST_XMLNS_05_12); + default: + { /*If anything goes wrong the default wst namespace is set : WST_05_02 */ + rstr->trust_version = 1; + rstr->wst_ns_uri = axutil_strdup(env, TRUST_WST_XMLNS_05_02); + } + } + + return rstr; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_free( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_populate_rstr( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *rstr_node) +{ + axiom_element_t *rstr_ele = NULL; + axutil_qname_t *attr_ctx_qname = NULL; + axis2_char_t *attr_ctx = NULL; + + axiom_node_t *requested_security_token_node = NULL; + axiom_element_t *requested_security_token_ele = NULL; + axutil_qname_t *requested_security_token_qname = NULL; + + axiom_node_t *token_type_node = NULL; + axiom_element_t *token_type_ele = NULL; + axutil_qname_t *token_type_qname = NULL; + axis2_char_t *token_type = NULL; + + axutil_qname_t *applies_to_qname = NULL; + axiom_node_t *appliesto_node = NULL; + axiom_element_t *appliesto_ele = NULL; + axiom_node_t *first_node = NULL; + axiom_element_t *first_ele = NULL; + + + trust_entropy_t *entropy = NULL; + axiom_node_t *entropy_node = NULL; + axiom_element_t *entropy_ele = NULL; + axutil_qname_t *entropy_qname = NULL; + + axiom_node_t *lifetime_node = NULL; + axiom_element_t *lifetime_ele = NULL; + axutil_qname_t *lifetime_qname = NULL; + + axiom_node_t *key_size_node = NULL; + axiom_element_t *key_size_ele = NULL; + axutil_qname_t *key_size_qname = NULL; + axis2_char_t *key_size = NULL; + + + rstr_ele = (axiom_element_t*)axiom_node_get_data_element(rstr_node, env); + + /[EMAIL PROTECTED] RSTR*/ + attr_ctx_qname = axutil_qname_create(env, TRUST_RST_CONTEXT, rstr->wst_ns_uri, TRUST_WST); + if (!attr_ctx_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Context Attribute Qname creation failed."); + return AXIS2_FAILURE; + } + attr_ctx = axiom_element_get_attribute_value(rstr_ele, env, attr_ctx_qname); + + if (attr_ctx) + { + rstr->attr_context = attr_ctx; + } + + + + /*TokenType*/ + token_type_qname = axutil_qname_create(env, TRUST_TOKEN_TYPE, rstr->wst_ns_uri, TRUST_WST); + if (!token_type_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] TokenType Qname creation failed."); + return AXIS2_FAILURE; + } + + token_type_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, token_type_qname, rstr_node, &token_type_node); + if (token_type_ele) + { + token_type = axiom_element_get_text(token_type_ele, env, token_type_node); + if(token_type) + { + rstr->token_type = token_type; + } + } + + + /*RequestedSecurityToken*/ + requested_security_token_qname = axutil_qname_create(env, TRUST_REQUESTED_SECURITY_TOKEN, rstr->wst_ns_uri, TRUST_WST); + if(!requested_security_token_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RequestedSecurityToken Qname creation failed."); + return AXIS2_FAILURE; + } + requested_security_token_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, requested_security_token_qname, + rstr_node, &requested_security_token_node); + if(requested_security_token_ele) + { + axiom_element_get_first_element(requested_security_token_ele, env, requested_security_token_node, &rstr->requested_sec_token); + } + + /*AppliesTo*/ + applies_to_qname = axutil_qname_create(env, TRUST_APPLIES_TO, TRUST_WSP_XMLNS, TRUST_WSP); + if (!applies_to_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Appliesto Qname creation failed."); + return AXIS2_FAILURE; + } + + appliesto_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, applies_to_qname, rstr_node, &appliesto_node); + if(appliesto_ele) + { + first_ele = axiom_element_get_first_element(appliesto_ele, env, appliesto_node, &first_node); + if(first_ele) + { + rstr->applies_to = axiom_element_get_text(first_ele, env, first_node); + } + } + + + /*Entropy*/ + entropy_qname = axutil_qname_create(env, TRUST_ENTROPY, rstr->wst_ns_uri, TRUST_WST); + if (!entropy_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Entropy Qname creation failed."); + return AXIS2_FAILURE; + } + + entropy_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, entropy_qname, rstr_node, &entropy_node); + if(entropy_ele) + { + if(AXIS2_SUCCESS == trust_entropy_deserialize(entropy, env, entropy_node)) + { + rstr->entropy = entropy; + } + } + + + /*LifeTime*/ + lifetime_qname = axutil_qname_create(env, TRUST_LIFE_TIME, rstr->wst_ns_uri, TRUST_WST); + if(!lifetime_qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] LifeTime Qname creation failed."); + return AXIS2_FAILURE; + } + + lifetime_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, lifetime_qname, rstr_node, &lifetime_node); + if(lifetime_ele) + { + rstr->life_time = trust_life_time_create(env); + if(AXIS2_SUCCESS == trust_life_time_deserialize(rstr->life_time, env, lifetime_node)) + { + + } + } + + /* KeySize */ + key_size_qname = axutil_qname_create(env, TRUST_KEY_SIZE, rstr->wst_ns_uri, TRUST_WST); + key_size_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, key_size_qname, rstr_node, &key_size_node); + if(key_size_ele) + { + key_size = axiom_element_get_text(key_size_ele, env, key_size_node); + if(key_size) + { + rstr->key_size = atoi(key_size); + } + } + + /*FIX :Attached and Unattached References*/ + + AXIS2_FREE(env->allocator, lifetime_qname); + AXIS2_FREE(env->allocator, entropy_qname); + AXIS2_FREE(env->allocator, applies_to_qname); + AXIS2_FREE(env->allocator, token_type_qname); + AXIS2_FREE(env->allocator, attr_ctx_qname); + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +trust_rstr_context_build_rstr( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *parent) +{ + axiom_node_t *rstr_node = NULL; + axis2_char_t *key_size = NULL; + + rstr_node = (axiom_node_t*)trust_util_create_rstr_element(env, rstr->trust_version, rstr->attr_context); + + if(rstr_node) + { + if(rstr->token_type) + { + if(NULL == (axiom_node_t*)trust_util_create_token_type_element(env, rstr->trust_version, rstr_node, rstr->token_type)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR TokenType element creation failed."); + return NULL; + } + } + + if(rstr->requested_sec_token) + { + if(NULL == (axiom_node_t*)trust_util_create_requested_security_token_element(env, rstr->trust_version, rstr_node, rstr->requested_sec_token)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR ReqSecToken element creation failed."); + return NULL; + } + + } + if(rstr->applies_to) + { + if(NULL == (axiom_node_t*)trust_util_create_applies_to_element(env, rstr_node, rstr->applies_to, TRUST_WSA_XMLNS)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR AppliesTo element creation failed."); + return NULL; + } + } + if(rstr->requested_attached_ref) + { + if(NULL == (axiom_node_t*)trust_util_create_req_attached_reference_element(env, rstr->trust_version, rstr_node)); + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR AttachedReference element creation failed."); + return NULL; + } + /* FIX : Attached Ref STR node*/ + + } + if(rstr->requested_unattached_ref) + { + if(NULL == (axiom_node_t*)trust_util_create_req_unattached_reference_element(env, rstr->trust_version, rstr_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR UnattachedReference element creation failed."); + return NULL; + } + } + + if(rstr->entropy) + { + if(NULL == trust_entropy_serialize(rstr->entropy, env, rstr_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR Entropy element creation failed."); + return NULL; + } + } + + if(rstr->life_time) + { + if(NULL == trust_life_time_serialize(rstr->life_time, env, rstr_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RSTR LifeTime element creation failed."); + return NULL; + } + } + + if(rstr->key_size > 0) + { + /*INFO -keysize Malloc Size = 128 */ + key_size = AXIS2_MALLOC( env->allocator, sizeof(char)*128); + sprintf(key_size, "%d", rstr->key_size); + if(NULL == (axiom_node_t*)trust_util_create_key_size_element(env, rstr->trust_version, rstr_node, key_size)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] KeySize element creation failed."); + return NULL; + } + } + return rstr_node; + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rstr_context_get_token_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->token_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_token_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_char_t *token_type) +{ + if(token_type) + { + rstr->token_type = token_type; + + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rstr_context_get_request_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->request_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_request_type( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_char_t *request_type) +{ + if(request_type) + { + rstr->request_type = request_type; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +trust_rstr_context_get_requested_security_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->requested_sec_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_requested_security_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *security_token) +{ + if (security_token) + { + rstr->requested_sec_token = security_token; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; + +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +trust_rstr_context_get_applies_to( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->applies_to; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_applies_to( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_char_t *applies_to) +{ + if (applies_to) + { + rstr->applies_to = applies_to; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +trust_rstr_context_get_requested_attached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->requested_attached_ref; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_requested_attached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *ref_node) +{ + if (ref_node) + { + rstr->requested_attached_ref = ref_node; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +trust_rstr_context_get_requested_unattached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->requested_unattached_ref; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_requested_unattached_reference( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *ref_node) +{ + if (ref_node) + { + rstr->requested_unattached_ref = ref_node; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +trust_rstr_context_get_requested_proof_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->requested_proof_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_requested_proof_token( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axiom_node_t *proof_token) +{ + if (proof_token) + { + rstr->requested_proof_token = proof_token; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN trust_entropy_t * AXIS2_CALL +trust_rstr_context_get_entropy( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->entropy; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_entropy( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + trust_entropy_t *entropy) +{ + if (entropy) + { + rstr->entropy = entropy; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN trust_life_time_t* AXIS2_CALL +trust_rstr_context_get_life_time( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->life_time; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_life_time( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + trust_life_time_t *life_time) +{ + if (life_time) + { + rstr->life_time = life_time; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +trust_rstr_context_get_in_header( + trust_rstr_context_t *rstr, + const axutil_env_t *env) +{ + return rstr->in_header; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +trust_rstr_context_set_in_header( + trust_rstr_context_t *rstr, + const axutil_env_t *env, + axis2_bool_t in_header) +{ + rstr->in_header = in_header; + + return AXIS2_SUCCESS; +} + + Propchange: webservices/rampart/scratch/c/trust/c/src/trust/rstr_context.c ------------------------------------------------------------------------------ svn:executable = *