Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UDR
Commits
c0548a66
Commit
c0548a66
authored
May 30, 2022
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API for provisioning UE info
parent
749f63c1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
136 additions
and
16 deletions
+136
-16
src/udr_app/cassandra_db.cpp
src/udr_app/cassandra_db.cpp
+12
-4
src/udr_app/cassandra_db.hpp
src/udr_app/cassandra_db.hpp
+7
-1
src/udr_app/database_wrapper.hpp
src/udr_app/database_wrapper.hpp
+4
-1
src/udr_app/database_wrapper_abstraction.hpp
src/udr_app/database_wrapper_abstraction.hpp
+7
-1
src/udr_app/mysql_db.cpp
src/udr_app/mysql_db.cpp
+86
-1
src/udr_app/mysql_db.hpp
src/udr_app/mysql_db.hpp
+7
-1
src/udr_app/udr_app.cpp
src/udr_app/udr_app.cpp
+12
-6
src/udr_app/udr_app.hpp
src/udr_app/udr_app.hpp
+1
-1
No files found.
src/udr_app/cassandra_db.cpp
View file @
c0548a66
...
...
@@ -31,38 +31,46 @@ using namespace oai::udr::config;
extern
udr_config
udr_cfg
;
//------------------------------------------------------------------------------
cassandra_db
::
cassandra_db
()
:
database_wrapper
<
cassandra_db
>
()
{
// initialize();
}
cassandra_db
::
cassandra_db
()
:
database_wrapper
<
cassandra_db
>
()
{}
//------------------------------------------------------------------------------
cassandra_db
::~
cassandra_db
()
{}
//------------------------------------------------------------------------------
bool
cassandra_db
::
initialize
()
{
Logger
::
udr_app
().
debug
(
"Initialize CassandraDB"
);
Logger
::
udr_app
().
debug
(
"CassandraDB is not supported!"
);
return
false
;
}
//------------------------------------------------------------------------------
bool
cassandra_db
::
close_connection
()
{
return
true
;
}
//------------------------------------------------------------------------------
bool
cassandra_db
::
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
)
{
const
std
::
string
&
id
,
const
oai
::
udr
::
model
::
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
json_data
)
{
return
true
;
}
//------------------------------------------------------------------------------
bool
cassandra_db
::
query_authentication_subscription
(
const
std
::
string
&
id
,
nlohmann
::
json
&
json_data
)
{
Logger
::
udr_app
().
debug
(
"CassandraDB is not supported!"
);
return
true
;
}
//------------------------------------------------------------------------------
bool
cassandra_db
::
update_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
)
{
return
true
;
}
//------------------------------------------------------------------------------
bool
cassandra_db
::
delete_authentication_subscription
(
const
std
::
string
&
id
)
{
return
true
;
}
...
...
src/udr_app/cassandra_db.hpp
View file @
c0548a66
...
...
@@ -32,15 +32,21 @@ class cassandra_db : public database_wrapper<cassandra_db> {
virtual
~
cassandra_db
();
bool
initialize
();
bool
close_connection
();
bool
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
);
const
std
::
string
&
id
,
const
oai
::
udr
::
model
::
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
json_data
);
bool
query_authentication_subscription
(
const
std
::
string
&
id
,
nlohmann
::
json
&
json_data
);
bool
update_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
);
bool
delete_authentication_subscription
(
const
std
::
string
&
id
);
bool
query_am_data
(
...
...
src/udr_app/database_wrapper.hpp
View file @
c0548a66
...
...
@@ -57,7 +57,10 @@ class database_wrapper : public database_wrapper_abstraction {
}
bool
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
)
override
{
const
std
::
string
&
id
,
const
oai
::
udr
::
model
::
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
json_data
)
override
{
return
true
;
}
...
...
src/udr_app/database_wrapper_abstraction.hpp
View file @
c0548a66
...
...
@@ -30,6 +30,7 @@
#include "PatchItem.h"
#include "SdmSubscription.h"
#include "SmfRegistration.h"
#include "AuthenticationSubscription.h"
#include <nlohmann/json.hpp>
...
...
@@ -58,11 +59,16 @@ class database_wrapper_abstraction {
/*
* Insert a new item to the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
* @param [const oai::udr::model::AuthenticationSubscription&]
* authentication_subscription: Authentication data
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
virtual
bool
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
)
=
0
;
const
std
::
string
&
id
,
const
oai
::
udr
::
model
::
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
json_data
)
=
0
;
/*
* Query an item from the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
...
...
src/udr_app/mysql_db.cpp
View file @
c0548a66
...
...
@@ -68,7 +68,92 @@ bool mysql_db::close_connection() {
//------------------------------------------------------------------------------
bool
mysql_db
::
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
)
{
const
std
::
string
&
id
,
const
oai
::
udr
::
model
::
AuthenticationSubscription
&
auth_subscription
,
nlohmann
::
json
&
json_data
)
{
MYSQL_RES
*
res
=
nullptr
;
MYSQL_ROW
row
=
{};
nlohmann
::
json
json_tmp
=
{};
std
::
string
query
=
"SELECT * FROM AuthenticationSubscription WHERE ueid='"
+
id
+
"'"
;
Logger
::
udr_mysql
().
info
(
"MySQL Query: %s"
,
query
.
c_str
());
if
(
mysql_real_query
(
&
mysql_connector
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
())
!=
0
)
{
Logger
::
udr_mysql
().
error
(
"Failed when executing mysql_real_query with SQL Query: %s"
,
query
.
c_str
());
return
false
;
}
res
=
mysql_store_result
(
&
mysql_connector
);
if
(
res
==
nullptr
)
{
Logger
::
udr_mysql
().
error
(
"mysql_store_result failure! SQL Query: %s"
,
query
.
c_str
());
return
false
;
}
row
=
mysql_fetch_row
(
res
);
if
(
row
!=
nullptr
)
{
Logger
::
udr_mysql
().
error
(
"AuthenticationSubscription existed!"
);
// Existed
return
false
;
}
mysql_free_result
(
res
);
query
=
"INSERT INTO AuthenticationSubscription SET ueid='"
+
id
+
"'"
+
",authenticationMethod='"
+
auth_subscription
.
getAuthenticationMethod
()
+
"'"
+
(
auth_subscription
.
encPermanentKeyIsSet
()
?
",encPermanentKey='"
+
auth_subscription
.
getEncPermanentKey
()
+
"'"
:
""
)
+
(
auth_subscription
.
protectionParameterIdIsSet
()
?
",protectionParameterId='"
+
auth_subscription
.
getProtectionParameterId
()
+
"'"
:
""
)
+
(
auth_subscription
.
authenticationManagementFieldIsSet
()
?
",authenticationManagementField='"
+
auth_subscription
.
getAuthenticationManagementField
()
+
"'"
:
""
)
+
(
auth_subscription
.
algorithmIdIsSet
()
?
",algorithmId='"
+
auth_subscription
.
getAlgorithmId
()
+
"'"
:
""
)
+
(
auth_subscription
.
encOpcKeyIsSet
()
?
",encOpcKey='"
+
auth_subscription
.
getEncOpcKey
()
+
"'"
:
""
)
+
(
auth_subscription
.
encTopcKeyIsSet
()
?
",encTopcKey='"
+
auth_subscription
.
getEncTopcKey
()
+
"'"
:
""
)
+
// (auth_subscription.vectorGenerationInHssIsSet() ?
// ",vectorGenerationInHss='" +
// auth_subscription.isVectorGenerationInHss() + "'" : "") +
(
auth_subscription
.
n5gcAuthMethodIsSet
()
?
",n5gcAuthMethod='"
+
auth_subscription
.
getN5gcAuthMethod
()
+
"'"
:
""
)
+
// auth_subscription.rgAuthenticationIndIsSet() ? ",rgAuthenticationInd='"
// + auth_subscription.() + "'" : "") +
(
auth_subscription
.
supiIsSet
()
?
",supi='"
+
auth_subscription
.
getSupi
()
+
"'"
:
""
);
if
(
auth_subscription
.
sequenceNumberIsSet
())
{
to_json
(
json_tmp
,
auth_subscription
.
getSequenceNumber
());
query
+=
",sequenceNumber='"
+
json_tmp
.
dump
()
+
"'"
;
}
if
(
mysql_real_query
(
&
mysql_connector
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_mysql
().
error
(
"mysql_real_query failure! SQL Query %s"
,
query
.
c_str
());
return
false
;
}
to_json
(
json_data
,
auth_subscription
);
Logger
::
udr_mysql
().
debug
(
"AuthenticationSubscription POST: %s"
,
json_data
.
dump
().
c_str
());
return
true
;
}
...
...
src/udr_app/mysql_db.hpp
View file @
c0548a66
...
...
@@ -34,17 +34,23 @@ class mysql_db : public database_wrapper<mysql_db> {
virtual
~
mysql_db
();
bool
initialize
();
bool
close_connection
();
bool
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
nlohmann
::
json
&
json_data
);
const
std
::
string
&
id
,
const
oai
::
udr
::
model
::
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
json_data
);
bool
query_authentication_subscription
(
const
std
::
string
&
id
,
nlohmann
::
json
&
json_data
);
bool
update_authentication_subscription
(
const
std
::
string
&
id
,
const
std
::
vector
<
oai
::
udr
::
model
::
PatchItem
>&
patchItem
,
nlohmann
::
json
&
json_data
);
bool
delete_authentication_subscription
(
const
std
::
string
&
id
);
bool
query_am_data
(
...
...
src/udr_app/udr_app.cpp
View file @
c0548a66
...
...
@@ -28,14 +28,10 @@
*/
#include "udr_app.hpp"
#include <mysql/mysql.h>
//#include <unistd.h>
#include "3gpp_29.500.h"
#include "AccessAndMobilitySubscriptionData.h"
#include "AuthenticationSubscription.h"
//#include "ProblemDetails.h"
//#include "SequenceNumber.h"
#include "logger.hpp"
#include "udr_config.hpp"
#include "udr_nrf.hpp"
...
...
@@ -190,8 +186,18 @@ void udr_app::handle_query_authentication_status(
void
udr_app
::
handle_create_authentication_data
(
const
std
::
string
&
ue_id
,
const
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
response_data
,
long
&
http_code
)
{
// TODO
nlohmann
::
json
&
response_data
,
long
&
code
)
{
Logger
::
udr_app
().
info
(
"Crate an authentication subscription data of a UE"
);
if
(
db_connector
->
insert_authentication_subscription
(
ue_id
,
authentication_subscription
,
response_data
))
{
code
=
HTTP_STATUS_CODE_201_CREATED
;
Logger
::
udr_app
().
info
(
"AuthenticationSubscription: %s"
,
response_data
.
dump
().
c_str
());
}
else
{
code
=
HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR
;
// TODO
}
return
;
}
//------------------------------------------------------------------------------
...
...
src/udr_app/udr_app.hpp
View file @
c0548a66
...
...
@@ -148,7 +148,7 @@ class udr_app {
void
handle_create_authentication_data
(
const
std
::
string
&
ue_id
,
const
AuthenticationSubscription
&
authentication_subscription
,
nlohmann
::
json
&
response_data
,
long
&
http_
code
);
nlohmann
::
json
&
response_data
,
long
&
code
);
/*
* Handle a request to modify AuthenticationSubscription
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment