/* * Simply dump the XACML response. * * @param [in] response the XAXML response * @return 0 on success or error code on failure. */ static int process_xacml_response(const xacml_response_t * response) { size_t results_l; int i, j, k; if (response == NULL) { fprintf(stderr,"response is NULL\n"); return 1; } results_l= xacml_response_results_length(response); fprintf(stdout,"response: %d results\n", (int)results_l); for(i= 0; i<results_l; i++) { xacml_result_t * result; xacml_status_t * status; xacml_statuscode_t * statuscode, * subcode; size_t obligations_l; result= xacml_response_getresult(response,i); fprintf(stdout,"response.result[%d].decision= %s\n", i, decision_tostring(xacml_result_getdecision(result))); fprintf(stdout,"response.result[%d].resourceid= %s\n", i, xacml_result_getresourceid(result)); status= xacml_result_getstatus(result); fprintf(stdout,"response.result[%d].status.message= %s\n", i, xacml_status_getmessage(status)); statuscode= xacml_status_getcode(status); fprintf(stdout,"response.result[%d].status.code.value= %s\n", i, xacml_statuscode_getvalue(statuscode)); subcode= xacml_statuscode_getsubcode(statuscode); if (subcode != NULL) { fprintf(stdout,"response.result[%d].status.code.subcode.value= %s\n", i, xacml_statuscode_getvalue(subcode)); } obligations_l= xacml_result_obligations_length(result); fprintf(stdout,"response.result[%d]: %d obligations\n", i, (int)obligations_l); for(j= 0; j<obligations_l; j++) { size_t attrs_l; xacml_obligation_t * obligation= xacml_result_getobligation(result,j); fprintf(stdout,"response.result[%d].obligation[%d].id= %s\n",i,j, xacml_obligation_getid(obligation)); fprintf(stdout,"response.result[%d].obligation[%d].fulfillOn= %s\n",i,j, fulfillon_tostring(xacml_obligation_getfulfillon(obligation))); attrs_l= xacml_obligation_attributeassignments_length(obligation); fprintf(stdout,"response.result[%d].obligation[%d]: %d attribute assignments\n",i,j,(int)attrs_l); for (k= 0; k<attrs_l; k++) { xacml_attributeassignment_t * attr= xacml_obligation_getattributeassignment(obligation,k); fprintf(stdout,"response.result[%d].obligation[%d].attributeassignment[%d].id= %s\n",i,j,k,xacml_attributeassignment_getid(attr)); fprintf(stdout,"response.result[%d].obligation[%d].attributeassignment[%d].datatype= %s\n",i,j,k,xacml_attributeassignment_getdatatype(attr)); fprintf(stdout,"response.result[%d].obligation[%d].attributeassignment[%d].value= %s\n",i,j,k,xacml_attributeassignment_getvalue(attr)); } } } return 0; }
/* * Dumps a XACML response. */ static int dump_response(xacml_response_t ** response_ptr) { xacml_response_t * response= *response_ptr; if (response == NULL) { error("dump_response: response is NULL"); return 1; } size_t results_l= xacml_response_results_length(response); info("response: %d results", (int)results_l); int i= 0; for(i= 0; i<results_l; i++) { xacml_result_t * result= xacml_response_getresult(response,i); info("response.result[%d].decision= %s", i, decision_str(xacml_result_getdecision(result))); info("response.result[%d].resourceid= %s", i, xacml_result_getresourceid(result)); xacml_status_t * status= xacml_result_getstatus(result); info("response.result[%d].status.message= %s", i, xacml_status_getmessage(status)); xacml_statuscode_t * statuscode= xacml_status_getcode(status); info("response.result[%d].status.code.value= %s", i, xacml_statuscode_getvalue(statuscode)); xacml_statuscode_t * subcode= xacml_statuscode_getsubcode(statuscode); if (subcode != NULL) { info("response.result[%d].status.code.subcode.value= %s", i, xacml_statuscode_getvalue(subcode)); } size_t obligations_l= xacml_result_obligations_length(result); info("response.result[%d]: %d obligations", i, (int)obligations_l); int j=0; for(j= 0; j<obligations_l; j++) { xacml_obligation_t * obligation= xacml_result_getobligation(result,j); info("response.result[%d].obligation[%d].id= %s",i,j, xacml_obligation_getid(obligation)); info("response.result[%d].obligation[%d].fulfillOn= %s",i,j, decision_str(xacml_obligation_getfulfillon(obligation))); size_t attrs_l= xacml_obligation_attributeassignments_length(obligation); info("response.result[%d].obligation[%d]: %d attribute assignments",i,j,(int)attrs_l); int k= 0; for (k= 0; k<attrs_l; k++) { xacml_attributeassignment_t * attr= xacml_obligation_getattributeassignment(obligation,k); info("response.result[%d].obligation[%d].attributeassignment[%d].id= %s",i,j,k,xacml_attributeassignment_getid(attr)); info("response.result[%d].obligation[%d].attributeassignment[%d].datatype= %s",i,j,k,xacml_attributeassignment_getdatatype(attr)); info("response.result[%d].obligation[%d].attributeassignment[%d].value= %s",i,j,k,xacml_attributeassignment_getvalue(attr)); } } } return 0; }