Commit b71c7c92 authored by HFJ's avatar HFJ

add basic udm confirmation post

parent bbe21d53
......@@ -94,7 +94,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
uint8_t authCtxId_seaf[16];
conv::hex_str_to_uint8(authCtxId.c_str(), authCtxId_seaf); //authCtxId in seaf
Logger::ausf_server().debug("authCtxId in ausf:\n %s", (conv::uint8_to_hex_string(ausf_av_s.autn, 16)).c_str());
Logger::ausf_server().debug("authCtxId in ausf: %s", (conv::uint8_to_hex_string(ausf_av_s.autn, 16)).c_str());
bool is_auth_vectors_present = Authentication_5gaka::equal_uint8(ausf_av_s.autn,authCtxId_seaf,16);
if(!is_auth_vectors_present) //AV expired
......@@ -113,7 +113,8 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
//get stored xres* -----
uint8_t xresStar[16] = {0};
memcpy(xresStar,XRES_STAR,16); //xres* stored for 5g-aka-confirmation
Logger::ausf_server().debug("xres* in ausf:\n %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str());
Logger::ausf_server().debug("xres* in ausf: %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str());
Logger::ausf_server().debug("xres in amf: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str());
bool authResult = Authentication_5gaka::equal_uint8(xresStar,resStar,16);
confirmResponse.setAuthResult(authResult); //3.向SEAF指示,从本地网络角度认证是否成功
......@@ -131,11 +132,48 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
kseaf_s = conv::uint8_to_hex_string(ausf_av_s.kseaf, 32); // convert uint8_t to string
confirmResponse.setKseaf(kseaf_s);
//send supi when supi_ausf exists
//5.send supi when supi_ausf exists
if(!SUPI_AUSF.empty())
{
confirmResponse.setSupi(SUPI_AUSF);
}
//6. send authResult to udm
//UDM POST interface ----- send authentication result info--------------------
std::string udm_ip = std::string(inet_ntoa (*((struct in_addr *)&ausf_cfg.nudm.addr4))); //need to change to nudm
std::string udm_port = std::to_string(ausf_cfg.nudm.port);
std::string udmUri;
std::string Method;
std::string Response;
//UDM POST interface ----- get authentication related info--------------------
udmUri = "http://" + udm_ip+ ":" + udm_port + "/nudm-ueau/v1/" + SUPI_AUSF + "/auth-events";
cout << udmUri.c_str() << endl;
//udmUri = "http://192.168.21.136:8181/nudm-ueau/v1/imsi-460011111111111/auth-events";
Logger::ausf_server().debug("POST Request:" + udmUri);
Method = "POST";
//form udm request body AuthInfo
nlohmann::json confirmResultInfo = {};
//form udm request body AuthInfo
//nfInstanceId
confirmResultInfo["nfInstanceId"] = "400346f4-087e-40b1-a4cd-00566953999d"; //fixed, may need to change
//success
confirmResultInfo["success"] = true;
//timeStamp
confirmResultInfo["timeStamp"] = "2020-08-12T17:02:51.128672225+09:00"; //PARAM
//authType
confirmResultInfo["authType"] = "5G_AKA"; //PARAM
//servingNetworkName
confirmResultInfo["servingNetworkName"] = "5G:mnc001.mcc460.3gppnetwork.org"; //PARAM
//authRemovalInd
confirmResultInfo["authRemovalInd"] = false;
cout << confirmResultInfo.dump() << endl;
Curl::curl_http_client(udmUri, Method, confirmResultInfo.dump() , Response);
}
}
......@@ -145,7 +183,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
to_json(confirmResponse_json, confirmResponse);
Logger::ausf_server().debug("5g-aka-confirmation response:\n %s",confirmResponse_json.dump().c_str());
Logger::ausf_server().info("Send 5g-aka-confirmation response to SEAF");
Logger::ausf_server().info("Send 5g-aka-confirmation 200 response to SEAF");
response.send(Pistache::Http::Code::Ok, confirmResponse_json.dump());
......@@ -181,11 +219,10 @@ void DefaultApiImpl::ue_authentications_post(
//UDM POST interface ----- get authentication related info--------------------
udmUri = "http://" + udm_ip+ ":" + udm_port + "/nudm-ueau/v1/" + supi + "/security-information/generate-auth-data";
//udmUri = "http://192.168.21.134:8181/nudm-ueau/v1/imsi-460011111111111/security-information/generate-auth-data";
Logger::ausf_server().debug("POST Request:" + udmUri);
Method = "POST";
//form udm request body AuthInso
//form udm request body AuthInfo
nlohmann::json AuthInfo = {}; //model AuthenticationInfo do not have ausfInstanceId field
AuthInfo["servingNetworkName"] = snn;
AuthInfo["ausfInstanceId"] = "400346f4-087e-40b1-a4cd-00566953999d"; //fixed, may need to change
......@@ -220,7 +257,7 @@ void DefaultApiImpl::ue_authentications_post(
Logger::ausf_server().debug("rand_udm %s",rand_udm.c_str());
std::string xresStar_udm = response_data["authenticationVector"].at("xresStar");
Logger::ausf_server().debug("xresStar_udm %s",autn_udm.c_str());
Logger::ausf_server().debug("xres*_udm %s",xresStar_udm.c_str());
//------------------5G HE AV-----------------------------------------------------
uint8_t autn[16] = {0};
......@@ -276,7 +313,9 @@ void DefaultApiImpl::ue_authentications_post(
KAUSF_TMP = conv::uint8_to_hex_string(kausf_ausf,32);
//store xres* for 5g-aka-confirmation
Logger::ausf_server().debug("xres*_udm %s",xresStar_udm.c_str());
memcpy(XRES_STAR,xresStar,16);
Logger::ausf_server().debug("xres*_ausf %s",conv::uint8_to_hex_string(XRES_STAR,16).c_str());
/*----------------ausf --> seaf-----------*/
//---forming response
......@@ -306,6 +345,10 @@ void DefaultApiImpl::ue_authentications_post(
resourceURI = "http://" + ausf_ip + ":" + ausf_port + "/nausf-auth/v1/ue-authentications/" + authCtxId_s + "/5g-aka-confirmation";
ausf_Href.setHref(resourceURI); //"/nausf-auth/v1/ue-authentications/640110987654321/5g-aka-confirmation"
std::string Location = resourceURI;
// cout << ausf_Href.getHref().c_str() << endl;
ausf_links["5G_AKA"] = ausf_Href;
UEAuthCtx.setLinks(ausf_links);
......@@ -321,7 +364,8 @@ void DefaultApiImpl::ue_authentications_post(
to_json(UEAuthCtx_json,UEAuthCtx);
Logger::ausf_server().debug("auth response:\n %s",UEAuthCtx_json.dump().c_str());
Logger::ausf_server().info("Send response to SEAF");
Logger::ausf_server().info("Send 201 response to SEAF");
response.headers().add<Pistache::Http::Header::Location>(Location);
response.send(Pistache::Http::Code::Created, UEAuthCtx_json.dump()); //Type: json object to string
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment