/* Called by: zxid_idp_soap_dispatch x2, zxid_sp_soap_dispatch x8 */ int zxid_soap_cgi_resp_body(zxid_conf* cf, zxid_ses* ses, struct zx_e_Body_s* body) { struct zx_e_Envelope_s* env = zx_NEW_e_Envelope(cf->ctx,0); struct zx_str* ss; struct zx_str* logpath; env->Body = body; zx_add_kid(&env->gg, &body->gg); env->Header = zx_NEW_e_Header(cf->ctx, &env->gg); if (ses && ses->curflt) { D("Detected curflt, abandoning previous Body content. %d", 0); /* *** LEAK: Should free previous body content */ env->Body = (struct zx_e_Body_s*)zx_replace_kid(&env->gg, (struct zx_elem_s*)zx_NEW_e_Body(cf->ctx, 0)); ZX_ADD_KID(env->Body, Fault, ses->curflt); } zxid_wsf_decor(cf, ses, env, 1, 0); ss = zx_easy_enc_elem_opt(cf, &env->gg); if (cf->log_issue_msg) { logpath = zxlog_path(cf, ses->issuer, ss, ZXLOG_ISSUE_DIR, ZXLOG_WIR_KIND, 1); if (logpath) { if (zxlog_dup_check(cf, logpath, "cgi_resp")) { ERR("Duplicate wire msg(%.*s) (Simple Sign)", ss->len, ss->s); #if 0 if (cf->dup_msg_fatal) { ERR("FATAL (by configuration): Duplicate wire msg(%.*s) (cgi_resp)", ss->len, ss->s); zxlog_blob(cf, 1, logpath, ss, "cgi_resp dup"); zx_str_free(cf->ctx, logpath); return 0; } #endif } zxlog_blob(cf, 1, logpath, ss, "cgi_resp"); zxlogwsp(cf, ses, "K", "CGIRESP", 0, "logpath(%.*s)", logpath->len, logpath->s); zx_str_free(cf->ctx, logpath); } } if (errmac_debug & ERRMAC_INOUT) INFO("SOAP_RESP(%.*s)", ss->len, ss->s); fprintf(stdout, "CONTENT-TYPE: text/xml" CRLF "CONTENT-LENGTH: %d" CRLF2 "%.*s", ss->len, ss->len, ss->s); fflush(stdout); D("^^^^^^^^^^^^^^ Done (%d chars returned) ^^^^^^^^^^^^^", ss->len); return ZXID_REDIR_OK; }
/* Called by: zxid_wsc_call, zxid_wsc_prepare_call */ static int zxid_wsc_prep(zxid_conf* cf, zxid_ses* ses, zxid_epr* epr, struct zx_e_Envelope_s* env) { zxid_tok* tok; struct zx_e_Header_s* hdr; if (!zxid_wsf_decor(cf, ses, env, 0, epr)) return 0; hdr = env->Header; /* 6.rq: ReplyTo (optional) */ if (cf->wsc_replyto_hdr && strcmp(cf->wsc_replyto_hdr, "#inhibit")) { /* Mandatory for a request (says who? - apparenly AXIS2 or WSO2 has a bug of * requiring this and not understanding to default it to anon). * liberty-idwsf-soap-binding-2.0-errata-v1.0.pdf * p.21 ll.591-595 seem to imply that ReplyTo can be omitted if value would be A_ANON. */ hdr->ReplyTo = zx_NEW_a_ReplyTo(cf->ctx, &hdr->gg); /*hdr->ReplyTo->Address = zxid_mk_addr(cf, zx_strf(cf->ctx, "%s?o=P", cf->burl));*/ if (!strcmp(cf->wsc_replyto_hdr, "#anon")) { hdr->ReplyTo->Address = zxid_mk_addr(cf, &hdr->ReplyTo->gg, zx_dup_str(cf->ctx, A_ANON)); } else if (!strcmp(cf->wsc_replyto_hdr, "#anon_2005_03")) { hdr->ReplyTo->Address = zxid_mk_addr(cf, &hdr->ReplyTo->gg, zx_dup_str(cf->ctx, A_ANON_2005_03)); } else { hdr->ReplyTo->Address = zxid_mk_addr(cf, &hdr->ReplyTo->gg, zx_dup_str(cf->ctx, cf->wsc_replyto_hdr)); } hdr->ReplyTo->mustUnderstand = zx_ref_attr(cf->ctx, &hdr->ReplyTo->gg, zx_e_mustUnderstand_ATTR, XML_TRUE); hdr->ReplyTo->actor = zx_ref_attr(cf->ctx, &hdr->ReplyTo->gg, zx_e_actor_ATTR, SOAP_ACTOR_NEXT); } #if 0 /* Omission means to use same address as ReplyTo */ hdr->FaultTo = zx_NEW_a_FaultTo(cf->ctx, &hdr->gg); hdr->FaultTo->Address = zx_mk_addr(cf->ctx, &hdr->FaultTo->gg, zx_strf(cf->ctx, "%s?o=P", cf->burl)); hdr->FaultTo->mustUnderstand = zx_ref_attr(cf->ctx, &hdr->FaultTo->gg, zx_e_mustUnderstand_ATTR, XML_TRUE); hdr->FaultTo->actor = zx_ref_attr(cf->ctx, &hdr->FaultTo->gg, zx_e_actor_ATTR, SOAP_ACTOR_NEXT); #endif if (ses->call_tgttok || ses->call_invoktok && epr && epr->Metadata && epr->Metadata->SecurityContext && epr->Metadata->SecurityContext->Token) { /* 9.rq: Target Identity */ if (ses->call_tgttok) { D("TargetIdentity: Explicit specification of ses->call_tgttok %d",0); tok = ses->call_tgttok; } else { D("TargetIdentity: Using token from EPR due to specification of ses->call_invoktok %d",0); tok = epr->Metadata->SecurityContext->Token; } hdr->TargetIdentity = zx_NEW_b_TargetIdentity(cf->ctx, &hdr->gg); hdr->TargetIdentity->mustUnderstand = zx_ref_attr(cf->ctx, &hdr->TargetIdentity->gg, zx_e_mustUnderstand_ATTR, XML_TRUE); hdr->TargetIdentity->actor = zx_ref_attr(cf->ctx, &hdr->TargetIdentity->gg, zx_e_actor_ATTR, SOAP_ACTOR_NEXT); if (tok->EncryptedAssertion) { ZX_ADD_KID(hdr->TargetIdentity, EncryptedAssertion, tok->EncryptedAssertion); } else if (tok->Assertion) { ZX_ADD_KID(hdr->TargetIdentity, Assertion, tok->Assertion); } else { ERR("No <sa:EncryptedAssertion> or <sa:Assertion> found in <sec:Token> %p", tok); } } /* else this is just implied by the sec mech */ /* 10. UsageDirective */ zxid_attach_sol1_usage_directive(cf, ses, env, TAS3_PLEDGE, cf->wsc_localpdp_obl_pledge); zx_reverse_elem_lists(&hdr->gg); return 1; }