Commit 240bfc95 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Add files for NRF_AccessToken

parent f26c2640
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "AccessTokenRequestApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::app::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
namespace api {
using namespace oai::nrf::helpers;
using namespace oai::nrf::model;
AccessTokenRequestApi::AccessTokenRequestApi(std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
void AccessTokenRequestApi::init() {
setupRoutes();
}
void AccessTokenRequestApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(*router, base + nrf_cfg.sbi_api_version + "/oauth2/token", Routes::bind(&AccessTokenRequestApi::access_token_request_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&AccessTokenRequestApi::access_token_request_api_default_handler, this));
}
void AccessTokenRequestApi::access_token_request_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {
this->access_token_request(request, response);
} catch (nlohmann::detail::exception &e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
void AccessTokenRequestApi::access_token_request_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
}
}
}
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* AccessTokenRequestApi.h
*
*
*/
#ifndef AccessTokenRequestApi_H_
#define AccessTokenRequestApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include "AccessTokenErr.h"
#include "AccessTokenRsp.h"
#include "NFType.h"
#include "PlmnId.h"
#include "ProblemDetails.h"
#include <string>
namespace oai {
namespace nrf {
namespace api {
using namespace oai::nrf::model;
class AccessTokenRequestApi {
public:
AccessTokenRequestApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~AccessTokenRequestApi() {}
void init();
const std::string base = "";
private:
void setupRoutes();
void access_token_request_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void access_token_request_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
/// Access Token Request
/// </summary>
/// <remarks>
///
/// </remarks>
virtual void access_token_request(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
};
}
}
}
#endif /* AccessTokenRequestApi_H_ */
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "AccessTokenRequestApiImpl.h"
namespace oai {
namespace nrf {
namespace api {
using namespace oai::nrf::model;
using namespace oai::nrf::app;
AccessTokenRequestApiImpl::AccessTokenRequestApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, nrf_app *nrf_app_inst,
std::string address)
:
AccessTokenRequestApi(rtr),
m_nrf_app(nrf_app_inst),
m_address(address) {
}
void AccessTokenRequestApiImpl::access_token_request(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
}
}
}
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* AccessTokenRequestApiImpl.h
*
*
*/
#ifndef ACCESS_TOKEN_REQUEST_API_IMPL_H_
#define ACCESS_TOKEN_REQUEST_API_IMPL_H_
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <AccessTokenRequestApi.h>
#include <pistache/optional.h>
#include "AccessTokenErr.h"
#include "AccessTokenRsp.h"
#include "NFType.h"
#include "PlmnId.h"
#include "ProblemDetails.h"
#include "nrf_app.hpp"
#include <string>
namespace oai {
namespace nrf {
namespace api {
using namespace oai::nrf::model;
using namespace oai::nrf::app;
class AccessTokenRequestApiImpl : public oai::nrf::api::AccessTokenRequestApi {
public:
AccessTokenRequestApiImpl(std::shared_ptr<Pistache::Rest::Router>,
nrf_app *nrf_app_inst, std::string address);
~AccessTokenRequestApiImpl() {
}
void access_token_request(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response);
private:
nrf_app *m_nrf_app;
std::string m_address;
};
}
}
}
#endif
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "AccessTokenClaims.h"
namespace oai {
namespace nrf {
namespace model {
AccessTokenClaims::AccessTokenClaims()
{
m_Iss = "";
m_Sub = "";
m_Scope = "";
m_Exp = 0;
m_ConsumerPlmnIdIsSet = false;
m_ProducerPlmnIdIsSet = false;
}
AccessTokenClaims::~AccessTokenClaims()
{
}
void AccessTokenClaims::validate()
{
// TODO: implement validation
}
void to_json(nlohmann::json& j, const AccessTokenClaims& o)
{
j = nlohmann::json();
j["iss"] = o.m_Iss;
j["sub"] = o.m_Sub;
j["aud"] = o.m_Aud;
j["scope"] = o.m_Scope;
j["exp"] = o.m_Exp;
if(o.consumerPlmnIdIsSet())
j["consumerPlmnId"] = o.m_ConsumerPlmnId;
if(o.producerPlmnIdIsSet())
j["producerPlmnId"] = o.m_ProducerPlmnId;
}
void from_json(const nlohmann::json& j, AccessTokenClaims& o)
{
j.at("iss").get_to(o.m_Iss);
j.at("sub").get_to(o.m_Sub);
j.at("aud").get_to(o.m_Aud);
j.at("scope").get_to(o.m_Scope);
j.at("exp").get_to(o.m_Exp);
if(j.find("consumerPlmnId") != j.end())
{
j.at("consumerPlmnId").get_to(o.m_ConsumerPlmnId);
o.m_ConsumerPlmnIdIsSet = true;
}
if(j.find("producerPlmnId") != j.end())
{
j.at("producerPlmnId").get_to(o.m_ProducerPlmnId);
o.m_ProducerPlmnIdIsSet = true;
}
}
std::string AccessTokenClaims::getIss() const
{
return m_Iss;
}
void AccessTokenClaims::setIss(std::string const& value)
{
m_Iss = value;
}
std::string AccessTokenClaims::getSub() const
{
return m_Sub;
}
void AccessTokenClaims::setSub(std::string const& value)
{
m_Sub = value;
}
audience_t AccessTokenClaims::getAud() const
{
return m_Aud;
}
void AccessTokenClaims::setAud(audience_t const& value)
{
m_Aud = value;
}
std::string AccessTokenClaims::getScope() const
{
return m_Scope;
}
void AccessTokenClaims::setScope(std::string const& value)
{
m_Scope = value;
}
int32_t AccessTokenClaims::getExp() const
{
return m_Exp;
}
void AccessTokenClaims::setExp(int32_t const value)
{
m_Exp = value;
}
PlmnId AccessTokenClaims::getConsumerPlmnId() const
{
return m_ConsumerPlmnId;
}
void AccessTokenClaims::setConsumerPlmnId(PlmnId const& value)
{
m_ConsumerPlmnId = value;
m_ConsumerPlmnIdIsSet = true;
}
bool AccessTokenClaims::consumerPlmnIdIsSet() const
{
return m_ConsumerPlmnIdIsSet;
}
void AccessTokenClaims::unsetConsumerPlmnId()
{
m_ConsumerPlmnIdIsSet = false;
}
PlmnId AccessTokenClaims::getProducerPlmnId() const
{
return m_ProducerPlmnId;
}
void AccessTokenClaims::setProducerPlmnId(PlmnId const& value)
{
m_ProducerPlmnId = value;
m_ProducerPlmnIdIsSet = true;
}
bool AccessTokenClaims::producerPlmnIdIsSet() const
{
return m_ProducerPlmnIdIsSet;
}
void AccessTokenClaims::unsetProducerPlmnId()
{
m_ProducerPlmnIdIsSet = false;
}
}
}
}
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* AccessTokenClaims.h
*
*
*/
#ifndef AccessTokenClaims_H_
#define AccessTokenClaims_H_
#include <string>
//#include "AnyOfNFTypearray.h"
#include "PlmnId.h"
#include <nlohmann/json.hpp>
namespace oai {
namespace nrf {
namespace model {
/// <summary>
///
/// </summary>
typedef struct audience_s {
uint8_t type;
union {
uint8_t nf_type;
std::vector<std::string> nf_instances;
};
audience_s()
:
type(0) {
nf_type = 0;
}
audience_s(uint8_t t)
:
type(t) {
nf_type = 0;
}
;
audience_s(const audience_s &a)
:
audience_s() {
type = a.type;
switch (a.type) {
case 0:
nf_type = a.nf_type;
break;
case 1:
nf_instances = a.nf_instances;
break;
default:
break;
}
}
audience_s& operator=(const audience_s &a) {
type = a.type;
switch (a.type) {
case 0: {
nf_type = a.nf_type;
}
break;
case 1: {
nf_instances = a.nf_instances;
}
break;
default: {
// TODO:
}
}
// TODO:
}
virtual ~audience_s() {
}
;
friend void to_json(nlohmann::json &j, const audience_s &a) {
switch (a.type) {
case 0: {
j["nf_type"] = a.nf_type;
}
break;
case 1: {
j["nf_instances"] = nlohmann::json::array();
for (auto i : a.nf_instances) {
j["nf_instances"].push_back(i);
}
}
break;
default: {
}
}
}
friend void from_json(const nlohmann::json &j, audience_s &a) {
if (j.find("nf_type") != j.end()) {
j.at("nf_type").get_to(a.nf_type);
a.type = 0;
}
if (j.find("nf_instances") != j.end()) {
j.at("nf_instances").get_to(a.nf_instances);
a.type = 1;
}
}
} audience_t;
class AccessTokenClaims {
public:
AccessTokenClaims();
virtual ~AccessTokenClaims();
void validate();
/////////////////////////////////////////////
/// AccessTokenClaims members
/// <summary>
///
/// </summary>
std::string getIss() const;
void setIss(std::string const &value);
/// <summary>
///
/// </summary>
std::string getSub() const;
void setSub(std::string const &value);
/// <summary>
///
/// </summary>
audience_t getAud() const;
void setAud(audience_t const &value);
/// <summary>
///
/// </summary>
std::string getScope() const;
void setScope(std::string const &value);
/// <summary>
///
/// </summary>
int32_t getExp() const;
void setExp(int32_t const value);
/// <summary>
///
/// </summary>
PlmnId getConsumerPlmnId() const;
void setConsumerPlmnId(PlmnId const &value);
bool consumerPlmnIdIsSet() const;
void unsetConsumerPlmnId();
/// <summary>
///
/// </summary>
PlmnId getProducerPlmnId() const;
void setProducerPlmnId(PlmnId const &value);
bool producerPlmnIdIsSet() const;
void unsetProducerPlmnId();
friend void to_json(nlohmann::json &j, const AccessTokenClaims &o);
friend void from_json(const nlohmann::json &j, AccessTokenClaims &o);
protected:
std::string m_Iss;
std::string m_Sub;
audience_t m_Aud;
std::string m_Scope;
int32_t m_Exp;
PlmnId m_ConsumerPlmnId;
bool m_ConsumerPlmnIdIsSet;
PlmnId m_ProducerPlmnId;
bool m_ProducerPlmnIdIsSet;
};
}
}
}
#endif /* AccessTokenClaims_H_ */
/**
* NRF OAuth2
* NRF OAuth2 Authorization. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.0.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).