sl_reply("500","Could not create transaction");
exit;
}
if (!ims_www_authenticate(NETWORKNAME)) {
if ($? == -2) {
t_reply("403", "Authentication Failed");
exit;
} else if ($? == -3) {
t_reply("400", "Bad Request");
exit;
} else {
#user has not been authenticated. Lets send a challenge via 401 Unauthorized
xlog("L_DBG","About to challenge! auth_ims\n");
ims_www_challenge("$td");
#this is async so to know status we have to check the reply avp
xlog("L_DBG","maa_return code is $avp(s:maa_return_code)\n");
switch ($avp(s:maa_return_code)){
case 1: #success
xlog("L_DBG", "MAR success - 401/407 response sent from module");
break;
case -1: #failure
xlog("L_ERR", "MAR failure - error response sent from module");
break;
case -2: #error
xlog("L_ERR", "MAR error - sending error response now");
t_reply("500", "MAR failed");
break;
default:
xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]");
t_reply("500", "Unknown response code from MAR");
break;
}
exit;
}
}
else {
if (!impu_registered("location")) {
xlog("L_DBG","IMPU not registered\n");
save("location");
#this is async so to know status we have to check the reply avp
xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
switch ($avp(s:saa_return_code)){
case 1: #success
xlog("L_DBG", "SAR success - 200 response sent from module");
isc_match_filter_reg("0","location");
exit;
case -1: #failure
xlog("L_ERR", "SAR failure - error response sent from module");
break;
case -2: #error
xlog("L_ERR", "SAR error - error response sent from module");
break;
default:
xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]");
break;
}
} else {
xlog("L_DBG","IMPU registered\n");
isc_match_filter_reg("1","location");
save("location");
#this is async so to know status we have to check the reply avp
xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
switch ($avp(s:saa_return_code)){
case 1: #success
xlog("L_DBG", "SAR success - 200 response sent from module");
exit;
case -1: #failure
xlog("L_ERR", "SAR failure - error response sent from module");
break;
case -2: #error
xlog("L_ERR", "SAR error - error response sent from module");
break;
default:
xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]");
break;
}
}
}
break;
}