Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/psv_pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion external/boost/CMakeLists.txt.boost.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ include(ExternalProject)
ExternalProject_Add(boost-download
GIT_REPOSITORY @OLP_SDK_CPP_BOOST_URL@
GIT_TAG @OLP_SDK_CPP_BOOST_TAG@
GIT_SUBMODULES libs/any
GIT_SUBMODULES libs/algorithm
libs/any
libs/array
libs/assert
libs/concept_check
libs/config
libs/container
libs/container_hash
libs/core
libs/date_time
libs/detail
libs/describe
libs/format
Expand All @@ -37,6 +42,7 @@ ExternalProject_Add(boost-download
libs/integer
libs/io
libs/iterator
libs/lexical_cast
libs/move
libs/mpl
libs/mp11
Expand All @@ -45,10 +51,12 @@ ExternalProject_Add(boost-download
libs/predef
libs/preprocessor
libs/random
libs/range
libs/serialization
libs/smart_ptr
libs/static_assert
libs/throw_exception
libs/tokenizer
libs/tti
libs/type_index
libs/type_traits
Expand Down
94 changes: 73 additions & 21 deletions olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/time_facet.hpp>
#include "Constants.h"
#include "ResponseFromJsonBuilder.h"
#include "olp/core/http/NetworkResponse.h"
Expand Down Expand Up @@ -59,6 +62,18 @@ constexpr auto kOauthSignatureMethod = "oauth_signature_method";
constexpr auto kVersion = "1.0";
constexpr auto kHmac = "HMAC-SHA256";
constexpr auto kLogTag = "AuthenticationClientUtils";
// %e: day with optional leading space/zero.
// %H remains strict two-digit hour in input facet.
constexpr auto kRfc1123GmtFormat = "%a, %e %b %Y %H:%M:%S GMT";

std::string TrimDateHeaderValue(const std::string& value) {
const auto begin = value.find_first_not_of(" \t\r\n");
if (begin == std::string::npos) {
return {};
}
const auto end = value.find_last_not_of(" \t\r\n");
return value.substr(begin, end - begin + 1);
}

std::string Base64Encode(const Crypto::Sha256Digest& digest) {
std::string ret = olp::utils::Base64Encode(digest.data(), digest.size());
Expand Down Expand Up @@ -109,37 +124,74 @@ std::time_t ParseTime(const std::string& value) {

#else

std::string TrimDateHeaderValue(const std::string& value) {
const auto begin = value.find_first_not_of(" \t\r\n");
if (begin == std::string::npos) {
return {};
}
const auto end = value.find_last_not_of(" \t\r\n");
return value.substr(begin, end - begin + 1);
}

std::time_t ParseTime(const std::string& value) {
std::tm tm = {};
const auto trimmed_value = TrimDateHeaderValue(value);
if (trimmed_value.empty()) {
OLP_SDK_LOG_WARNING_F(kLogTag,
"Failed to parse Date header '%s': value is empty "
"after trimming whitespace",
value.c_str());
return static_cast<std::time_t>(-1);
}

std::istringstream stream(trimmed_value);

// Facet has internal counter, which is incremented by the std::locale.
// When last locale pointing to the facet is destroyed, the counter is
// decremented and the facet is destroyed.
stream.imbue(
std::locale(std::locale::classic(),
new boost::posix_time::time_input_facet(kRfc1123GmtFormat)));

boost::posix_time::ptime parsed_time;
stream >> parsed_time;
if (stream.fail()) {
OLP_SDK_LOG_WARNING_F(kLogTag,
"Failed to parse Date header '%s': format mismatch "
"for RFC1123 timestamp",
value.c_str());
return static_cast<std::time_t>(-1);
}

// Use a C locale to keep RFC1123 parsing locale-independent.
// Literal "GMT" avoids platform-specific %Z behaviour.
locale_t c_locale = newlocale(LC_ALL_MASK, "C", (locale_t)0);
if (c_locale == (locale_t)0) {
OLP_SDK_LOG_WARNING(kLogTag, "Failed to create C locale");
if (parsed_time.is_not_a_date_time()) {
OLP_SDK_LOG_WARNING_F(kLogTag,
"Failed to parse Date header '%s': parsed value is "
"not a valid date/time",
value.c_str());
return static_cast<std::time_t>(-1);
}

const auto parsed_until = ::strptime_l(
trimmed_value.c_str(), "%a, %d %b %Y %H:%M:%S GMT", &tm, c_locale);
freelocale(c_locale);
stream >> std::ws;
if (!stream.eof()) {
OLP_SDK_LOG_WARNING_F(kLogTag,
"Failed to parse Date header '%s': unexpected "
"trailing characters after timestamp",
value.c_str());
return static_cast<std::time_t>(-1);
}

const auto epoch =
boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1));
if (parsed_time < epoch) {
OLP_SDK_LOG_WARNING_F(
kLogTag,
"Failed to parse Date header '%s': timestamp is before Unix epoch",
value.c_str());
return static_cast<std::time_t>(-1);
}

if (parsed_until != trimmed_value.c_str() + trimmed_value.size()) {
OLP_SDK_LOG_WARNING(kLogTag, "Timestamp is not fully parsed " << value);
const auto seconds_since_epoch = (parsed_time - epoch).total_seconds();
using SecondsType = boost::remove_cv_t<decltype(seconds_since_epoch)>;
if (seconds_since_epoch >
static_cast<SecondsType>(std::numeric_limits<std::time_t>::max())) {
OLP_SDK_LOG_WARNING_F(
kLogTag,
"Failed to parse Date header '%s': timestamp exceeds std::time_t range",
value.c_str());
return static_cast<std::time_t>(-1);
}

return timegm(&tm);
return static_cast<std::time_t>(seconds_since_epoch);
}

#endif
Expand Down
8 changes: 4 additions & 4 deletions scripts/android/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -ex
#
# Copyright (C) 2019-2024 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.
Expand All @@ -19,15 +19,15 @@

#
# This script will compile Data SDK for C++
# with ANDROID_PLATFORM=android-28 and -DANDROID_ABI=arm64-v8a
# with ANDROID_PLATFORM=android-21 and -DANDROID_ABI=arm64-v8a
# by using Android NDK 21.
#

# Install required NDK version (output disabled as it causes issues during page loading)
env
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_HOME} >/dev/null
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-28" >/dev/null
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-21" >/dev/null
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.3.6528147
env
Expand All @@ -38,7 +38,7 @@ ls -la $ANDROID_NDK_HOME/platforms
mkdir -p build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE="$ANDROID_HOME/ndk/21.3.6528147/build/cmake/android.toolchain.cmake" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DANDROID_PLATFORM=android-28 \
-DANDROID_PLATFORM=android-21 \
-DANDROID_ABI=arm64-v8a \
-DANDROID_NDK="$ANDROID_HOME/ndk/21.3.6528147" \
-DOLP_SDK_ENABLE_TESTING=NO \
Expand Down
37 changes: 37 additions & 0 deletions scripts/linux/psv/build_psv_no_exceptions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash -ex
#
# 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

# Show initial ccache data
ccache -s

mkdir -p build
cd build

cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror $CXXFLAGS" \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DOLP_SDK_BUILD_EXAMPLES=ON \
-DBUILD_SHARED_LIBS=ON \
-DOLP_SDK_NO_EXCEPTION=ON \
..

cmake --build . -- -j$(nproc)

# Show last ccache data
ccache -s
Loading