mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 11:37:54 +00:00
Fixing framework
This commit is contained in:
@@ -59,7 +59,7 @@ namespace OpenWifi {
|
|||||||
if (i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForEmail ||
|
if (i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForEmail ||
|
||||||
i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForDevice ||
|
i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForDevice ||
|
||||||
i.statusCode == ProvObjects::SignupStatusCodes::SignupSuccess ) {
|
i.statusCode == ProvObjects::SignupStatusCodes::SignupSuccess ) {
|
||||||
Logger().information(Poco::format("SIGNUP: Returning existing signup record for '%s'",i.email));
|
Logger().information(fmt::format("SIGNUP: Returning existing signup record for '{}'",i.email));
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
i.to_json(Answer);
|
i.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -94,7 +94,7 @@ namespace OpenWifi {
|
|||||||
// Let's create one
|
// Let's create one
|
||||||
// If sec.signup("email",uuid);
|
// If sec.signup("email",uuid);
|
||||||
auto SignupUUID = MicroService::instance().CreateUUID();
|
auto SignupUUID = MicroService::instance().CreateUUID();
|
||||||
Logger().information(Poco::format("SIGNUP: Creating signup entry for '%s', uuid=%s",UserName, SignupUUID));
|
Logger().information(fmt::format("SIGNUP: Creating signup entry for '{}', uuid='{}'",UserName, SignupUUID));
|
||||||
|
|
||||||
Poco::JSON::Object Body;
|
Poco::JSON::Object Body;
|
||||||
OpenAPIRequestPost CreateUser( uSERVICE_SECURITY, "/api/v1/signup", {
|
OpenAPIRequestPost CreateUser( uSERVICE_SECURITY, "/api/v1/signup", {
|
||||||
@@ -111,7 +111,7 @@ namespace OpenWifi {
|
|||||||
UI.from_json(Answer);
|
UI.from_json(Answer);
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
Answer->stringify(os);
|
Answer->stringify(os);
|
||||||
Logger().information(Poco::format("SIGNUP: email: '%s' signupID: '%s' userId: '%s'", UserName, SignupUUID, UI.id));
|
Logger().information(fmt::format("SIGNUP: email: '{}' signupID: '{}' userId: '{}'", UserName, SignupUUID, UI.id));
|
||||||
|
|
||||||
// so create the Signup entry and modify the inventory
|
// so create the Signup entry and modify the inventory
|
||||||
ProvObjects::SignupEntry SE;
|
ProvObjects::SignupEntry SE;
|
||||||
|
|||||||
@@ -4311,15 +4311,14 @@ namespace OpenWifi {
|
|||||||
auto Services = MicroService::instance().GetServices(Type_);
|
auto Services = MicroService::instance().GetServices(Type_);
|
||||||
for(auto const &Svc:Services) {
|
for(auto const &Svc:Services) {
|
||||||
Poco::URI URI(Svc.PrivateEndPoint);
|
Poco::URI URI(Svc.PrivateEndPoint);
|
||||||
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
|
||||||
|
auto Secure = (URI.getScheme() == "https");
|
||||||
|
|
||||||
URI.setPath(EndPoint_);
|
URI.setPath(EndPoint_);
|
||||||
for (const auto &qp : QueryData_)
|
for (const auto &qp : QueryData_)
|
||||||
URI.addQueryParameter(qp.first, qp.second);
|
URI.addQueryParameter(qp.first, qp.second);
|
||||||
|
|
||||||
std::string Path(URI.getPathAndQuery());
|
std::string Path(URI.getPathAndQuery());
|
||||||
Session.setTimeout(Poco::Timespan(msTimeout_/1000, msTimeout_ % 1000));
|
|
||||||
|
|
||||||
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
Path,
|
Path,
|
||||||
Poco::Net::HTTPMessage::HTTP_1_1);
|
Poco::Net::HTTPMessage::HTTP_1_1);
|
||||||
@@ -4332,15 +4331,33 @@ namespace OpenWifi {
|
|||||||
Request.add("Authorization", "Bearer " + BearerToken);
|
Request.add("Authorization", "Bearer " + BearerToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
Session.sendRequest(Request);
|
if(Secure) {
|
||||||
|
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
||||||
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
|
||||||
Poco::Net::HTTPResponse Response;
|
Session.sendRequest(Request);
|
||||||
std::istream &is = Session.receiveResponse(Response);
|
|
||||||
if(Response.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
|
Poco::Net::HTTPResponse Response;
|
||||||
Poco::JSON::Parser P;
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
}
|
||||||
|
return Response.getStatus();
|
||||||
|
} else {
|
||||||
|
Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
|
||||||
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
|
||||||
|
Session.sendRequest(Request);
|
||||||
|
|
||||||
|
Poco::Net::HTTPResponse Response;
|
||||||
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
}
|
||||||
|
return Response.getStatus();
|
||||||
}
|
}
|
||||||
return Response.getStatus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Poco::Exception &E)
|
catch (const Poco::Exception &E)
|
||||||
@@ -4355,14 +4372,14 @@ namespace OpenWifi {
|
|||||||
auto Services = MicroService::instance().GetServices(Type_);
|
auto Services = MicroService::instance().GetServices(Type_);
|
||||||
for(auto const &Svc:Services) {
|
for(auto const &Svc:Services) {
|
||||||
Poco::URI URI(Svc.PrivateEndPoint);
|
Poco::URI URI(Svc.PrivateEndPoint);
|
||||||
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
|
||||||
|
auto Secure = (URI.getScheme() == "https");
|
||||||
|
|
||||||
URI.setPath(EndPoint_);
|
URI.setPath(EndPoint_);
|
||||||
for (const auto &qp : QueryData_)
|
for (const auto &qp : QueryData_)
|
||||||
URI.addQueryParameter(qp.first, qp.second);
|
URI.addQueryParameter(qp.first, qp.second);
|
||||||
|
|
||||||
std::string Path(URI.getPathAndQuery());
|
std::string Path(URI.getPathAndQuery());
|
||||||
Session.setTimeout(Poco::Timespan(msTimeout_/1000, msTimeout_ % 1000));
|
|
||||||
|
|
||||||
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_PUT,
|
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_PUT,
|
||||||
Path,
|
Path,
|
||||||
@@ -4381,19 +4398,41 @@ namespace OpenWifi {
|
|||||||
Request.add("Authorization", "Bearer " + BearerToken);
|
Request.add("Authorization", "Bearer " + BearerToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream & os = Session.sendRequest(Request);
|
if(Secure) {
|
||||||
os << obody.str();
|
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
||||||
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
|
||||||
Poco::Net::HTTPResponse Response;
|
std::ostream &os = Session.sendRequest(Request);
|
||||||
std::istream &is = Session.receiveResponse(Response);
|
os << obody.str();
|
||||||
if(Response.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
|
|
||||||
Poco::JSON::Parser P;
|
Poco::Net::HTTPResponse Response;
|
||||||
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
} else {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
}
|
||||||
|
return Response.getStatus();
|
||||||
} else {
|
} else {
|
||||||
Poco::JSON::Parser P;
|
Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
|
||||||
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
|
||||||
|
std::ostream &os = Session.sendRequest(Request);
|
||||||
|
os << obody.str();
|
||||||
|
|
||||||
|
Poco::Net::HTTPResponse Response;
|
||||||
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
} else {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
}
|
||||||
|
return Response.getStatus();
|
||||||
}
|
}
|
||||||
return Response.getStatus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Poco::Exception &E)
|
catch (const Poco::Exception &E)
|
||||||
@@ -4409,14 +4448,14 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
for(auto const &Svc:Services) {
|
for(auto const &Svc:Services) {
|
||||||
Poco::URI URI(Svc.PrivateEndPoint);
|
Poco::URI URI(Svc.PrivateEndPoint);
|
||||||
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
|
||||||
|
auto Secure = (URI.getScheme() == "https");
|
||||||
|
|
||||||
URI.setPath(EndPoint_);
|
URI.setPath(EndPoint_);
|
||||||
for (const auto &qp : QueryData_)
|
for (const auto &qp : QueryData_)
|
||||||
URI.addQueryParameter(qp.first, qp.second);
|
URI.addQueryParameter(qp.first, qp.second);
|
||||||
|
|
||||||
std::string Path(URI.getPathAndQuery());
|
std::string Path(URI.getPathAndQuery());
|
||||||
Session.setTimeout(Poco::Timespan(msTimeout_/1000, msTimeout_ % 1000));
|
|
||||||
|
|
||||||
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
Path,
|
Path,
|
||||||
@@ -4435,19 +4474,39 @@ namespace OpenWifi {
|
|||||||
Request.add("Authorization", "Bearer " + BearerToken);
|
Request.add("Authorization", "Bearer " + BearerToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream & os = Session.sendRequest(Request);
|
if(Secure) {
|
||||||
os << obody.str();
|
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
||||||
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
std::ostream &os = Session.sendRequest(Request);
|
||||||
|
os << obody.str();
|
||||||
|
|
||||||
Poco::Net::HTTPResponse Response;
|
Poco::Net::HTTPResponse Response;
|
||||||
std::istream &is = Session.receiveResponse(Response);
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
if(Response.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
Poco::JSON::Parser P;
|
Poco::JSON::Parser P;
|
||||||
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
} else {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
}
|
||||||
|
return Response.getStatus();
|
||||||
} else {
|
} else {
|
||||||
Poco::JSON::Parser P;
|
Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
|
||||||
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
std::ostream &os = Session.sendRequest(Request);
|
||||||
|
os << obody.str();
|
||||||
|
|
||||||
|
Poco::Net::HTTPResponse Response;
|
||||||
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
} else {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
}
|
||||||
|
return Response.getStatus();
|
||||||
}
|
}
|
||||||
return Response.getStatus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Poco::Exception &E)
|
catch (const Poco::Exception &E)
|
||||||
@@ -4463,14 +4522,14 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
for(auto const &Svc:Services) {
|
for(auto const &Svc:Services) {
|
||||||
Poco::URI URI(Svc.PrivateEndPoint);
|
Poco::URI URI(Svc.PrivateEndPoint);
|
||||||
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
|
||||||
|
auto Secure = (URI.getScheme() == "https");
|
||||||
|
|
||||||
URI.setPath(EndPoint_);
|
URI.setPath(EndPoint_);
|
||||||
for (const auto &qp : QueryData_)
|
for (const auto &qp : QueryData_)
|
||||||
URI.addQueryParameter(qp.first, qp.second);
|
URI.addQueryParameter(qp.first, qp.second);
|
||||||
|
|
||||||
std::string Path(URI.getPathAndQuery());
|
std::string Path(URI.getPathAndQuery());
|
||||||
Session.setTimeout(Poco::Timespan(msTimeout_/1000, msTimeout_ % 1000));
|
|
||||||
|
|
||||||
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_DELETE,
|
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_DELETE,
|
||||||
Path,
|
Path,
|
||||||
@@ -4483,10 +4542,21 @@ namespace OpenWifi {
|
|||||||
Request.add("Authorization", "Bearer " + BearerToken);
|
Request.add("Authorization", "Bearer " + BearerToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
Session.sendRequest(Request);
|
if(Secure) {
|
||||||
Poco::Net::HTTPResponse Response;
|
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
||||||
Session.receiveResponse(Response);
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
return Response.getStatus();
|
Session.sendRequest(Request);
|
||||||
|
Poco::Net::HTTPResponse Response;
|
||||||
|
Session.receiveResponse(Response);
|
||||||
|
return Response.getStatus();
|
||||||
|
} else {
|
||||||
|
Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
|
||||||
|
Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
|
||||||
|
Session.sendRequest(Request);
|
||||||
|
Poco::Net::HTTPResponse Response;
|
||||||
|
Session.receiveResponse(Response);
|
||||||
|
return Response.getStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Poco::Exception &E)
|
catch (const Poco::Exception &E)
|
||||||
|
|||||||
Reference in New Issue
Block a user