axiom_node_t *axis2_saml_issuer_issue( const axutil_env_t * env, trust_context_t *trust_ctx) { axis2_char_t *token_type = NULL; axiom_node_t *issued_saml_token = NULL; axiom_node_t *rstr_node = NULL; axiom_node_t *requested_sec_token_node = NULL; trust_rst_t *rst = NULL; /*Created RST Context*/ trust_rstr_t *rstr = NULL; /*Used for Creating RSTR*/ rst = trust_context_get_rst(trust_ctx, env); token_type = trust_rst_get_token_type(rst, env); if(token_type) AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] token type: %s !", token_type); else return NULL; if (axutil_strcmp(token_type, SAML_TOKEN)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] token type not equal..!"); return NULL; } rstr = trust_rstr_create(env); issued_saml_token = create_saml_token(env); trust_rstr_set_requested_security_token(rstr, env, issued_saml_token); trust_rstr_set_wst_ns_uri(rstr, env, "http://schemas.xmlsoap.org/ws/2005/02/trust"); trust_rstr_set_requested_proof_token(rstr, env, trust_util_create_random_session_key_proof_token_element(env, "http://schemas.xmlsoap.org/ws/2005/02/trust") ); trust_context_set_rstr(trust_ctx, env, rstr); rstr_node = trust_context_build_rstr_node(trust_ctx, env); return rstr_node; }
rampart_issued_token_t * AXIS2_CALL get_issued_token(const axutil_env_t *env, rp_property_t *issued_token, rampart_context_t *rampart_context) { axis2_endpoint_ref_t *endpoint_ref = NULL; axis2_options_t *options = NULL; axis2_svc_client_t *svc_client = NULL; axiom_node_t *rst_node = NULL; axiom_node_t *return_rstr_node = NULL; trust_rstr_t *rstr = NULL; axiom_node_t *assertion = NULL; rampart_saml_token_t *saml = NULL; rampart_issued_token_t *token = NULL; axis2_op_client_t* op_client = NULL; axis2_msg_ctx_t *in_msg_ctx = NULL; axis2_status_t status = AXIS2_SUCCESS; neethi_policy_t *issuer_policy = NULL; trust_rst_t *rst = NULL; rp_issued_token_t *it = (rp_issued_token_t *)rp_property_get_value(issued_token, env); /*Setting Issuer's EPR*/ endpoint_ref = endpoint_ref = axis2_endpoint_ref_create(env, "http://127.0.0.1:9090/axis2/services/saml_sts"); options = axis2_options_create(env); axis2_options_set_to(options, env, endpoint_ref); /*Create the policy, from file*/ issuer_policy = neethi_util_create_policy_from_file(env, sts_ploicy); if(!issuer_policy) { printf("\nPolicy creation failed from the file. %s\n", policy_file); } /*axis2_options_set_action(options, env, action); WSA Action*/ svc_client = axis2_svc_client_create(env, client_home); if (!svc_client) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); return NULL; } axis2_options_set_action(options, env, "http://example.com/ws/2004/09/policy/Test/EchoRequest"); /* Set service client options */ axis2_svc_client_set_options(svc_client, env, options); rst = trust_rst_create(env); trust_rst_set_wst_ns_uri(rst, env, "http://schemas.xmlsoap.org/ws/2005/02/trust"); rst_node = trust_rst_build_rst_with_issued_token_assertion(rst, env, it); if (status == AXIS2_SUCCESS) { status = axis2_svc_client_set_policy(svc_client, env, issuer_policy); if (status == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Policy setting failed."); } /*Building the RST */ if(rst_node) { return_rstr_node = axis2_svc_client_send_receive(svc_client, env, rst_node); rstr = trust_rstr_create(env); trust_rstr_set_wst_ns_uri(rstr, env, "http://schemas.xmlsoap.org/ws/2005/02/trust"); trust_rstr_populate_rstr(rstr, env, return_rstr_node); assertion = trust_rstr_get_requested_security_token(rstr, env); } } saml = rampart_saml_token_create(env, assertion, RAMPART_ST_CONFIR_TYPE_SENDER_VOUCHES); rampart_saml_token_set_token_type(saml, env, RAMPART_ST_TYPE_SIGNED_SUPPORTING_TOKEN); token = rampart_issued_token_create(env); rampart_issued_token_set_token(token, env, saml, RP_PROPERTY_SAML_TOKEN); return token; }