mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 18:18:03 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -47,30 +47,40 @@ namespace OpenWifi {
|
|||||||
ProvObjects::GLBLRCertificateInfo &NewCertificate) {
|
ProvObjects::GLBLRCertificateInfo &NewCertificate) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
auto BearerToken = MakeToken(GlobalReachAccountId);
|
auto BearerToken = MakeToken(GlobalReachAccountId);
|
||||||
Poco::URI URI{"https://config.openro.am/v1/radsec/issue"};
|
Poco::URI URI{"https://config.openro.am/v1/radsec/issue"};
|
||||||
std::string Path(URI.getPathAndQuery());
|
std::string Path(URI.getPathAndQuery());
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST, Path,
|
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST, Path,
|
||||||
Poco::Net::HTTPMessage::HTTP_1_1);
|
Poco::Net::HTTPMessage::HTTP_1_1);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
|
|
||||||
Request.add("Authorization", "Bearer " + BearerToken);
|
Request.add("Authorization", "Bearer " + BearerToken);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
|
|
||||||
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
||||||
Session.setTimeout(Poco::Timespan(10000, 10000));
|
Session.setTimeout(Poco::Timespan(10000, 10000));
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
Poco::JSON::Object CertRequestBody;
|
Poco::JSON::Object CertRequestBody;
|
||||||
CertRequestBody.set("name", Name);
|
CertRequestBody.set("name", Name);
|
||||||
CertRequestBody.set("csr", CSR);
|
CertRequestBody.set("csr", CSR);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
CertRequestBody.stringify(os);
|
CertRequestBody.stringify(os);
|
||||||
Request.setContentType("application/json");
|
Request.setContentType("application/json");
|
||||||
Request.setContentLength((long) os.str().size());
|
Request.setContentLength((long) os.str().size());
|
||||||
|
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
auto &Body = Session.sendRequest(Request);
|
auto &Body = Session.sendRequest(Request);
|
||||||
Body << os.str();
|
Body << os.str();
|
||||||
|
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
Poco::Net::HTTPResponse Response;
|
Poco::Net::HTTPResponse Response;
|
||||||
std::istream &is = Session.receiveResponse(Response);
|
std::istream &is = Session.receiveResponse(Response);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
Poco::JSON::Parser P;
|
Poco::JSON::Parser P;
|
||||||
auto Result = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
auto Result = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||||
@@ -80,8 +90,10 @@ namespace OpenWifi {
|
|||||||
NewCertificate.certificateChain = Result->get("certificate_chain").toString();
|
NewCertificate.certificateChain = Result->get("certificate_chain").toString();
|
||||||
NewCertificate.certificateId = Result->get("certificate_id").toString();
|
NewCertificate.certificateId = Result->get("certificate_id").toString();
|
||||||
NewCertificate.expiresAt = Result->get("expires_at");
|
NewCertificate.expiresAt = Result->get("expires_at");
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
std::cout << Response.getStatus() << std::endl;
|
||||||
} catch( const Poco::Exception &E) {
|
} catch( const Poco::Exception &E) {
|
||||||
poco_error(Logger(),fmt::format("Could not create a new RADSEC certificate: {},{}",E.name(),E.displayText()));
|
poco_error(Logger(),fmt::format("Could not create a new RADSEC certificate: {},{}",E.name(),E.displayText()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -618,9 +618,7 @@ getsystemconfiguration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
creategraccount() {
|
creategraccount() {
|
||||||
payload="{ \"name\" : \"Test account\" , \"country\" : \"CA\", \"province\" : \"BC\" , \"city\" : \"Vancouver\", \"organization\" : \"Arilia Wireless Inc.\", \"commonName\" : \"arilia.com\", \"GlobalReachAcctId\" : \"bd63aaa7-b14d-4cdb-85ae-8de6cf2cfa31\", \"privateKey\" : \"-----BEGIN PRIVATE KEY-----MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgl1FpARtuOtw1F9sR2DD82jh6sZFGRn619IY0rmNIFEuhRANCAATB7ji6OF/+heGRCocgVNhw4QGvaL9Kp8F6ZqqZ3aMewRMOfzi3TQaXN12FNBsvXnptx5vk8GAzZk6UAzzvMBVK-----END PRIVATE KEY-----\" }"
|
payload="{ \"name\" : \"Test account\" , \"country\" : \"CA\", \"province\" : \"BC\" , \"city\" : \"Vancouver\", \"organization\" : \"Arilia Wireless Inc.\", \"commonName\" : \"arilia.com\", \"GlobalReachAcctId\" : \"bd63aaa7-b14d-4cdb-85ae-8de6cf2cfa31\", \"privateKey\" : \"-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgl1FpARtuOtw1F9sR2DD82jh6sZFGRn619IY0rmNIFEuhRANCAATB7ji6OF/+heGRCocgVNhw4QGvaL9Kp8F6ZqqZ3aMewRMOfzi3TQaXN12FNBsvXnptx5vk8GAzZk6UAzzvMBVK\n-----END PRIVATE KEY-----\" }"
|
||||||
echo $payload | jq
|
|
||||||
|
|
||||||
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/openroaming/globalreach/account/0" \
|
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/openroaming/globalreach/account/0" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Authorization: Bearer ${token}" \
|
-H "Authorization: Bearer ${token}" \
|
||||||
@@ -629,6 +627,41 @@ creategraccount() {
|
|||||||
jq < ${result_file}
|
jq < ${result_file}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getgraccount() {
|
||||||
|
curl ${FLAGS} -X GET "https://${OWPROV}/api/v1/openroaming/globalreach/account/$1" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "Accept: application/json" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
|
deletegraccount() {
|
||||||
|
curl ${FLAGS} -X DELETE "https://${OWPROV}/api/v1/openroaming/globalreach/account/$1" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "Accept: application/json" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
|
getgraccounts() {
|
||||||
|
curl ${FLAGS} -X GET "https://${OWPROV}/api/v1/openroaming/globalreach/accounts" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "Accept: application/json" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
|
creategrcert() {
|
||||||
|
payload="{ \"name\" : \"$2\" }"
|
||||||
|
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/openroaming/globalreach/certificate/$1/0" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
-d "$payload" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
shopt -s nocasematch
|
shopt -s nocasematch
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"login") login; echo "You are logged in..." ; logout ;;
|
"login") login; echo "You are logged in..." ; logout ;;
|
||||||
@@ -686,6 +719,10 @@ case "$1" in
|
|||||||
"venueupgraderevisions") login; venueupgraderevisions "$2"; logout;;
|
"venueupgraderevisions") login; venueupgraderevisions "$2"; logout;;
|
||||||
"getsystemconfiguration") login; getsystemconfiguration "$2"; logout;;
|
"getsystemconfiguration") login; getsystemconfiguration "$2"; logout;;
|
||||||
"creategraccount") login; creategraccount ; logout;;
|
"creategraccount") login; creategraccount ; logout;;
|
||||||
|
"getgraccount") login; getgraccount "$2"; logout;;
|
||||||
|
"getgraccounts") login; getgraccounts ; logout;;
|
||||||
|
"creategrcert") login; creategrcert "$2" "$3"; logout;;
|
||||||
|
"deletegraccount") login; deletegraccount "$2"; logout;;
|
||||||
"getvenuesperrrm") login; getvenuesperrrm "$2"; logout;;
|
"getvenuesperrrm") login; getvenuesperrrm "$2"; logout;;
|
||||||
*) help ;;
|
*) help ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user