diff --git a/.github/workflows/psv_pipelines.yml b/.github/workflows/psv_pipelines.yml
index 5b9551c7c..be86659d2 100644
--- a/.github/workflows/psv_pipelines.yml
+++ b/.github/workflows/psv_pipelines.yml
@@ -108,6 +108,21 @@ jobs:
run: ./scripts/linux/psv/test_psv.sh
shell: bash
+ psv-linux-22-04-gcc11-build-no-exceptions:
+ name: PSV.Linux.22.04.gcc11.OLP_SDK_NO_EXCEPTION=ON
+ runs-on: ubuntu-22.04
+ env:
+ BUILD_TYPE: RelWithDebInfo
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v4
+ - name: Install Ubuntu dependencies
+ run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev --no-install-recommends
+ shell: bash
+ - name: Compile project with cmake and ccache
+ run: gcc --version && ./scripts/linux/psv/build_psv_no_exceptions.sh
+ shell: bash
+
psv-linux-latest-gcc14-build-no-cache:
name: PSV.Linux.latest.gcc14.OLP_SDK_ENABLE_DEFAULT_CACHE=OFF
runs-on: ubuntu-latest
@@ -181,6 +196,25 @@ jobs:
run: scripts/linux/psv/test_psv.sh
shell: bash
+ psv-linux-22-04-clang-hidden-build:
+ name: PSV.Linux.22.04.clang.hidden
+ runs-on: ubuntu-22.04
+ env:
+ BUILD_TYPE: RelWithDebInfo
+ CC: clang-11
+ CXX: clang++-11
+ CXXFLAGS: -Wno-deprecated-copy
+ EXTRA_CMAKE_OPTIONS: -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DOLP_SDK_ENABLE_TESTING=OFF
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v4
+ - name: Install Ubuntu dependencies
+ run: sudo apt-get update -y && sudo apt-get install clang-11 ccache libcurl4-openssl-dev -y --no-install-recommends --fix-missing
+ shell: bash
+ - name: Compile project on Clang
+ run: scripts/linux/psv/build_psv.sh
+ shell: bash
+
psv-android-22-04-build:
name: PSV.Linux.Android.22.04
runs-on: ubuntu-22.04
diff --git a/README.md b/README.md
index 8910973b3..719ab6ec1 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,6 @@ The table below lists the dependencies of the Data SDK.
| Boost (headers only) | 1.82.0 |
| LevelDB | 1.21 |
| Snappy | 1.1.7 |
-| RapidJSON | latest |
| Zlib | 1.3.1 |
### Linux dependencies
diff --git a/docs/get-started.md b/docs/get-started.md
index c26f716c7..a05e9f746 100644
--- a/docs/get-started.md
+++ b/docs/get-started.md
@@ -71,7 +71,7 @@ cmake --build . --target install
CMake is the main build system. The minimal required version of CMake is 3.9.
-CMake downloads LevelDB, Snappy, RapidJSON, and Boost. To disable downloading, set `OLP_SDK_BUILD_EXTERNAL_DEPS` to `OFF`. For details on CMake flags, see the [related](#cmake-flags) section.
+CMake downloads LevelDB, Snappy, and Boost. To disable downloading, set `OLP_SDK_BUILD_EXTERNAL_DEPS` to `OFF`. For details on CMake flags, see the [related](#cmake-flags) section.
**To build the Data SDK:**
diff --git a/docs/work-with-data-apis.md b/docs/work-with-data-apis.md
index 9ce4de074..4d727a4b9 100644
--- a/docs/work-with-data-apis.md
+++ b/docs/work-with-data-apis.md
@@ -59,7 +59,7 @@ The example below demonstrates how to use the `olp::client::OlpClient` class fro
}
```
-5. If the check passed and the status of the received `olp::client::HttpResponse` is `olp::http::HttpStatusCode::OK` (that is 200 OK), extract the encoded JSON from the response and parse it using RapidJSON or any other JSON parsing library.
+5. If the check passed and the status of the received `olp::client::HttpResponse` is `olp::http::HttpStatusCode::OK` (that is 200 OK), extract the encoded JSON from the response and parse it using JSON parsing library.
```cpp
std::string response_json;
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index dbac398a4..2a0684c91 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2020 HERE Europe B.V.
+# Copyright (C) 2019-2026 HERE Europe B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -81,6 +81,25 @@ else()
olp-cpp-sdk-authentication
olp-cpp-sdk-dataservice-read)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_READ_EXAMPLE_TARGET}
+ PRIVATE EXAMPLES_LIBRARY)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_WRITE_EXAMPLE_TARGET}
+ PRIVATE EXAMPLES_LIBRARY)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_CACHE_EXAMPLE_TARGET}
+ PRIVATE EXAMPLES_LIBRARY)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_READ_STREAM_LAYER_EXAMPLE_TARGET}
+ PRIVATE EXAMPLES_LIBRARY)
+ if(BUILD_SHARED_LIBS)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_READ_EXAMPLE_TARGET}
+ PUBLIC EXAMPLES_SHARED_LIBRARY)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_WRITE_EXAMPLE_TARGET}
+ PUBLIC EXAMPLES_SHARED_LIBRARY)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_CACHE_EXAMPLE_TARGET}
+ PUBLIC EXAMPLES_SHARED_LIBRARY)
+ target_compile_definitions(${OLP_SDK_DATASERVICE_READ_STREAM_LAYER_EXAMPLE_TARGET}
+ PUBLIC EXAMPLES_SHARED_LIBRARY)
+ endif()
+
add_executable(${OLP_SDK_DATASERVICE_EXAMPLE_TARGET}
./main.cpp
./Examples.h
diff --git a/examples/Examples.h b/examples/Examples.h
index b0492468f..dd16f0acd 100644
--- a/examples/Examples.h
+++ b/examples/Examples.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2020 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,21 @@
#pragma once
+#include
+
+#ifdef EXAMPLES_SHARED_LIBRARY
+#ifdef EXAMPLES_LIBRARY
+#define EXAMPLES_API OLP_CPP_SDK_DECL_EXPORT
+#else
+#define EXAMPLES_API OLP_CPP_SDK_DECL_IMPORT
+#endif // EXAMPLES_LIBRARY
+#else
+#define EXAMPLES_API
+#endif // EXAMPLES_SHARED_LIBRARY
+
#include
-struct AccessKey
-{
+struct AccessKey {
std::string id; // Your here.access.key.id
std::string secret; // Your here.access.key.secret
};
diff --git a/examples/ProtectedCacheExample.h b/examples/ProtectedCacheExample.h
index 7656fe724..961798f42 100644
--- a/examples/ProtectedCacheExample.h
+++ b/examples/ProtectedCacheExample.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 HERE Europe B.V.
+ * Copyright (C) 2020-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,14 +21,19 @@
#include "Examples.h"
+#include
+
/**
- * @brief Dataservice cache example.
+ * @brief Dataservice cache example.
*
- * Gets the partition data using the HERE Open Location Platform with mutable cache.
- * Makes the mutable cache path
- * protected. Reads the same data from the protected cache.
+ * Gets the partition data using the HERE Open Location Platform with mutable
+ * cache. Makes the mutable cache path protected. Reads the same data from the
+ * protected cache.
* @param access_key Your access key ID and access key secret.
- * @param The HERE Resource Name (HRN) of the catalog from which you want to read data.
+ * @param The HERE Resource Name (HRN) of the catalog from which you want to
+ * read data.
* @return 0 if data was published successfully.
*/
-int RunExampleProtectedCache(const AccessKey& access_key, const std::string& catalog);
+EXAMPLES_API
+int RunExampleProtectedCache(const AccessKey& access_key,
+ const std::string& catalog);
diff --git a/examples/ReadExample.h b/examples/ReadExample.h
index c4eb8c565..008de9f3e 100644
--- a/examples/ReadExample.h
+++ b/examples/ReadExample.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2020 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
#include "Examples.h"
#include
+#include
/**
* @brief Dataservice read example. Authenticate client using access key id and
@@ -33,6 +34,7 @@
* @param catalog_version The desired version of the catalog.
* @return result of publish data(0 - if succeed)
*/
+EXAMPLES_API
int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
const olp::porting::optional& catalog_version =
olp::porting::none);
diff --git a/examples/StreamLayerReadExample.h b/examples/StreamLayerReadExample.h
index 06519bb5a..1fb8f7274 100644
--- a/examples/StreamLayerReadExample.h
+++ b/examples/StreamLayerReadExample.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2020 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
#include "Examples.h"
#include
+#include
/**
* @brief Dataservice read from stream layer example. Authenticate client using
@@ -34,6 +35,7 @@
* @param subscription_mode The type of client subscription.
* @return 0 on success, -1 otherwise.
*/
+EXAMPLES_API
int RunStreamLayerExampleRead(
const AccessKey& access_key, const std::string& catalog,
const std::string& layer_id,
diff --git a/examples/WriteExample.h b/examples/WriteExample.h
index 2dbfd1c1a..15546fa26 100644
--- a/examples/WriteExample.h
+++ b/examples/WriteExample.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2020 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,13 +21,18 @@
#include "Examples.h"
+#include
+
/**
* @brief Dataservice write example. Authenticate client using access key id and
* secret. Publish data to some layer in HRN catalog.
* @param access_key Your access key ID and access key secret.
- * @param The HERE Resource Name (HRN) of the catalog to which you want to publish data.
- * @param layer_id The layer ID of the catalog to which you want to publish data.
+ * @param The HERE Resource Name (HRN) of the catalog to which you want to
+ * publish data.
+ * @param layer_id The layer ID of the catalog to which you want to publish
+ * data.
* @return result of publish data(0 - if succeed)
*/
+EXAMPLES_API
int RunExampleWrite(const AccessKey& access_key, const std::string& catalog,
const std::string& layer_id);
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index b81b81125..3a0c8bcd5 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -48,10 +48,6 @@ set(OLP_SDK_CPP_SNAPPY_TAG "1.1.7")
set(OLP_SDK_CPP_LEVELDB_URL "https://github.com/google/leveldb.git")
set(OLP_SDK_CPP_LEVELDB_TAG "1.21")
-set(OLP_SDK_CPP_RAPIDJSON_URL "https://github.com/Tencent/rapidjson.git")
-# Next commit after that breaks our build
-set(OLP_SDK_CPP_RAPIDJSON_TAG "d621dc9e9c77f81e5c8a35b8dcc16dcd63351321")
-
set(OLP_SDK_CPP_BOOST_URL "https://github.com/boostorg/boost.git")
set(OLP_SDK_CPP_BOOST_TAG "boost-1.82.0")
@@ -73,11 +69,6 @@ if(NOT TARGET GTest AND NOT GTest_FOUND)
add_subdirectory(googletest)
endif()
-find_package(RapidJSON 1.1.0 QUIET)
-if(NOT TARGET RapidJSON AND NOT RapidJSON_FOUND)
- add_subdirectory(rapidjson)
-endif()
-
if(OLP_SDK_ENABLE_DEFAULT_CACHE)
find_package(leveldb QUIET)
if(NOT TARGET leveldb AND NOT leveldb_FOUND)
diff --git a/external/boost/CMakeLists.txt b/external/boost/CMakeLists.txt
index 618d0fe09..43f9396e9 100644
--- a/external/boost/CMakeLists.txt
+++ b/external/boost/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2020 HERE Europe B.V.
+# Copyright (C) 2019-2026 HERE Europe B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ else()
set(B2_CMD ./b2)
endif()
+set(PATCH_BOOST_CMD "git apply -v ${CMAKE_CURRENT_SOURCE_DIR}/boost_182_json_noexceptions.diff")
+
configure_file(CMakeLists.txt.boost.in download/CMakeLists.txt @ONLY)
set(CMAKE_VERBOSE_MAKEFILE ON)
diff --git a/external/boost/CMakeLists.txt.boost.in b/external/boost/CMakeLists.txt.boost.in
index d526f9278..cbf5a4080 100644
--- a/external/boost/CMakeLists.txt.boost.in
+++ b/external/boost/CMakeLists.txt.boost.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2020 HERE Europe B.V.
+# Copyright (C) 2019-2026 HERE Europe B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ ExternalProject_Add(boost-download
GIT_REPOSITORY @OLP_SDK_CPP_BOOST_URL@
GIT_TAG @OLP_SDK_CPP_BOOST_TAG@
GIT_SUBMODULES libs/algorithm
+ libs/align
libs/any
libs/array
libs/assert
@@ -34,18 +35,20 @@ ExternalProject_Add(boost-download
libs/container_hash
libs/core
libs/date_time
- libs/detail
libs/describe
+ libs/detail
libs/format
libs/function_types
libs/headers
libs/integer
+ libs/intrusive
libs/io
libs/iterator
+ libs/json
libs/lexical_cast
libs/move
- libs/mpl
libs/mp11
+ libs/mpl
libs/numeric/conversion
libs/optional
libs/predef
@@ -55,6 +58,7 @@ ExternalProject_Add(boost-download
libs/serialization
libs/smart_ptr
libs/static_assert
+ libs/system
libs/throw_exception
libs/tokenizer
libs/tti
@@ -62,11 +66,13 @@ ExternalProject_Add(boost-download
libs/type_traits
libs/utility
libs/uuid
+ libs/variant2
libs/winapi
tools/build
tools/boost_install
GIT_SHALLOW 1
SOURCE_DIR "@CMAKE_CURRENT_BINARY_DIR@/external_boost"
+ PATCH_COMMAND @PATCH_BOOST_CMD@
BUILD_IN_SOURCE 1
UPDATE_COMMAND ""
CONFIGURE_COMMAND @BOOTSTRAP_CMD@
diff --git a/external/boost/boost_182_json_noexceptions.diff b/external/boost/boost_182_json_noexceptions.diff
new file mode 100644
index 000000000..a0defe5eb
--- /dev/null
+++ b/external/boost/boost_182_json_noexceptions.diff
@@ -0,0 +1,56 @@
+diff --git a/libs/json/include/boost/json/detail/value_to.hpp b/libs/json/include/boost/json/detail/value_to.hpp
+index 7cb779e..6df1c9d 100644
+--- a/libs/json/include/boost/json/detail/value_to.hpp
++++ b/libs/json/include/boost/json/detail/value_to.hpp
+@@ -652,10 +652,13 @@ value_to_impl(
+ value const& jv,
+ user_conversion_tag)
+ {
++#ifndef BOOST_NO_EXCEPTIONS
+ try
+ {
++#endif // BOOST_NO_EXCEPTIONS
+ return {
+ boost::system::in_place_value, tag_invoke(value_to_tag(), jv)};
++#ifndef BOOST_NO_EXCEPTIONS
+ }
+ catch( std::bad_alloc const&)
+ {
+@@ -671,6 +674,7 @@ value_to_impl(
+ BOOST_JSON_FAIL(ec, error::exception);
+ return {boost::system::in_place_error, ec};
+ }
++#endif // BOOST_NO_EXCEPTIONS
+ }
+
+ // no suitable conversion implementation
+diff --git a/libs/json/include/boost/json/impl/value.ipp b/libs/json/include/boost/json/impl/value.ipp
+index 7460c02..7513b38 100644
+--- a/libs/json/include/boost/json/impl/value.ipp
++++ b/libs/json/include/boost/json/impl/value.ipp
+@@ -381,7 +381,9 @@ operator>>(
+ char read_buf[BOOST_JSON_STACK_BUFFER_SIZE / 2];
+ std::streambuf& buf = *is.rdbuf();
+ std::ios::iostate err = std::ios::goodbit;
++#ifndef BOOST_NO_EXCEPTIONS
+ try
++#endif
+ {
+ while( true )
+ {
+@@ -437,6 +439,7 @@ operator>>(
+ break;
+ }
+ }
++#ifndef BOOST_NO_EXCEPTIONS
+ catch(...)
+ {
+ try
+@@ -450,6 +453,7 @@ operator>>(
+ if( is.exceptions() & std::ios::badbit )
+ throw;
+ }
++#endif
+
+ is.setstate(err | std::ios::failbit);
+ return is;
diff --git a/external/rapidjson/CMakeLists.txt b/external/rapidjson/CMakeLists.txt
deleted file mode 100644
index b3f504c04..000000000
--- a/external/rapidjson/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2019-2021 HERE Europe B.V.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# License-Filename: LICENSE
-
-# RapidJSON
-# Download and unpack rapidjson at configure time
-
-configure_file(CMakeLists.txt.rapidjson.in download/CMakeLists.txt)
-
-execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . ${COMMON_GENERATE_FLAGS}
- RESULT_VARIABLE result
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download)
-if(result)
- message(FATAL_ERROR "CMake step for rapidjson failed: ${result}")
-endif()
-
-execute_process(COMMAND ${CMAKE_COMMAND} --build .
- RESULT_VARIABLE result
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download)
-if(result)
- message(FATAL_ERROR "Build step for rapidjson failed: ${result}")
-endif()
diff --git a/external/rapidjson/CMakeLists.txt.rapidjson.in b/external/rapidjson/CMakeLists.txt.rapidjson.in
deleted file mode 100644
index e8a3fc727..000000000
--- a/external/rapidjson/CMakeLists.txt.rapidjson.in
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2019 HERE Europe B.V.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# License-Filename: LICENSE
-
-cmake_minimum_required(VERSION 3.9)
-
-project(rapidjson-download NONE)
-
-include(ExternalProject)
-ExternalProject_Add(rapidjson
- GIT_REPOSITORY @OLP_SDK_CPP_RAPIDJSON_URL@
- GIT_TAG @OLP_SDK_CPP_RAPIDJSON_TAG@
- GIT_SHALLOW 0
- INSTALL_DIR "@EXTERNAL_BINARY_INSTALL_DIR@"
- CMAKE_ARGS @COMMON_PLATFORM_FLAGS@
- -DCMAKE_INSTALL_PREFIX=
- -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@
- -DRAPIDJSON_BUILD_DOC=OFF
- -DRAPIDJSON_BUILD_EXAMPLES=OFF
- -DRAPIDJSON_BUILD_TESTS=OFF
- -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF
- -DRAPIDJSON_ENABLE_INSTRUMENTATION_OPT=OFF
- -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
- TEST_COMMAND ""
-)
diff --git a/olp-cpp-sdk-authentication/CMakeLists.txt b/olp-cpp-sdk-authentication/CMakeLists.txt
index b8d9cc787..f36f48759 100644
--- a/olp-cpp-sdk-authentication/CMakeLists.txt
+++ b/olp-cpp-sdk-authentication/CMakeLists.txt
@@ -18,6 +18,8 @@
project(olp-cpp-sdk-authentication VERSION 1.24.0)
set(DESCRIPTION "C++ API library for accessing HERE Account authentication service")
+find_package(Boost REQUIRED)
+
file(GLOB_RECURSE AUTHENTICATION_INC "include/*.h*")
file(GLOB_RECURSE AUTHENTICATION_SRC "src/*.*")
@@ -25,9 +27,13 @@ add_library(${PROJECT_NAME}
${AUTHENTICATION_SRC}
${AUTHENTICATION_INC})
-target_include_directories(${PROJECT_NAME} PUBLIC
- $
- $)
+target_include_directories(${PROJECT_NAME}
+ PUBLIC
+ $
+ $
+ PRIVATE
+ $
+)
# Used also in the package config file
set(PROJECT_LIBS olp-cpp-sdk-core)
@@ -37,8 +43,9 @@ target_link_libraries(${PROJECT_NAME}
${PROJECT_LIBS}
)
-# On MINGW boost uses bcrypt library
-if (MINGW)
+# On MINGW and MSVC boost uses bcrypt library
+# https://github.com/boostorg/uuid/issues/122
+if (MINGW OR MSVC)
target_link_libraries(${PROJECT_NAME} PRIVATE bcrypt )
endif()
@@ -49,6 +56,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC AUTHENTICATION_SHARED_LIBRARY)
endif()
+target_compile_definitions(${PROJECT_NAME}
+ PRIVATE
+ BOOST_ALL_NO_LIB
+ BOOST_JSON_NO_LIB)
+
# install component
install (FILES ${AUTHENTICATION_INC} DESTINATION ${INCLUDE_DIRECTORY}/olp/authentication)
diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp b/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
index 567c1cde8..de349240c 100644
--- a/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2025 HERE Europe B.V.
+ * Copyright (C) 2020-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,9 @@
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
#include
#include
@@ -116,17 +115,13 @@ void RetryDelay(const client::RetrySettings& retry_settings, size_t retry) {
client::OlpClient::RequestBodyType GenerateAppleSignInBody(
const AppleSignInProperties& sign_in_properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object json_object;
- writer.Key(kGrantType);
- writer.String(kAppleGrantType);
+ json_object[kGrantType] = kAppleGrantType;
- auto write_field = [&writer](const char* key, const std::string& value) {
+ auto write_field = [&json_object](const char* key, const std::string& value) {
if (!value.empty()) {
- writer.Key(key);
- writer.String(value.c_str());
+ json_object[key] = value;
}
};
@@ -137,9 +132,8 @@ client::OlpClient::RequestBodyType GenerateAppleSignInBody(
write_field(kCountryCode, sign_in_properties.GetCountryCode());
write_field(kLanguage, sign_in_properties.GetLanguage());
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(json_object);
+ return std::make_shared(content.begin(), content.end());
}
client::HttpResponse CallApi(const client::OlpClient& client,
@@ -219,20 +213,26 @@ olp::client::HttpResponse AuthenticationClientImpl::CallAuth(
SignInResult AuthenticationClientImpl::ParseAuthResponse(
int status, std::stringstream& auth_response) {
- auto document = std::make_shared();
- rapidjson::IStreamWrapper stream(auth_response);
- document->ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(auth_response, ec);
return std::make_shared(
- status, olp::http::HttpErrorToString(status), document);
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())));
}
SignInUserResult AuthenticationClientImpl::ParseUserAuthResponse(
int status, std::stringstream& auth_response) {
- auto document = std::make_shared();
- rapidjson::IStreamWrapper stream(auth_response);
- document->ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(auth_response, ec);
return std::make_shared(
- status, olp::http::HttpErrorToString(status), document);
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())));
}
template
@@ -397,23 +397,24 @@ client::CancellationToken AuthenticationClientImpl::SignInClient(
TimeResponse AuthenticationClientImpl::ParseTimeResponse(
std::stringstream& payload) {
- rapidjson::Document document;
- rapidjson::IStreamWrapper stream(payload);
- document.ParseStream(stream);
+ boost::json::error_code ec;
+ auto json_value = boost::json::parse(payload, ec);
- if (!document.IsObject()) {
+ if (ec.failed() || !json_value.is_object()) {
return client::ApiError(client::ErrorCode::InternalFailure,
"JSON document root is not an Object type");
}
- const auto timestamp_it = document.FindMember("timestamp");
- if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) {
+ auto& object = json_value.as_object();
+ const auto timestamp_it = object.find("timestamp");
+ if (timestamp_it == object.end() || (!timestamp_it->value().is_uint64() &&
+ !timestamp_it->value().is_int64())) {
return client::ApiError(
client::ErrorCode::InternalFailure,
"JSON document must contain timestamp integer field");
}
- return timestamp_it->value.GetUint();
+ return timestamp_it->value().to_number();
}
TimeResponse AuthenticationClientImpl::GetTimeFromServer(
@@ -622,10 +623,14 @@ client::CancellationToken AuthenticationClientImpl::SignUpHereUser(
return client::ApiError(status, response_text);
}
- auto document = std::make_shared();
- document->Parse(response_text.c_str());
+ boost::json::error_code ec;
+ auto document = boost::json::parse(response_text, ec);
return {std::make_shared(
- status, olp::http::HttpErrorToString(status), document)};
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())))};
};
return AddTask(settings_.task_scheduler, pending_requests_,
@@ -667,10 +672,14 @@ client::CancellationToken AuthenticationClientImpl::SignOut(
return client::ApiError(status, response_text);
}
- auto document = std::make_shared();
- document->Parse(response_text.c_str());
+ boost::json::error_code ec;
+ auto document = boost::json::parse(response_text, ec);
return {std::make_shared(
- status, olp::http::HttpErrorToString(status), document)};
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())))};
};
return AddTask(settings_.task_scheduler, pending_requests_,
@@ -700,24 +709,23 @@ client::CancellationToken AuthenticationClientImpl::IntrospectApp(
auto http_result = client.CallApi(kIntrospectAppEndpoint, "GET", {}, {}, {},
nullptr, {}, context);
- rapidjson::Document document;
- rapidjson::IStreamWrapper stream(http_result.GetRawResponse());
- document.ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(http_result.GetRawResponse(), ec);
if (http_result.GetStatus() != http::HttpStatusCode::OK) {
// HttpResult response can be error message or valid json with it.
std::string msg = http_result.GetResponseAsString();
- if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) {
- msg = document[Constants::MESSAGE].GetString();
+ if (!ec.failed() && document.as_object().contains(Constants::MESSAGE)) {
+ msg = document.as_object()[Constants::MESSAGE].as_string().c_str();
}
return client::ApiError({http_result.GetStatus(), msg});
}
- if (document.HasParseError()) {
+ if (ec.failed() || !document.is_object()) {
return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR),
"Failed to parse response"});
}
- return GetIntrospectAppResult(document);
+ return GetIntrospectAppResult(document.as_object());
};
return AddTask(settings_.task_scheduler, pending_requests_,
@@ -747,25 +755,27 @@ client::CancellationToken AuthenticationClientImpl::Authorize(
GenerateAuthorizeBody(request),
kApplicationJson, context);
- rapidjson::Document document;
- rapidjson::IStreamWrapper stream(http_result.GetRawResponse());
- document.ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(http_result.GetRawResponse(), ec);
if (http_result.GetStatus() != http::HttpStatusCode::OK) {
// HttpResult response can be error message or valid json with it.
std::string msg = http_result.GetResponseAsString();
- if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) {
- msg = document[Constants::MESSAGE].GetString();
+ if (!ec.failed() && document.as_object().contains(Constants::MESSAGE)) {
+ msg = document.as_object()[Constants::MESSAGE].as_string().c_str();
}
return client::ApiError({http_result.GetStatus(), msg});
- } else if (!document.HasParseError() &&
- document.HasMember(Constants::ERROR_CODE) &&
- document[Constants::ERROR_CODE].IsInt()) {
+ }
+
+ if (!ec.failed() && document.as_object().contains(Constants::ERROR_CODE) &&
+ document.as_object()[Constants::ERROR_CODE].is_int64()) {
std::string msg =
"Error code: " +
- std::to_string(document[Constants::ERROR_CODE].GetInt());
- if (document.HasMember(Constants::MESSAGE)) {
+ std::to_string(
+ document.as_object()[Constants::ERROR_CODE].as_int64());
+ if (document.as_object().contains(Constants::MESSAGE)) {
msg.append(" (");
- msg.append(document[Constants::MESSAGE].GetString());
+ msg.append(
+ document.as_object()[Constants::MESSAGE].as_string().c_str());
msg.append(")");
}
@@ -773,12 +783,12 @@ client::CancellationToken AuthenticationClientImpl::Authorize(
{static_cast(http::ErrorCode::UNKNOWN_ERROR), msg});
}
- if (document.HasParseError()) {
+ if (ec.failed() || !document.is_object()) {
return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR),
"Failed to parse response"});
}
- return GetAuthorizeResult(document);
+ return GetAuthorizeResult(document.as_object());
};
return AddTask(settings_.task_scheduler, pending_requests_, std::move(task),
@@ -819,237 +829,187 @@ client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateClientBody(
return std::make_shared(content.data(),
content.data() + content.size());
};
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
- writer.Key(kGrantType);
- writer.String(kClientGrantType);
+ boost::json::object object;
+
+ object[kGrantType] = kClientGrantType;
auto expires_in = static_cast(properties.expires_in.count());
if (expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(expires_in);
+ object[Constants::EXPIRES_IN] = expires_in;
}
if (properties.scope) {
- writer.Key(kScope);
- writer.String(properties.scope->c_str());
+ object[kScope] = *properties.scope;
}
if (properties.device_id) {
- writer.Key(kDeviceId);
- writer.String(properties.device_id->c_str());
+ object[kDeviceId] = *properties.device_id;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateUserBody(
const UserProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kUserGrantType);
+ object[kGrantType] = kUserGrantType;
if (!properties.email.empty()) {
- writer.Key(kEmail);
- writer.String(properties.email.c_str());
+ object[kEmail] = properties.email;
}
if (!properties.password.empty()) {
- writer.Key(kPassword);
- writer.String(properties.password.c_str());
+ object[kPassword] = properties.password;
}
if (properties.expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(properties.expires_in);
+ object[Constants::EXPIRES_IN] = properties.expires_in;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateFederatedBody(
const FederatedSignInType type, const FederatedProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
switch (type) {
case FederatedSignInType::FacebookSignIn:
- writer.String(kFacebookGrantType);
+ object[kGrantType] = kFacebookGrantType;
break;
case FederatedSignInType::ArcgisSignIn:
- writer.String(kArcgisGrantType);
+ object[kGrantType] = kArcgisGrantType;
break;
default:
return nullptr;
}
if (!properties.access_token.empty()) {
- writer.Key(Constants::ACCESS_TOKEN);
- writer.String(properties.access_token.c_str());
+ object[Constants::ACCESS_TOKEN] = properties.access_token;
}
if (!properties.country_code.empty()) {
- writer.Key(kCountryCode);
- writer.String(properties.country_code.c_str());
+ object[kCountryCode] = properties.country_code;
}
if (!properties.language.empty()) {
- writer.Key(kLanguage);
- writer.String(properties.language.c_str());
+ object[kLanguage] = properties.language;
}
if (!properties.email.empty()) {
- writer.Key(kEmail);
- writer.String(properties.email.c_str());
+ object[kEmail] = properties.email;
}
if (properties.expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(properties.expires_in);
+ object[Constants::EXPIRES_IN] = properties.expires_in;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateRefreshBody(
const RefreshProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kRefreshGrantType);
+ object[kGrantType] = kRefreshGrantType;
if (!properties.access_token.empty()) {
- writer.Key(Constants::ACCESS_TOKEN);
- writer.String(properties.access_token.c_str());
+ object[Constants::ACCESS_TOKEN] = properties.access_token;
}
if (!properties.refresh_token.empty()) {
- writer.Key(Constants::REFRESH_TOKEN);
- writer.String(properties.refresh_token.c_str());
+ object[Constants::REFRESH_TOKEN] = properties.refresh_token;
}
if (properties.expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(properties.expires_in);
+ object[Constants::EXPIRES_IN] = properties.expires_in;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateSignUpBody(
const SignUpProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
if (!properties.email.empty()) {
- writer.Key(kEmail);
- writer.String(properties.email.c_str());
+ object[kEmail] = properties.email;
}
if (!properties.password.empty()) {
- writer.Key(kPassword);
- writer.String(properties.password.c_str());
+ object[kPassword] = properties.password;
}
if (!properties.date_of_birth.empty()) {
- writer.Key(kDateOfBirth);
- writer.String(properties.date_of_birth.c_str());
+ object[kDateOfBirth] = properties.date_of_birth;
}
if (!properties.first_name.empty()) {
- writer.Key(kFirstName);
- writer.String(properties.first_name.c_str());
+ object[kFirstName] = properties.first_name;
}
if (!properties.last_name.empty()) {
- writer.Key(kLastName);
- writer.String(properties.last_name.c_str());
+ object[kLastName] = properties.last_name;
}
if (!properties.country_code.empty()) {
- writer.Key(kCountryCode);
- writer.String(properties.country_code.c_str());
+ object[kCountryCode] = properties.country_code;
}
if (!properties.language.empty()) {
- writer.Key(kLanguage);
- writer.String(properties.language.c_str());
+ object[kLanguage] = properties.language;
}
if (properties.marketing_enabled) {
- writer.Key(kMarketingEnabled);
- writer.Bool(true);
+ object[kMarketingEnabled] = true;
}
if (!properties.phone_number.empty()) {
- writer.Key(kPhoneNumber);
- writer.String(properties.phone_number.c_str());
+ object[kPhoneNumber] = properties.phone_number;
}
if (!properties.realm.empty()) {
- writer.Key(kRealm);
- writer.String(properties.realm.c_str());
+ object[kRealm] = properties.realm;
}
if (!properties.invite_token.empty()) {
- writer.Key(kInviteToken);
- writer.String(properties.invite_token.c_str());
+ object[kInviteToken] = properties.invite_token;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateAcceptTermBody(
const std::string& reacceptance_token) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kTermsReacceptanceToken);
- writer.String(reacceptance_token.c_str());
+ object[kTermsReacceptanceToken] = reacceptance_token;
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateAuthorizeBody(
const AuthorizeRequest& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
- writer.Key(kServiceId);
- writer.String(properties.GetServiceId().c_str());
- writer.Key(kActions);
- writer.StartArray();
- for (const auto& action : properties.GetActions()) {
- writer.StartObject();
- writer.Key(kAction);
- writer.String(action.first.c_str());
- if (!action.second.empty()) {
- writer.Key(kResource);
- writer.String(action.second.c_str());
+ boost::json::object object;
+
+ object[kServiceId] = properties.GetServiceId();
+
+ {
+ boost::json::array actions;
+ for (const auto& action : properties.GetActions()) {
+ boost::json::object action_value;
+ action_value[kAction] = action.first;
+ if (!action.second.empty()) {
+ action_value.emplace(kResource, action.second);
+ }
+ actions.emplace_back(std::move(action_value));
}
- writer.EndObject();
+ object.emplace(kActions, std::move(actions));
}
- writer.EndArray();
- writer.Key(kDiagnostics);
- writer.Bool(properties.GetDiagnostics());
+ object[kDiagnostics] = properties.GetDiagnostics();
// default value is 'and', ignore parameter if operator type is 'and'
if (properties.GetOperatorType() ==
AuthorizeRequest::DecisionOperatorType::kOr) {
- writer.Key(kOperator);
- writer.String("or");
+ object[kOperator] = "or";
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
std::string AuthenticationClientImpl::GenerateUid() const {
diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
index dd7c45c2a..3fc9715a8 100644
--- a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
+++ b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
@@ -26,10 +26,9 @@
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
#include "Constants.h"
#include "ResponseFromJsonBuilder.h"
#include "Rfc1123Helper.h"
@@ -72,25 +71,25 @@ std::string Base64Encode(const Crypto::Sha256Digest& digest) {
return ret;
}
-Response Parse(client::HttpResponse& http_response) {
- rapidjson::IStreamWrapper stream(http_response.GetRawResponse());
- rapidjson::Document document;
- document.ParseStream(stream);
+Response Parse(client::HttpResponse& http_response) {
+ boost::json::error_code ec;
+ auto document = boost::json::parse(http_response.GetRawResponse(), ec);
if (http_response.GetStatus() != http::HttpStatusCode::OK) {
// HttpResult response can be error message or valid json with it.
std::string msg = http_response.GetResponseAsString();
- if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) {
- msg = document[Constants::MESSAGE].GetString();
+ if (!ec.failed() && document.is_object() &&
+ document.as_object().contains(Constants::MESSAGE)) {
+ msg = document.as_object()[Constants::MESSAGE].get_string().c_str();
}
return client::ApiError({http_response.GetStatus(), msg});
}
- if (document.HasParseError()) {
+ if (ec.failed() || !document.is_object()) {
return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR),
"Failed to parse response"});
}
- return Response(std::move(document));
+ return {std::move(document).as_object()};
}
} // namespace
@@ -119,7 +118,7 @@ porting::optional GetTimestampFromHeaders(
return porting::none;
}
-IntrospectAppResult GetIntrospectAppResult(const rapidjson::Document& doc) {
+IntrospectAppResult GetIntrospectAppResult(const boost::json::object& doc) {
return ResponseFromJsonBuilder::Build(doc)
.Value(Constants::CLIENT_ID, &IntrospectAppResult::SetClientId)
.Value(Constants::NAME, &IntrospectAppResult::SetName)
@@ -150,22 +149,25 @@ DecisionType GetDecision(const std::string& str) {
: DecisionType::kDeny;
}
-std::vector GetDiagnostics(rapidjson::Document& doc) {
+std::vector GetDiagnostics(boost::json::object& doc) {
std::vector results;
- const auto& array = doc[Constants::DIAGNOSTICS].GetArray();
- for (auto& element : array) {
+ auto& array = doc[Constants::DIAGNOSTICS].get_array();
+ for (auto& element_value : array) {
+ auto& element = element_value.get_object();
ActionResult action;
- if (element.HasMember(Constants::DECISION)) {
- action.SetDecision(GetDecision(element[Constants::DECISION].GetString()));
+ if (element.contains(Constants::DECISION)) {
+ action.SetDecision(
+ GetDecision(element[Constants::DECISION].get_string().c_str()));
// get permissions if avialible
- if (element.HasMember(Constants::PERMISSIONS) &&
- element[Constants::PERMISSIONS].IsArray()) {
+ if (element.contains(Constants::PERMISSIONS) &&
+ element[Constants::PERMISSIONS].is_array()) {
std::vector permissions;
const auto& permissions_array =
- element[Constants::PERMISSIONS].GetArray();
+ element[Constants::PERMISSIONS].get_array();
for (auto& permission_element : permissions_array) {
Permission permission =
- ResponseFromJsonBuilder::Build(permission_element)
+ ResponseFromJsonBuilder::Build(
+ permission_element.get_object())
.Value(Constants::ACTION, &Permission::SetAction)
.Value(Constants::DECISION, &Permission::SetDecision,
&GetDecision)
@@ -182,26 +184,27 @@ std::vector GetDiagnostics(rapidjson::Document& doc) {
return results;
}
-AuthorizeResult GetAuthorizeResult(rapidjson::Document& doc) {
+AuthorizeResult GetAuthorizeResult(boost::json::object& doc) {
AuthorizeResult result;
- if (doc.HasMember(Constants::IDENTITY)) {
- auto uris = doc[Constants::IDENTITY].GetObject();
+ if (doc.contains(Constants::IDENTITY)) {
+ auto uris = doc[Constants::IDENTITY].get_object();
- if (uris.HasMember(Constants::CLIENT_ID)) {
- result.SetClientId(uris[Constants::CLIENT_ID].GetString());
- } else if (uris.HasMember(Constants::USER_ID)) {
- result.SetClientId(uris[Constants::USER_ID].GetString());
+ if (uris.contains(Constants::CLIENT_ID)) {
+ result.SetClientId(uris[Constants::CLIENT_ID].get_string().c_str());
+ } else if (uris.contains(Constants::USER_ID)) {
+ result.SetClientId(uris[Constants::USER_ID].get_string().c_str());
}
}
- if (doc.HasMember(Constants::DECISION)) {
- result.SetDecision(GetDecision(doc[Constants::DECISION].GetString()));
+ if (doc.contains(Constants::DECISION)) {
+ result.SetDecision(
+ GetDecision(doc[Constants::DECISION].get_string().c_str()));
}
// get diagnostics if available
- if (doc.HasMember(Constants::DIAGNOSTICS) &&
- doc[Constants::DIAGNOSTICS].IsArray()) {
+ if (doc.contains(Constants::DIAGNOSTICS) &&
+ doc[Constants::DIAGNOSTICS].is_array()) {
result.SetActionResults(GetDiagnostics(doc));
}
return result;
diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h
index 3904627df..6fdb5cd82 100644
--- a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h
+++ b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2021 HERE Europe B.V.
+ * Copyright (C) 2020-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +19,12 @@
#pragma once
+#include
#include
#include
#include
-#include
+#include
#include "olp/authentication/AuthenticationCredentials.h"
#include "olp/authentication/AuthenticationSettings.h"
@@ -78,7 +79,7 @@ porting::optional GetTimestampFromHeaders(
* @param doc json document.
* @return result for introspect app.
*/
-IntrospectAppResult GetIntrospectAppResult(const rapidjson::Document& doc);
+IntrospectAppResult GetIntrospectAppResult(const boost::json::object& value);
/*
* @brief Convert string representation of decision to DecisionType.
@@ -92,14 +93,14 @@ DecisionType GetDecision(const std::string& str);
* @param doc json document.
* @return result of ActionResults.
*/
-std::vector GetDiagnostics(rapidjson::Document& doc);
+std::vector GetDiagnostics(boost::json::object& value);
/*
* @brief Parse json document to AuthorizeResult type.
* @param doc json document.
* @return result for authorize.
*/
-AuthorizeResult GetAuthorizeResult(rapidjson::Document& doc);
+AuthorizeResult GetAuthorizeResult(boost::json::object& value);
/*
* @brief Parse HTTP response to UserAccountInfoResponse type or error message.
diff --git a/olp-cpp-sdk-authentication/src/BaseResult.cpp b/olp-cpp-sdk-authentication/src/BaseResult.cpp
index edd86f7c9..f19399961 100644
--- a/olp-cpp-sdk-authentication/src/BaseResult.cpp
+++ b/olp-cpp-sdk-authentication/src/BaseResult.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,10 @@
#include "BaseResult.h"
-#include
-#include
+#include
+
+#include
+#include
#include "Constants.h"
#include "olp/core/http/HttpStatusCode.h"
@@ -35,52 +37,49 @@ static const char* ERROR_MESSAGE = "message";
static const char* LINE_END = ".";
BaseResult::BaseResult(int status, std::string error,
- std::shared_ptr json_document)
+ std::shared_ptr json_document)
: status_()
{
status_ = status;
error_.message = std::move(error);
- is_valid_ = (json_document && !json_document->HasParseError());
+ is_valid_ = json_document != nullptr;
// If HTTP error, try to get error details
- if (!HasError() || !is_valid_ || !json_document->HasMember(ERROR_CODE)) {
+ if (!HasError() || !is_valid_ || !json_document->contains(ERROR_CODE)) {
return;
}
// The JSON document has an error code member, so save full JSON content to
// the `full_message_` string.
- rapidjson::StringBuffer buffer;
- rapidjson::Writer writer(buffer);
- json_document->Accept(writer);
- full_message_ = buffer.GetString();
+ full_message_ = boost::json::serialize(*json_document);
- if (json_document->HasMember(ERROR_ID)) {
- error_.error_id = (*json_document)[ERROR_ID].GetString();
+ if (json_document->contains(ERROR_ID)) {
+ error_.error_id = (*json_document)[ERROR_ID].get_string().c_str();
}
// Enhance error message with network response error details
- error_.code = (*json_document)[ERROR_CODE].GetUint();
+ error_.code = (*json_document)[ERROR_CODE].to_number();
- if (!json_document->HasMember(ERROR_MESSAGE)) {
+ if (!json_document->contains(ERROR_MESSAGE)) {
return;
}
- std::string message = (*json_document)[ERROR_MESSAGE].GetString();
- if (!json_document->HasMember(ERROR_FIELDS)) {
+ std::string message = (*json_document)[ERROR_MESSAGE].get_string().c_str();
+ if (!json_document->contains(ERROR_FIELDS)) {
error_.message = message;
return;
}
error_.message = message.substr(0, message.find_first_of(LINE_END) + 1);
- const rapidjson::Value& fields = (*json_document)[ERROR_FIELDS];
- if (fields.GetType() == rapidjson::kArrayType) {
- for (rapidjson::SizeType i = 0u; i < fields.Size(); i++) {
- const rapidjson::Value& field = fields[i];
- if (field.HasMember(ERROR_MESSAGE)) {
+ auto& fields = (*json_document)[ERROR_FIELDS];
+ if (auto* fields_array = fields.if_array()) {
+ for (auto& field : *fields_array) {
+ if (field.is_object() && field.as_object().contains(ERROR_MESSAGE)) {
ErrorField error_field;
- error_field.name = field[FIELD_NAME].GetString();
- error_field.code = field[ERROR_CODE].GetUint();
- error_field.message = field[ERROR_MESSAGE].GetString();
+ error_field.name = field.as_object()[FIELD_NAME].get_string().c_str();
+ error_field.code = field.as_object()[ERROR_CODE].to_number();
+ error_field.message =
+ field.as_object()[ERROR_MESSAGE].get_string().c_str();
error_fields_.emplace_back(error_field);
}
}
diff --git a/olp-cpp-sdk-authentication/src/BaseResult.h b/olp-cpp-sdk-authentication/src/BaseResult.h
index cd581275f..e0dae31c2 100644
--- a/olp-cpp-sdk-authentication/src/BaseResult.h
+++ b/olp-cpp-sdk-authentication/src/BaseResult.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
#include
#include
-#include
+#include
#include "olp/authentication/ErrorResponse.h"
@@ -33,7 +33,7 @@ namespace authentication {
class BaseResult {
public:
BaseResult(int status, std::string error,
- std::shared_ptr json_document = nullptr);
+ std::shared_ptr json_document = nullptr);
virtual ~BaseResult();
/**
diff --git a/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h b/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
index 8d4ee37d5..ff49374ac 100644
--- a/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
+++ b/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2021 HERE Europe B.V.
+ * Copyright (C) 2020-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,10 @@
#pragma once
+#include
+#include
+#include
+
#include
#include
@@ -35,7 +39,8 @@ struct Identity {
template
class ResponseFromJsonBuilder {
- using JsonValue = rapidjson::Document::ValueType;
+ using JsonDoc = boost::json::object;
+ using JsonValue = boost::json::value;
public:
template
@@ -46,16 +51,16 @@ class ResponseFromJsonBuilder {
const std::string kLogTag = "ResponseFromJsonBuilder";
public:
- explicit BuilderHelper(const JsonValue& json_value) : json_{json_value} {}
+ explicit BuilderHelper(const JsonDoc& json_value) : json_{json_value} {}
template
BuilderHelper& Value(const char* name, void (TargetType::*set_fn)(ArgType),
Projection projection = {}) {
using CompatibleType = decltype(GetCompatibleType());
fields_.emplace(name, [=](TargetType& target_obj,
- const JsonValue& value) {
- if (value.Is()) {
- (target_obj.*set_fn)(projection(value.Get()));
+ const JsonValue& json_value) {
+ if (auto value = If(json_value)) {
+ (target_obj.*set_fn)(projection(*value));
} else {
OLP_SDK_LOG_WARNING_F(kLogTag, "Wrong type, response=%s, field=%s",
kTargetTypeName.c_str(), name);
@@ -71,13 +76,13 @@ class ResponseFromJsonBuilder {
decltype(GetCompatibleType());
fields_.emplace(name, [=](TargetType& target_obj,
const JsonValue& value) {
- if (value.IsArray()) {
- const auto& array = value.GetArray();
+ if (value.is_array()) {
+ const auto& array = value.get_array();
ArrayType array_result;
- array_result.reserve(array.Size());
+ array_result.reserve(array.size());
for (const auto& element : array) {
- if (element.Is()) {
- array_result.push_back(element.Get());
+ if (auto element_value = If(element)) {
+ array_result.push_back(*element_value);
}
}
(target_obj.*set_fn)(std::move(array_result));
@@ -92,12 +97,12 @@ class ResponseFromJsonBuilder {
TargetType Finish() {
TargetType result;
- auto it = json_.MemberBegin();
- auto it_end = json_.MemberEnd();
+ auto it = json_.cbegin();
+ auto it_end = json_.cend();
for (; it != it_end; ++it) {
- auto find_it = fields_.find(std::string{it->name.GetString()});
+ auto find_it = fields_.find(std::string{it->key_c_str()});
if (find_it != fields_.end()) {
- find_it->second(result, it->value);
+ find_it->second(result, it->value());
// erasing already processed value
fields_.erase(find_it);
continue;
@@ -105,7 +110,7 @@ class ResponseFromJsonBuilder {
OLP_SDK_LOG_WARNING_F(kLogTag,
"Unexpected value, response=%s, field=%s",
- kTargetTypeName.c_str(), it->name.GetString());
+ kTargetTypeName.c_str(), it->key_c_str());
}
// in the ideal scenario all fields should be processed
@@ -133,11 +138,39 @@ class ResponseFromJsonBuilder {
std::is_same::value>::type>
int64_t GetCompatibleType();
+ template ::value>::type>
+ const bool* If(const JsonValue& value) {
+ return value.if_bool();
+ }
+
+ template ::value ||
+ std::is_same::value>::type>
+ const int64_t* If(const JsonValue& value) {
+ return value.if_int64();
+ }
+
+ template ::value>::type>
+ const uint64_t* If(const JsonValue& value) {
+ return value.if_uint64();
+ }
+
+ template ::value>::type>
+ porting::optional If(const JsonValue& value) {
+ if (auto* str = value.if_string()) {
+ return str->c_str();
+ }
+ return nullptr;
+ }
+
using Fields =
std::unordered_map>;
- const JsonValue& json_;
+ const JsonDoc& json_;
Fields fields_;
};
diff --git a/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
index 96cfa8d7b..334de6cb1 100644
--- a/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2025 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
#include "SignInResultImpl.h"
+#include
+
#include "Constants.h"
#include "olp/core/http/HttpStatusCode.h"
@@ -33,45 +35,43 @@ constexpr auto kTokenTypeSnakeCase = "token_type";
constexpr auto kAccessTokenSnakeCase = "access_token";
constexpr auto kExpiresInSnakeCase = "expires_in";
-bool HasAccessToken(const rapidjson::Document& document) {
- return document.HasMember(Constants::ACCESS_TOKEN) ||
- document.HasMember(kAccessTokenSnakeCase);
+bool HasAccessToken(const boost::json::object& document) {
+ return document.contains(Constants::ACCESS_TOKEN) ||
+ document.contains(kAccessTokenSnakeCase);
}
-std::string ParseAccessToken(const rapidjson::Document& document) {
- if (document.HasMember(Constants::ACCESS_TOKEN)) {
- return document[Constants::ACCESS_TOKEN].GetString();
+std::string ParseAccessToken(const boost::json::object& document) {
+ if (document.contains(Constants::ACCESS_TOKEN)) {
+ return document.at(Constants::ACCESS_TOKEN).get_string().c_str();
}
-
- return document[kAccessTokenSnakeCase].GetString();
+ return document.at(kAccessTokenSnakeCase).get_string().c_str();
}
-bool HasExpiresIn(const rapidjson::Document& document) {
- return document.HasMember(Constants::EXPIRES_IN) ||
- document.HasMember(kExpiresInSnakeCase);
+bool HasExpiresIn(const boost::json::object& document) {
+ return document.contains(Constants::EXPIRES_IN) ||
+ document.contains(kExpiresInSnakeCase);
}
-unsigned ParseExpiresIn(const rapidjson::Document& document) {
- if (document.HasMember(Constants::EXPIRES_IN)) {
- return document[Constants::EXPIRES_IN].GetUint();
+uint64_t ParseExpiresIn(const boost::json::object& document) {
+ if (document.contains(Constants::EXPIRES_IN)) {
+ return document.at(Constants::EXPIRES_IN).to_number();
}
- return document[kExpiresInSnakeCase].GetUint();
+ return document.at(kExpiresInSnakeCase).to_number();
}
-bool HasTokenType(const rapidjson::Document& document) {
- return document.HasMember(kTokenType) ||
- document.HasMember(kTokenTypeSnakeCase);
+bool HasTokenType(const boost::json::object& document) {
+ return document.contains(kTokenType) ||
+ document.contains(kTokenTypeSnakeCase);
}
-std::string ParseTokenType(const rapidjson::Document& document) {
- if (document.HasMember(kTokenType)) {
- return document[kTokenType].GetString();
+std::string ParseTokenType(const boost::json::object& document) {
+ if (document.contains(kTokenType)) {
+ return document.at(kTokenType).get_string().c_str();
}
-
- return document[kTokenTypeSnakeCase].GetString();
+ return document.at(kTokenTypeSnakeCase).get_string().c_str();
}
-bool IsDocumentValid(const rapidjson::Document& document) {
+bool IsDocumentValid(const boost::json::object& document) {
return HasAccessToken(document) && HasExpiresIn(document) &&
HasTokenType(document);
}
@@ -84,7 +84,7 @@ SignInResultImpl::SignInResultImpl() noexcept
SignInResultImpl::SignInResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: BaseResult(status, std::move(error), json_document),
expiry_time_(),
expires_in_() {
@@ -100,17 +100,18 @@ SignInResultImpl::SignInResultImpl(
access_token_ = ParseAccessToken(*json_document);
if (HasTokenType(*json_document))
token_type_ = ParseTokenType(*json_document);
- if (json_document->HasMember(Constants::REFRESH_TOKEN))
- refresh_token_ = (*json_document)[Constants::REFRESH_TOKEN].GetString();
+ if (json_document->contains(Constants::REFRESH_TOKEN))
+ refresh_token_ =
+ json_document->at(Constants::REFRESH_TOKEN).get_string().c_str();
if (HasExpiresIn(*json_document)) {
const auto expires_in = ParseExpiresIn(*json_document);
expiry_time_ = std::time(nullptr) + expires_in;
expires_in_ = std::chrono::seconds(expires_in);
}
- if (json_document->HasMember(kUserId))
- user_identifier_ = (*json_document)[kUserId].GetString();
- if (json_document->HasMember(kScope))
- scope_ = (*json_document)[kScope].GetString();
+ if (json_document->contains(kUserId))
+ user_identifier_ = json_document->at(kUserId).get_string().c_str();
+ if (json_document->contains(kScope))
+ scope_ = json_document->at(kScope).get_string().c_str();
}
}
}
diff --git a/olp-cpp-sdk-authentication/src/SignInResultImpl.h b/olp-cpp-sdk-authentication/src/SignInResultImpl.h
index 1712f443f..bad5abad5 100644
--- a/olp-cpp-sdk-authentication/src/SignInResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignInResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@
#pragma once
+#include
#include
#include
#include
-#include
#include "BaseResult.h"
@@ -34,7 +34,7 @@ class SignInResultImpl : public BaseResult {
SignInResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignInResultImpl() override;
@@ -65,7 +65,7 @@ class SignInResultImpl : public BaseResult {
*/
time_t GetExpiryTime() const;
- /**
+ /**
* @brief Gets the access token expiry time in seconds.
* @return Duration for which token stays valid.
*/
diff --git a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp
index 36530f40d..10eddcc76 100644
--- a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
#include "SignInUserResultImpl.h"
+#include
+
#include "Constants.h"
#include "olp/core/http/HttpStatusCode.h"
@@ -40,23 +42,24 @@ SignInUserResultImpl::SignInUserResultImpl() noexcept
SignInUserResultImpl::SignInUserResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: SignInResultImpl(status, std::move(error), json_document) {
if (BaseResult::IsValid()) {
- if (json_document->HasMember(kTermsReacceptanceToken))
+ if (json_document->contains(kTermsReacceptanceToken))
term_acceptance_token_ =
- (*json_document)[kTermsReacceptanceToken].GetString();
- if (json_document->HasMember(kTermsUrls)) {
- rapidjson::Document::Object obj =
- (*json_document)[kTermsUrls].GetObject();
- if (obj.HasMember(kTermsOfServiceUrl))
- terms_of_service_url_ = obj[kTermsOfServiceUrl].GetString();
- if (obj.HasMember(kTermsOfServiceUrlJson))
- terms_of_service_url_json_ = obj[kTermsOfServiceUrlJson].GetString();
- if (obj.HasMember(kPrivatePolicyUrl))
- private_policy_url_ = obj[kPrivatePolicyUrl].GetString();
- if (obj.HasMember(kPrivatePolicyUrlJson))
- private_policy_url_json_ = obj[kPrivatePolicyUrlJson].GetString();
+ (*json_document)[kTermsReacceptanceToken].get_string().c_str();
+ if (json_document->contains(kTermsUrls)) {
+ auto& obj = (*json_document)[kTermsUrls].get_object();
+ if (obj.contains(kTermsOfServiceUrl))
+ terms_of_service_url_ = obj[kTermsOfServiceUrl].get_string().c_str();
+ if (obj.contains(kTermsOfServiceUrlJson))
+ terms_of_service_url_json_ =
+ obj[kTermsOfServiceUrlJson].get_string().c_str();
+ if (obj.contains(kPrivatePolicyUrl))
+ private_policy_url_ = obj[kPrivatePolicyUrl].get_string().c_str();
+ if (obj.contains(kPrivatePolicyUrlJson))
+ private_policy_url_json_ =
+ obj[kPrivatePolicyUrlJson].get_string().c_str();
}
}
}
diff --git a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h
index c6fd5218c..15425e57f 100644
--- a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
#pragma once
#include
+#include
#include
#include "SignInResultImpl.h"
@@ -41,7 +42,7 @@ class SignInUserResultImpl : public SignInResultImpl {
SignInUserResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignInUserResultImpl() override;
diff --git a/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp
index d223919f4..3b381d9c0 100644
--- a/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
#include "SignOutResultImpl.h"
+#include
+
#include "Constants.h"
#include "olp/core/http/HttpStatusCode.h"
@@ -31,7 +33,7 @@ SignOutResultImpl::SignOutResultImpl() noexcept
SignOutResultImpl::SignOutResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: BaseResult(status, std::move(error), json_document) {}
SignOutResultImpl::~SignOutResultImpl() = default;
diff --git a/olp-cpp-sdk-authentication/src/SignOutResultImpl.h b/olp-cpp-sdk-authentication/src/SignOutResultImpl.h
index 8c13229db..d23dccff5 100644
--- a/olp-cpp-sdk-authentication/src/SignOutResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignOutResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ class SignOutResultImpl : public BaseResult {
SignOutResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignOutResultImpl() override;
};
diff --git a/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp
index 27ea17db3..a62e080c3 100644
--- a/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
#include "SignUpResultImpl.h"
+#include
+
#include "Constants.h"
#include "olp/core/http/HttpStatusCode.h"
@@ -35,11 +37,11 @@ SignUpResultImpl::SignUpResultImpl() noexcept
SignUpResultImpl::SignUpResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: BaseResult(status, std::move(error), json_document) {
if (BaseResult::IsValid()) {
- if (json_document->HasMember(kUserId))
- user_identifier_ = (*json_document)[kUserId].GetString();
+ if (json_document->contains(kUserId))
+ user_identifier_ = (*json_document)[kUserId].get_string().c_str();
}
}
diff --git a/olp-cpp-sdk-authentication/src/SignUpResultImpl.h b/olp-cpp-sdk-authentication/src/SignUpResultImpl.h
index 7434d8e0a..e51adf3ee 100644
--- a/olp-cpp-sdk-authentication/src/SignUpResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignUpResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
#include
#include
-#include
+#include
#include "BaseResult.h"
@@ -35,7 +35,7 @@ class SignUpResultImpl : public BaseResult {
SignUpResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignUpResultImpl() override;
diff --git a/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp b/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
index 52bf22fa9..a3808009a 100644
--- a/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021-2024 HERE Europe B.V.
+ * Copyright (C) 2021-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +29,9 @@
#include
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
#include
#include "AuthenticationClientUtils.h"
@@ -102,22 +101,24 @@ void RetryDelay(const client::RetrySettings& retry_settings, size_t retry) {
}
TimeResponse ParseTimeResponse(const std::string& payload) {
- rapidjson::Document document;
- document.Parse(payload.c_str());
+ boost::json::error_code ec;
+ auto document = boost::json::parse(payload, ec);
- if (!document.IsObject()) {
+ if (!document.is_object()) {
return client::ApiError(client::ErrorCode::InternalFailure,
"JSON document root is not an Object type");
}
- const auto timestamp_it = document.FindMember("timestamp");
- if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) {
+ const auto timestamp_it = document.as_object().find("timestamp");
+ if (timestamp_it == document.as_object().end() ||
+ (!timestamp_it->value().is_uint64() &&
+ !timestamp_it->value().is_int64())) {
return client::ApiError(
client::ErrorCode::InternalFailure,
"JSON document must contain timestamp integer field");
}
- return timestamp_it->value.GetUint();
+ return timestamp_it->value().to_number();
}
std::string GenerateUid() {
@@ -130,28 +131,22 @@ std::string GenerateUid() {
client::OlpClient::RequestBodyType GenerateClientBody(
const TokenRequest& token_request,
const porting::optional& scope) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kClientGrantType);
+ object[kGrantType] = kClientGrantType;
auto expires_in =
static_cast(token_request.GetExpiresIn().count());
if (expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(expires_in);
+ object[Constants::EXPIRES_IN] = expires_in;
}
if (scope) {
- writer.Key(kScope);
- writer.String(scope->c_str());
+ object[kScope] = *scope;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
TimeResponse GetTimeFromServer(client::CancellationContext& context,
@@ -334,11 +329,13 @@ SignInResponse TokenEndpointImpl::SignInClient(
SignInResult TokenEndpointImpl::ParseAuthResponse(
int status, std::stringstream& auth_response) {
- auto document = std::make_shared();
- rapidjson::IStreamWrapper stream(auth_response);
- document->ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(auth_response, ec);
return std::make_shared(
- status, http::HttpErrorToString(status), document);
+ status, http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(document.as_object()));
}
client::HttpResponse TokenEndpointImpl::CallAuth(
diff --git a/olp-cpp-sdk-authentication/src/utils/BoostJsonSrc.cpp b/olp-cpp-sdk-authentication/src/utils/BoostJsonSrc.cpp
new file mode 100644
index 000000000..017758210
--- /dev/null
+++ b/olp-cpp-sdk-authentication/src/utils/BoostJsonSrc.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2026 HERE Europe B.V.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * License-Filename: LICENSE
+ */
+
+#include
diff --git a/olp-cpp-sdk-authentication/tests/SignInResultImplTest.cpp b/olp-cpp-sdk-authentication/tests/SignInResultImplTest.cpp
index 08599cc54..3381c0123 100644
--- a/olp-cpp-sdk-authentication/tests/SignInResultImplTest.cpp
+++ b/olp-cpp-sdk-authentication/tests/SignInResultImplTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2025 HERE Europe B.V.
+ * Copyright (C) 2020-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
#include
#include
+#include
#include "../src/SignInResultImpl.h"
namespace {
@@ -82,8 +83,12 @@ constexpr auto kWrongFormatResponse =
TEST(SignInResultImplTest, Constructor) {
{
SCOPED_TRACE("Valid token");
- auto doc = std::make_shared();
- doc->Parse(kTokenResponse);
+
+ boost::system::error_code error_code;
+ auto doc = std::make_shared(
+ boost::json::parse(kTokenResponse, error_code).as_object());
+ ASSERT_FALSE(error_code.failed());
+
olp::authentication::SignInResultImpl result(olp::http::HttpStatusCode::OK,
std::string(), doc);
@@ -95,8 +100,12 @@ TEST(SignInResultImplTest, Constructor) {
{
SCOPED_TRACE("Valid token from snake case response");
- auto doc = std::make_shared();
- doc->Parse(kTokenResponseSnakeCase);
+
+ boost::system::error_code error_code;
+ auto doc = std::make_shared(
+ boost::json::parse(kTokenResponseSnakeCase, error_code).as_object());
+ ASSERT_FALSE(error_code.failed());
+
olp::authentication::SignInResultImpl result(olp::http::HttpStatusCode::OK,
std::string(), doc);
@@ -108,8 +117,12 @@ TEST(SignInResultImplTest, Constructor) {
{
SCOPED_TRACE("Bad response");
- auto doc = std::make_shared();
- doc->Parse(kWrongFormatResponse);
+
+ boost::system::error_code error_code;
+ auto doc = std::make_shared(
+ boost::json::parse(kWrongFormatResponse, error_code).as_object());
+ ASSERT_FALSE(error_code.failed());
+
olp::authentication::SignInResultImpl result(olp::http::HttpStatusCode::OK,
std::string(), doc);
diff --git a/olp-cpp-sdk-core/CMakeLists.txt b/olp-cpp-sdk-core/CMakeLists.txt
index 6190c13dc..9bab6cedf 100644
--- a/olp-cpp-sdk-core/CMakeLists.txt
+++ b/olp-cpp-sdk-core/CMakeLists.txt
@@ -19,7 +19,6 @@
project(olp-cpp-sdk-core VERSION 1.24.0)
set(DESCRIPTION "Core network and utility library for the HERE OLP SDK C++")
-find_package(RapidJSON 1.1.0 REQUIRED)
find_package(Boost REQUIRED)
find_package(Threads REQUIRED)
@@ -97,12 +96,6 @@ set(OLP_SDK_CLIENT_HEADERS
./include/olp/core/client/TaskContext.h
)
-set(OLP_SDK_GENERATED_HEADERS
- ./include/olp/core/generated/parser/JsonParser.h
- ./include/olp/core/generated/parser/ParserWrapper.h
- ./include/olp/core/generated/serializer/SerializerWrapper.h
-)
-
set(OLP_SDK_HTTP_HEADERS
./include/olp/core/http/adapters/HarCaptureAdapter.h
./include/olp/core/http/CertificateSettings.h
@@ -229,6 +222,12 @@ set(OLP_SDK_COREAPI_HEADERS
./include/olp/core/CoreApi.h
)
+set(OLP_SDK_GENERATED_HEADERS
+ ./src/generated/parser/JsonParser.h
+ ./src/generated/parser/ParserWrapper.h
+ ./src/generated/serializer/SerializerWrapper.h
+)
+
set(OLP_SDK_GEO_SOURCES
./src/geo/coordinates/GeoCoordinates.cpp
./src/geo/coordinates/GeoCoordinates3d.cpp
@@ -359,6 +358,7 @@ endif()
set(OLP_SDK_UTILS_SOURCES
./src/utils/Base64.cpp
./src/utils/BoostExceptionHandle.cpp
+ ./src/utils/BoostJsonSrc.cpp
./src/utils/Credentials.cpp
./src/utils/Dir.cpp
./src/utils/Thread.cpp
@@ -389,7 +389,6 @@ set(OLP_SDK_THREAD_SOURCES
set(OLP_SDK_CORE_HEADERS
${OLP_SDK_CACHE_HEADERS}
${OLP_SDK_CLIENT_HEADERS}
- ${OLP_SDK_GENERATED_HEADERS}
${OLP_SDK_HTTP_HEADERS}
${OLP_SDK_MODEL_HEADERS}
${OLP_SDK_PLATFORM_HEADERS}
@@ -407,6 +406,7 @@ set(OLP_SDK_CORE_HEADERS
)
set(OLP_SDK_CORE_SOURCES
+ ${OLP_SDK_GENERATED_HEADERS}
${OLP_SDK_CLIENT_SOURCES}
${OLP_SDK_HTTP_SOURCES}
${OLP_SDK_PLATFORM_SOURCES}
@@ -456,14 +456,15 @@ if (OLP_SDK_USE_STD_ANY)
PUBLIC OLP_SDK_USE_STD_ANY)
endif()
+target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_ALL_NO_LIB)
+target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_JSON_NO_LIB)
+
target_include_directories(${PROJECT_NAME} PUBLIC
$
$
$
$
- $
-
$)
if (ANDROID)
diff --git a/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h b/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h
deleted file mode 100644
index 3cdd5e1bd..000000000
--- a/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2019-2023 HERE Europe B.V.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * License-Filename: LICENSE
- */
-
-#pragma once
-
-#include