Commit 94ce9678 authored by HFJ's avatar HFJ

ue_authentications fixed

parent 908d873b
......@@ -21,10 +21,15 @@
#include "conversions.hpp"
#include "sha256.hpp"
#include "Av5gAka.h"
#include "UEAuthenticationCtx.h"
#include "ConfirmationDataResponse.h"
#include <typeinfo>
#include <map>
#include "ausf_config.hpp"
using namespace config;
extern ausf_config ausf_cfg;
using namespace std;
......@@ -38,7 +43,8 @@ using namespace org::openapitools::server::model;
//stored temporarily
uint8_t XRES_STAR[16]; //store xres*
uint8_t KSEAF[32];
// uint8_t KSEAF[32];
uint8_t kAUSF[32];
typedef struct {
uint8_t rand[16];
......@@ -233,19 +239,54 @@ void DefaultApiImpl::ue_authentications_post(
string hxresStar_s;
hxresStar_s = conv::uint8_to_hex_string(hxresStar, 16);
// convert to json
Av5gAka AuthResponse;
AuthResponse.setRand(rand_s);
AuthResponse.setAutn(autn_s);
AuthResponse.setHxresStar(hxresStar_s);
nlohmann::json AuthResponse_json;
to_json(AuthResponse_json,AuthResponse);
Logger::ausf_server().debug("auth response:\n %s",AuthResponse_json.dump().c_str());
// nlohmann::json AuthInfoResult = {};
// AuthInfoResult["authType"] = "5G_AKA";
// AuthInfoResult["_links"] = "5G_AKA";
// AuthInfoResult["5gAuthData"]["avType"] = "5G_SE_AKA";
// AuthInfoResult["5gAuthData"]["rand"] = rand_s;
// AuthInfoResult["5gAuthData"]["autn"] = autn_s;
// AuthInfoResult["5gAuthData"]["hxresStar"] = hxresStar_s;
// Logger::ausf_server().debug("auth response:\n %s",AuthInfoResult.dump().c_str());
// Logger::ausf_server().info("Send response to seaf");
// response.send(Pistache::Http::Code::Created, AuthInfoResult.dump());
UEAuthenticationCtx UEAuthCtx;
//-------authType(string)
UEAuthCtx.setAuthType("5G_AKA");
//-------_links(std::map)
std::map<std::string, LinksValueSchema> ausf_links;
LinksValueSchema ausf_Href;
std::string resourceURI;
std::string authCtxId;
std::string ausf_ip = std::string(inet_ntoa (*((struct in_addr *)&ausf_cfg.nudr.addr4)));
std::string ausf_port = std::to_string(ausf_cfg.sbi.port);
authCtxId = supi; //unsecure, supi leaked
resourceURI = "http://" + ausf_ip + ":" + ausf_port + "/nausf-auth/v1/ue-authentications/" + authCtxId + "/5g-aka-confirmation";
ausf_Href.setHref(resourceURI); //"/nausf-auth/v1/ue-authentications/640110987654321/5g-aka-confirmation"
cout << ausf_Href.getHref().c_str() << endl;
ausf_links["5g_aka_confirmation_put"] = ausf_Href;
UEAuthCtx.setLinks(ausf_links);
//----------5gAuthData(Av5gAka):rand autn hxresStar
Av5gAka ausf_5gAuthData;
ausf_5gAuthData.setRand(rand_s);
ausf_5gAuthData.setAutn(autn_s);
ausf_5gAuthData.setHxresStar(hxresStar_s);
UEAuthCtx.setR5gAuthData(ausf_5gAuthData);
nlohmann::json UEAuthCtx_json;
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");
response.send(Pistache::Http::Code::Created, AuthResponse_json.dump()); //Type: json object to string
response.send(Pistache::Http::Code::Created, UEAuthCtx_json.dump()); //Type: json object to string
}
} // namespace api
......
......@@ -56,11 +56,11 @@ void from_json(const nlohmann::json& j, UEAuthenticationCtx& o)
}
}
AuthType UEAuthenticationCtx::getAuthType() const
std::string UEAuthenticationCtx::getAuthType() const
{
return m_AuthType;
}
void UEAuthenticationCtx::setAuthType(AuthType const& value)
void UEAuthenticationCtx::setAuthType(std::string const& value)
{
m_AuthType = value;
}
......
......@@ -49,8 +49,8 @@ public:
/// <summary>
///
/// </summary>
AuthType getAuthType() const;
void setAuthType(AuthType const& value);
std::string getAuthType() const;
void setAuthType(std::string const& value);
/// <summary>
///
/// </summary>
......@@ -72,7 +72,7 @@ public:
friend void to_json(nlohmann::json& j, const UEAuthenticationCtx& o);
friend void from_json(const nlohmann::json& j, UEAuthenticationCtx& o);
protected:
AuthType m_AuthType;
std::string m_AuthType;
Av5gAka m_r_5gAuthData;
......
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