AXIS2_EXTERN neethi_assertion_t * AXIS2_CALL rp_issued_token_builder_build( const axutil_env_t *env, axiom_node_t *node, axiom_element_t *element) { rp_issued_token_t *issued_token = NULL; neethi_policy_t *policy = NULL; neethi_policy_t *normalized_policy = NULL; neethi_all_t *all = NULL; axutil_array_list_t *alternatives = NULL; neethi_operator_t *component = NULL; axis2_char_t *inclusion_value = NULL; axutil_qname_t *qname = NULL; axiom_node_t *issuer_node = NULL; axiom_element_t *issuer_ele = NULL; axiom_element_t *issuer_first_child_ele = NULL; axiom_node_t *issuer_first_child_node = NULL; axiom_node_t *req_sec_tok_template_node = NULL; axiom_element_t *req_sec_tok_template_ele = NULL; axiom_node_t *policy_node = NULL; axiom_element_t *policy_ele = NULL; neethi_assertion_t *assertion = NULL; issued_token = rp_issued_token_create(env); qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_11, RP_SP_PREFIX); inclusion_value = axiom_element_get_attribute_value(element, env, qname); axutil_qname_free(qname, env); qname = NULL; if(!inclusion_value) { /* we can try whether WS-SP1.2 specific inclusion value */ qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_12, RP_SP_PREFIX); inclusion_value = axiom_element_get_attribute_value(element, env, qname); axutil_qname_free(qname, env); qname = NULL; } if(inclusion_value) { rp_issued_token_set_inclusion(issued_token, env, inclusion_value); } qname = axutil_qname_create(env, RP_ISSUER, RP_SP_NS_11, RP_SP_PREFIX); issuer_ele = axiom_element_get_first_child_with_qname(element, env, qname, node, &issuer_node); if(issuer_ele) { issuer_first_child_ele = axiom_element_get_first_element(issuer_ele, env, issuer_node, &issuer_first_child_node); if(issuer_first_child_ele) { rp_issued_token_set_issuer_epr(issued_token, env, issuer_first_child_node); } } axutil_qname_free(qname, env); qname = NULL; qname = axutil_qname_create(env, RP_REQUEST_SEC_TOKEN_TEMPLATE, RP_SP_NS_11, RP_SP_PREFIX); req_sec_tok_template_ele = axiom_element_get_first_child_with_qname(element, env, qname, node, &req_sec_tok_template_node); if(req_sec_tok_template_ele) { rp_issued_token_set_requested_sec_token_template(issued_token, env, req_sec_tok_template_node); } else { return NULL; } axutil_qname_free(qname, env); qname = NULL; qname = axutil_qname_create(env, RP_POLICY, RP_POLICY_NS, RP_POLICY_PREFIX); policy_ele = axiom_element_get_first_child_with_qname(element, env, qname, node, &policy_node); if(policy_ele) { policy = neethi_engine_get_policy(env, policy_node, policy_ele); if(!policy) { return NULL; } normalized_policy = neethi_engine_get_normalize(env, AXIS2_FALSE, policy); neethi_policy_free(policy, env); policy = NULL; alternatives = neethi_policy_get_alternatives(normalized_policy, env); component = (neethi_operator_t *)axutil_array_list_get(alternatives, env, 0); all = (neethi_all_t *)neethi_operator_get_value(component, env); if(AXIS2_FAILURE == rp_issued_token_builder_process_alternatives(env, all, issued_token)) return NULL; assertion = neethi_assertion_create_with_args(env, (AXIS2_FREE_VOID_ARG)rp_issued_token_free, issued_token, ASSERTION_TYPE_ISSUED_TOKEN); neethi_policy_free(normalized_policy, env); normalized_policy = NULL; return assertion; } assertion = neethi_assertion_create(env); neethi_assertion_set_value(assertion, env, issued_token, ASSERTION_TYPE_ISSUED_TOKEN); return assertion; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL trust_rstr_populate_rstr( trust_rstr_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 *proof_token_node = NULL; axiom_element_t *proof_token_ele = NULL; axutil_qname_t *proof_token_qname = NULL; axiom_node_t *attached_reference_node = NULL; axiom_element_t *attached_reference_ele = NULL; axutil_qname_t *attached_reference_qname = NULL; axiom_node_t *unattached_reference_node = NULL; axiom_element_t *unattached_reference_ele = NULL; axutil_qname_t *unattached_reference_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); /*@Context 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; } axutil_qname_free(attr_ctx_qname, env); /*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; } } axutil_qname_free(token_type_qname, env); /*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); } axutil_qname_free(requested_security_token_qname, env); /*RequestedProofToken*/ proof_token_qname = axutil_qname_create(env, TRUST_REQUESTED_PROOF_TOKEN, rstr->wst_ns_uri, TRUST_WST); if(!proof_token_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RequestedProofToken Qname creation failed."); return AXIS2_FAILURE; } proof_token_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, proof_token_qname, rstr_node, &proof_token_node); if(proof_token_ele) { axiom_element_get_first_element(proof_token_ele, env, proof_token_node, &rstr->requested_proof_token); } axutil_qname_free(proof_token_qname, env); /*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); } } axutil_qname_free(applies_to_qname, env); /*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) { entropy = trust_entropy_create(env); trust_entropy_set_ns_uri(entropy, env, rstr->wst_ns_uri); if(AXIS2_SUCCESS == trust_entropy_deserialize(entropy, env, entropy_node)) { rstr->entropy = entropy; } } axutil_qname_free(entropy_qname, env); /*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)) { } } axutil_qname_free(lifetime_qname, env); /* 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); } } axutil_qname_free(key_size_qname, env); /*Attached reference*/ attached_reference_qname = axutil_qname_create(env, TRUST_REQUESTED_ATTACHED_REFERENCE, rstr->wst_ns_uri, TRUST_WST); if(!attached_reference_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RequestedAttachedReference Qname creation failed."); return AXIS2_FAILURE; } attached_reference_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, attached_reference_qname, rstr_node, &attached_reference_node); if(attached_reference_ele) { axiom_element_get_first_element(attached_reference_ele, env, attached_reference_node, &rstr->requested_attached_ref); } axutil_qname_free(attached_reference_qname, env); /*Unattached reference*/ unattached_reference_qname = axutil_qname_create(env, TRUST_REQUESTED_UNATTACHED_REFERENCE, rstr->wst_ns_uri, TRUST_WST); if(!unattached_reference_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RequestedUnattachedReference Qname creation failed."); return AXIS2_FAILURE; } unattached_reference_ele = axiom_element_get_first_child_with_qname(rstr_ele, env, unattached_reference_qname, rstr_node, &unattached_reference_node); if(unattached_reference_ele) { axiom_element_get_first_element(unattached_reference_ele, env, unattached_reference_node, &rstr->requested_unattached_ref); } axutil_qname_free(unattached_reference_qname, env); return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL trust_rst_populate_rst( trust_rst_t *rst, const axutil_env_t *env, axiom_node_t *rst_node) { 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; axiom_node_t *authnetication_type_node = NULL; axiom_element_t *authnetication_type_ele = NULL; axutil_qname_t *authnetication_type_qname = NULL; axis2_char_t *authnetication_type = NULL; axiom_node_t *signature_algo_node = NULL; axiom_element_t *signature_algo_ele = NULL; axutil_qname_t *signature_algo_qname = NULL; axis2_char_t *signature_algo = NULL; axiom_node_t *encryption_algo_node = NULL; axiom_element_t *encryption_algo_ele = NULL; axutil_qname_t *encryption_algo_qname = NULL; axis2_char_t *encryption_algo = NULL; axiom_node_t *canonocalization_algo_node = NULL; axiom_element_t *canonocalization_algo_ele = NULL; axutil_qname_t *canonocalization_algo_qname = NULL; axis2_char_t *canonocalization_algo = NULL; axiom_node_t *computedkey_algo_node = NULL; axiom_element_t *computedkey_algo_ele = NULL; axutil_qname_t *computedkey_algo_qname = NULL; axis2_char_t *computedkey_algo = NULL; axiom_node_t *desired_encryption_node = NULL; axiom_element_t *desired_encryption_ele = NULL; axutil_qname_t *desired_encryption_qname = NULL; axiom_node_t *desired_encryption_key_node = NULL; /*This can be either Key or STR*/ axiom_element_t *desired_encryption_key_ele = NULL; axiom_node_t *proof_encryption_node = NULL; axiom_element_t *proof_encryption_ele = NULL; axutil_qname_t *proof_encryption_qname = NULL; axiom_node_t *proof_encryption_key_node = NULL; /*This can be either Key or STR*/ axiom_element_t *proof_encryption_key_ele = NULL; axiom_node_t *use_key_node = NULL; axiom_element_t *use_key_ele = NULL; axutil_qname_t *use_key_qname = NULL; axiom_node_t *usekey_key_node = NULL; /*This can be either Key or STR*/ axiom_element_t *usekey_key_ele = NULL; axiom_node_t *sign_with_node = NULL; axiom_element_t *sign_with_ele = NULL; axutil_qname_t *sign_with_qname = NULL; axis2_char_t *sign_with = NULL; axiom_node_t *encrypt_with_node = NULL; axiom_element_t *encrypt_with_ele = NULL; axutil_qname_t *encrypt_with_qname = NULL; axis2_char_t *encrypt_with = NULL; 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; } /*@Context*/ 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; } axutil_qname_free(attr_ctx_qname, env); /*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; } } axutil_qname_free(token_type_qname, env); /* 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; } } axutil_qname_free(req_type_qname, env); /* 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); } } } axutil_qname_free(applies_to_qname, env); axutil_qname_free(applies_to_epr_qname, env); axutil_qname_free(applies_to_addr_qname, env); /* 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) { claims = trust_claims_create(env); if(AXIS2_SUCCESS == trust_claims_deserialize(claims, env, claims_node)) { rst->claims = claims; } } axutil_qname_free(claims_qname, env); /*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; } } axutil_qname_free(entropy_qname, env); /*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; } } axutil_qname_free(lifetime_qname, env); /*Key and Encryption Requirements*/ /* 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; } } axutil_qname_free(key_type_qname, env); /* 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); } } axutil_qname_free(key_size_qname, env); /*AuthenticationType*/ authnetication_type_qname = axutil_qname_create(env, TRUST_AUTHENTICATION_TYPE, rst->wst_ns_uri, TRUST_WST); authnetication_type_ele = axiom_element_get_first_child_with_qname(rst_ele, env, authnetication_type_qname, rst_node, &authnetication_type_node); if(authnetication_type_ele) { authnetication_type = axiom_element_get_text(authnetication_type_ele, env, authnetication_type_node); if(authnetication_type) { rst->authentication_type = authnetication_type; } } axutil_qname_free(authnetication_type_qname, env); /*SignatureAlgorithm*/ signature_algo_qname = axutil_qname_create(env, TRUST_SIGNATURE_ALGO, rst->wst_ns_uri, TRUST_WST); signature_algo_ele = axiom_element_get_first_child_with_qname(rst_ele, env, signature_algo_qname, rst_node, &signature_algo_node); if(signature_algo_ele) { signature_algo = axiom_element_get_text(signature_algo_ele, env, signature_algo_node); if(signature_algo) { rst->signature_algo = signature_algo; } } axutil_qname_free(signature_algo_qname, env); /*EncryptionAlgorithm*/ encryption_algo_qname = axutil_qname_create(env, TRUST_ENCRYPTION_ALGO, rst->wst_ns_uri, TRUST_WST); encryption_algo_ele = axiom_element_get_first_child_with_qname(rst_ele, env, encryption_algo_qname, rst_node, &encryption_algo_node); if(encryption_algo_ele) { encryption_algo = axiom_element_get_text(encryption_algo_ele, env, encryption_algo_node); if(encryption_algo) { rst->encryption_algo = encryption_algo; } } axutil_qname_free(encryption_algo_qname, env); /*CanonicalizationAlgorithm*/ canonocalization_algo_qname = axutil_qname_create(env, TRUST_CANONICAL_ALGO, rst->wst_ns_uri, TRUST_WST); canonocalization_algo_ele = axiom_element_get_first_child_with_qname(rst_ele, env, canonocalization_algo_qname, rst_node, &canonocalization_algo_node); if(canonocalization_algo_ele) { canonocalization_algo = axiom_element_get_text(canonocalization_algo_ele, env, canonocalization_algo_node); if(canonocalization_algo) { rst->canonicalization_algo = canonocalization_algo; } } axutil_qname_free(canonocalization_algo_qname, env); /*ComputedKeyAlgorithm*/ computedkey_algo_qname = axutil_qname_create(env, TRUST_COMPUTED_KEY_ALGO, rst->wst_ns_uri, TRUST_WST); computedkey_algo_ele = axiom_element_get_first_child_with_qname(rst_ele, env, computedkey_algo_qname, rst_node, &computedkey_algo_node); if(computedkey_algo_ele) { computedkey_algo = axiom_element_get_text(computedkey_algo_ele, env, computedkey_algo_node); if(computedkey_algo) { rst->computed_key_algo = computedkey_algo; } } axutil_qname_free(computedkey_algo_qname, env); /*(Desired)Encryption */ desired_encryption_qname = axutil_qname_create(env, TRUST_DESIRED_ENCRYPTION, rst->wst_ns_uri, TRUST_WST); if (!desired_encryption_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] Encryption Qname creation failed."); return AXIS2_FAILURE; } desired_encryption_ele = axiom_element_get_first_child_with_qname(rst_ele, env, desired_encryption_qname, rst_node, &desired_encryption_node); if(desired_encryption_ele) { desired_encryption_key_ele = axiom_element_get_first_element(desired_encryption_ele, env, desired_encryption_node, &desired_encryption_key_node); rst->desired_encryption = desired_encryption_key_node; } axutil_qname_free(desired_encryption_qname, env); /*ProofEncryption*/ proof_encryption_qname = axutil_qname_create(env, TRUST_PROOF_ENCRYPTION, rst->wst_ns_uri, TRUST_WST); if (!proof_encryption_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] ProofEncryption Qname creation failed."); return AXIS2_FAILURE; } proof_encryption_ele = axiom_element_get_first_child_with_qname(rst_ele, env, proof_encryption_qname, rst_node, &proof_encryption_node); if(proof_encryption_ele) { proof_encryption_key_ele = axiom_element_get_first_element(proof_encryption_ele, env, proof_encryption_node, &proof_encryption_key_node); rst->proof_encryption = proof_encryption_key_node; } axutil_qname_free(proof_encryption_qname, env); /*UseKey*/ use_key_qname = axutil_qname_create(env, TRUST_USE_KEY, rst->wst_ns_uri, TRUST_WST); if(!use_key_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] UseKey Qname creation failed."); return AXIS2_FAILURE; } use_key_ele = axiom_element_get_first_child_with_qname(rst_ele, env, use_key_qname, rst_node, &use_key_node); if(use_key_ele) { usekey_key_ele = axiom_element_get_first_element(use_key_ele, env, use_key_node, &usekey_key_node); rst->usekey = usekey_key_node; } axutil_qname_free(use_key_qname, env); /*SignWith*/ sign_with_qname = axutil_qname_create(env, TRUST_SIGN_WITH, rst->wst_ns_uri, TRUST_WST); sign_with_ele = axiom_element_get_first_child_with_qname(rst_ele, env, sign_with_qname, rst_node, &sign_with_node); if(sign_with_ele) { sign_with = axiom_element_get_text(sign_with_ele, env, sign_with_node); if(sign_with) { rst->sign_with = sign_with; } } axutil_qname_free(sign_with_qname, env); /*EncryptWith*/ encrypt_with_qname = axutil_qname_create(env, TRUST_ENCRYPT_WITH, rst->wst_ns_uri, TRUST_WST); if(!encrypt_with_qname) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] EncryptWith Qname creation failed."); return AXIS2_FAILURE; } encrypt_with_ele = axiom_element_get_first_child_with_qname(rst_ele, env, encrypt_with_qname, rst_node, &encrypt_with_node); if(encrypt_with_ele) { encrypt_with = axiom_element_get_text(encrypt_with_ele, env, encrypt_with_node); if(encrypt_with) { rst->encrypt_with = encrypt_with; } } axutil_qname_free(encrypt_with_qname, env); return AXIS2_SUCCESS; }
AXIS2_EXTERN neethi_assertion_t *AXIS2_CALL rp_username_token_builder_build( const axutil_env_t *env, axiom_node_t *node, axiom_element_t *element) { rp_username_token_t *username_token = NULL; neethi_policy_t *policy = NULL; axiom_node_t *child_node = NULL; axiom_element_t *child_element = NULL; axutil_array_list_t *alternatives = NULL; neethi_operator_t *component = NULL; neethi_all_t *all = NULL; axis2_char_t *inclusion_value = NULL; axutil_qname_t *qname = NULL; neethi_assertion_t *assertion = NULL; neethi_policy_t *normalized_policy = NULL; username_token = rp_username_token_create(env); qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_11, RP_SP_PREFIX); inclusion_value = axiom_element_get_attribute_value(element, env, qname); axutil_qname_free(qname, env); qname = NULL; if(!inclusion_value) { /* we can try whether WS-SP1.2 specific inclusion value */ qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_12, RP_SP_PREFIX); inclusion_value = axiom_element_get_attribute_value(element, env, qname); axutil_qname_free(qname, env); qname = NULL; } rp_username_token_set_inclusion(username_token, env, inclusion_value); child_node = axiom_node_get_first_element(node, env); if (!child_node) { assertion = neethi_assertion_create(env); neethi_assertion_set_value(assertion, env, username_token, ASSERTION_TYPE_USERNAME_TOKEN); return assertion; } if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT) { child_element = (axiom_element_t *) axiom_node_get_data_element(child_node, env); if (child_element) { policy = neethi_engine_get_policy(env, child_node, child_element); if (!policy) { return NULL; } normalized_policy = neethi_engine_get_normalize(env, AXIS2_FALSE, policy); neethi_policy_free(policy, env); policy = NULL; alternatives = neethi_policy_get_alternatives(normalized_policy, env); component = (neethi_operator_t *) axutil_array_list_get(alternatives, env, 0); all = (neethi_all_t *) neethi_operator_get_value(component, env); username_token_process_alternatives(env, all, username_token); assertion = neethi_assertion_create_with_args( env,(AXIS2_FREE_VOID_ARG)rp_username_token_free, username_token, ASSERTION_TYPE_USERNAME_TOKEN); neethi_policy_free(normalized_policy, env); normalized_policy = NULL; return assertion; } else return NULL; } else return NULL; }
static axis2_status_t AXIS2_CALL axis2_rm_assertion_builder_populate_for_10( const axutil_env_t *env, axis2_rm_assertion_t *rm_assertion, axiom_node_t *rm_assertion_node, axiom_element_t *rm_assertion_element) { axiom_children_iterator_t *children_iter = NULL; axis2_status_t status = AXIS2_FAILURE; /* In rm 1.0 it is just child elements which inside * rm_assertion contains all the properties. */ status = axis2_rm_assertion_set_spec_version(rm_assertion, env, RM_SPEC_VERSION_1_0); children_iter = axiom_element_get_children(rm_assertion_element, env, rm_assertion_node); if(children_iter) { while(axiom_children_iterator_has_next(children_iter, env)) { axiom_node_t *node = NULL; axiom_element_t *ele = NULL; axis2_char_t *local_name = NULL; node = axiom_children_iterator_next(children_iter, env); if(node) { if(axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { ele = (axiom_element_t *)axiom_node_get_data_element(node, env); if(ele) { axutil_qname_t *node_qname = NULL; axis2_char_t *ns = NULL; node_qname = axiom_element_get_qname(ele, env, node); if(!node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot get qname from element"); return AXIS2_FAILURE; } ns = axutil_qname_get_uri(node_qname, env); if(!ns) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot get namespace from element."); return AXIS2_FAILURE; } if(axutil_strcmp(ns, AXIS2_RM_POLICY_10_NS)) { continue; } local_name = axiom_element_get_localname(ele, env); if(local_name) { if(!axutil_strcmp(local_name, AXIS2_RM_INACTIVITY_TIMEOUT)) { axis2_char_t *inactivity_timeout = NULL; axutil_qname_t *qname = NULL; qname = axutil_qname_create(env, "Milliseconds", NULL, NULL); inactivity_timeout = axiom_element_get_attribute_value(ele, env, qname); if(qname) { axutil_qname_free(qname, env); qname = NULL; } status = axis2_rm_assertion_set_inactivity_timeout(rm_assertion, env, inactivity_timeout); } else if(!axutil_strcmp(local_name, AXIS2_RM_BASE_RETRANSMISSION_INTERVAL)) { axis2_char_t *rti = NULL; axutil_qname_t *qname = NULL; qname = axutil_qname_create(env, "Milliseconds", NULL, NULL); rti = axiom_element_get_attribute_value(ele, env, qname); if(qname) { axutil_qname_free(qname, env); qname = NULL; } status = axis2_rm_assertion_set_retrans_interval(rm_assertion, env, rti); } else if(!axutil_strcmp(local_name, AXIS2_RM_EXPONENTIAL_BACK_OFF)) { status = axis2_rm_assertion_set_is_exp_backoff(rm_assertion, env, AXIS2_TRUE); } else if(!axutil_strcmp(local_name, AXIS2_RM_ACKNOWLEDGEMENT_INTERVAL)) { axis2_char_t *ack_interval = NULL; axutil_qname_t *qname = NULL; qname = axutil_qname_create(env, "Milliseconds", NULL, NULL); ack_interval = axiom_element_get_attribute_value(ele, env, qname); if(qname) { axutil_qname_free(qname, env); qname = NULL; } status = axis2_rm_assertion_set_ack_interval(rm_assertion, env, ack_interval); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Unknown Assertion %s ", local_name); return AXIS2_FAILURE; } } } } } } } return status; }