Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <olp/authentication/Types.h>
#include <olp/core/client/ApiResponse.h>
#include <olp/core/client/CancellationToken.h>
#include <boost/optional.hpp>
#include <olp/core/porting/optional.hpp>

/**
* @brief Rules all the other namespaces.
Expand Down Expand Up @@ -65,15 +65,15 @@ class AUTHENTICATION_API AuthenticationClient {
/**
* @brief (Optional) The scope assigned to the access token.
*/
boost::optional<std::string> scope{boost::none};
porting::optional<std::string> scope{porting::none};

/**
* @brief (Optional) The device ID assigned to the access token.
*
* @note This field is only necessary if you want to apply a oauth rate
* limit on a particular device.
*/
boost::optional<std::string> device_id{boost::none};
porting::optional<std::string> device_id{porting::none};

/**
* @brief (Optional) The number of seconds left before the access
Expand All @@ -89,7 +89,7 @@ class AUTHENTICATION_API AuthenticationClient {
* requires it. Fully overrides default body and resets the request content
* type.
*/
boost::optional<std::string> custom_body{boost::none};
porting::optional<std::string> custom_body{olp::porting::none};
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <string>

#include <boost/optional/optional.hpp>
#include <olp/core/porting/optional.hpp>
#include "AuthenticationApi.h"

namespace olp {
Expand Down Expand Up @@ -58,12 +58,13 @@ class AUTHENTICATION_API AuthenticationCredentials {
* @return An optional value with your credentials if the credentials were
* read successfully, or no value in case of failure.
*/
static boost::optional<AuthenticationCredentials> ReadFromStream(
static porting::optional<AuthenticationCredentials> ReadFromStream(
std::istream& stream);

/**
* @brief Parses the **credentials.properties** file downloaded from the [HERE platform](https://platform.here.com/)
* website and retrieves a value with your credentials.
* @brief Parses the **credentials.properties** file downloaded from the [HERE
* platform](https://platform.here.com/) website and retrieves a value with
* your credentials.
*
* The file must contain the following lines:
* * here.access.key.id &ndash; your access key ID
Expand All @@ -81,7 +82,7 @@ class AUTHENTICATION_API AuthenticationCredentials {
* @return The optional value with your credentials if the credentials were
* read successfully, or no value in case of failure.
*/
static boost::optional<AuthenticationCredentials> ReadFromFile(
static porting::optional<AuthenticationCredentials> ReadFromFile(
std::string filename = {});
AuthenticationCredentials() = delete;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <olp/authentication/AuthenticationApi.h>
#include <olp/core/client/RetrySettings.h>
#include <olp/core/http/NetworkProxySettings.h>
#include <boost/optional.hpp>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace http {
Expand All @@ -50,9 +50,9 @@ struct AUTHENTICATION_API AuthenticationSettings {
/**
* @brief The configuration settings for the network layer.
*
* To remove any existing proxy settings, set to boost::none.
* To remove any existing proxy settings, set to olp::porting::none.
*/
boost::optional<http::NetworkProxySettings> network_proxy_settings{};
porting::optional<http::NetworkProxySettings> network_proxy_settings{};

/**
* @brief The network instance that is used to internally operate with the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#pragma once

#include <boost/optional.hpp>
#include <string>
#include <vector>

#include <olp/authentication/AuthenticationApi.h>
#include <olp/core/porting/optional.hpp>

namespace olp {
namespace authentication {
Expand Down Expand Up @@ -83,7 +83,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return The service ID.
*/
inline const std::string& GetServiceId() const { return service_id_; }
const std::string& GetServiceId() const { return service_id_; }

/**
* @brief Sets the service ID.
Expand All @@ -92,7 +92,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return A reference to the updated `DecisionRequest` instance.
*/
inline AuthorizeRequest& WithServiceId(std::string service_id) {
AuthorizeRequest& WithServiceId(std::string service_id) {
service_id_ = std::move(service_id);
return *this;
}
Expand All @@ -109,7 +109,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return The contract ID or an error.
*/
inline const boost::optional<std::string>& GetContractId() const {
const porting::optional<std::string>& GetContractId() const {
return contract_id_;
}

Expand All @@ -122,9 +122,9 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return A reference to the updated `DecisionRequest` instance.
*/
inline AuthorizeRequest& WithContractId(
boost::optional<std::string> contract_id) {
contract_id_ = std::move(contract_id);
template <class T = porting::optional<std::string>>
AuthorizeRequest& WithContractId(T&& contract_id) {
contract_id_ = std::forward<T>(contract_id);
return *this;
}

Expand All @@ -137,7 +137,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return A reference to the updated `DecisionRequest` instance.
*/
inline AuthorizeRequest& WithContractId(std::string contract_id) {
AuthorizeRequest& WithContractId(std::string contract_id) {
contract_id_ = std::move(contract_id);
return *this;
}
Expand All @@ -159,8 +159,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return A reference to the updated `DecisionRequest` instance.
*/
inline AuthorizeRequest& WithAction(std::string action,
std::string resource = "") {
AuthorizeRequest& WithAction(std::string action, std::string resource = "") {
actions_.emplace_back(std::move(action), std::move(resource));
return *this;
}
Expand All @@ -174,7 +173,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return The operator type.
*/
inline DecisionOperatorType GetOperatorType() const { return operator_type_; }
DecisionOperatorType GetOperatorType() const { return operator_type_; }

/**
* @brief Sets the operator type for the request.
Expand All @@ -185,8 +184,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return A reference to the updated `DecisionRequest` instance.
*/
inline AuthorizeRequest& WithOperatorType(
DecisionOperatorType operator_type) {
AuthorizeRequest& WithOperatorType(DecisionOperatorType operator_type) {
operator_type_ = operator_type;
return *this;
}
Expand All @@ -196,7 +194,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return The diagnostics flag.
*/
inline bool GetDiagnostics() const { return diagnostics_; }
bool GetDiagnostics() const { return diagnostics_; }

/**
* @brief Sets the diagnostics flag for the request.
Expand All @@ -206,7 +204,7 @@ class AUTHENTICATION_API AuthorizeRequest final {
*
* @return A reference to the updated `DecisionRequest` instance.
*/
inline AuthorizeRequest& WithDiagnostics(bool diagnostics) {
AuthorizeRequest& WithDiagnostics(bool diagnostics) {
diagnostics_ = diagnostics;
return *this;
}
Expand All @@ -220,7 +218,7 @@ class AUTHENTICATION_API AuthorizeRequest final {

private:
std::string service_id_;
boost::optional<std::string> contract_id_;
porting::optional<std::string> contract_id_;
Actions actions_;
DecisionOperatorType operator_type_{DecisionOperatorType::kAnd};
bool diagnostics_{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

#pragma once

#include <boost/optional.hpp>
#include <memory>
#include <string>

#include <olp/core/client/RetrySettings.h>
#include <olp/core/http/NetworkProxySettings.h>
#include <olp/core/porting/optional.hpp>

#include "AuthenticationApi.h"
#include "AuthenticationCredentials.h"
Expand Down Expand Up @@ -77,7 +77,7 @@ struct AUTHENTICATION_API Settings {
/**
* @brief (Optional) The configuration settings for the network layer.
*/
boost::optional<http::NetworkProxySettings> network_proxy_settings;
porting::optional<http::NetworkProxySettings> network_proxy_settings;

/**
* @brief (Optional) The server URL of the token endpoint.
Expand Down Expand Up @@ -108,7 +108,7 @@ struct AUTHENTICATION_API Settings {
/**
* @brief (Optional) The scope to be assigned to an access token requests.
*/
boost::optional<std::string> scope;
porting::optional<std::string> scope;
};

} // namespace authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#pragma once

#include <boost/optional.hpp>
#include <chrono>
#include <ctime>
#include <string>

#include <olp/core/porting/optional.hpp>
#include "AuthenticationApi.h"
#include "ErrorResponse.h"

Expand All @@ -47,7 +47,7 @@ class AUTHENTICATION_API TokenResult {
* @param scope The scope assigned to the access token.
*/
TokenResult(std::string access_token, time_t expiry_time,
boost::optional<std::string> scope);
porting::optional<std::string> scope);

/**
* @brief Creates the `TokenResult` instance.
Expand All @@ -57,7 +57,7 @@ class AUTHENTICATION_API TokenResult {
* @param scope The scope assigned to the access token.
*/
TokenResult(std::string access_token, std::chrono::seconds expires_in,
boost::optional<std::string> scope);
porting::optional<std::string> scope);
/**
* @brief Creates the default `TokenResult` instance.
*/
Expand Down Expand Up @@ -92,13 +92,13 @@ class AUTHENTICATION_API TokenResult {
* @return The optional string that contains the scope assigned to the access
* token.
*/
const boost::optional<std::string>& GetScope() const;
const porting::optional<std::string>& GetScope() const;

private:
std::string access_token_;
time_t expiry_time_{};
std::chrono::seconds expires_in_{};
boost::optional<std::string> scope_;
porting::optional<std::string> scope_;
};

} // namespace authentication
Expand Down
24 changes: 12 additions & 12 deletions olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,24 @@ Response<SignInResponseType> AuthenticationClientImpl::GetSignInResponse(
}

template <>
boost::optional<SignInResult> AuthenticationClientImpl::FindInCache(
porting::optional<SignInResult> AuthenticationClientImpl::FindInCache(
const std::string& key) {
return client_token_cache_->locked(
[&](utils::LruCache<std::string, SignInResult>& cache) {
auto it = cache.Find(key);
return it != cache.end() ? boost::make_optional(it->value())
: boost::none;
return it != cache.end() ? porting::make_optional(it->value())
: porting::none;
});
}

template <>
boost::optional<SignInUserResult> AuthenticationClientImpl::FindInCache(
porting::optional<SignInUserResult> AuthenticationClientImpl::FindInCache(
const std::string& key) {
return user_token_cache_->locked(
[&](utils::LruCache<std::string, SignInUserResult>& cache) {
auto it = cache.Find(key);
return it != cache.end() ? boost::make_optional(it->value())
: boost::none;
return it != cache.end() ? porting::make_optional(it->value())
: porting::none;
});
}

Expand Down Expand Up @@ -325,7 +325,7 @@ client::CancellationToken AuthenticationClientImpl::SignInClient(
// endpoint with it. Construction of the `OlpClient` requires the host part
// of URL, while `CallAuth` method - the rest of URL, hence we need to split
// URL passed in the Credentials object.
const auto credentials_endpoint = credentials.GetEndpointUrl();
const auto& credentials_endpoint = credentials.GetEndpointUrl();
const auto maybe_host_and_rest =
olp::utils::Url::ParseHostAndRest(credentials_endpoint);
if (maybe_host_and_rest) {
Expand All @@ -338,7 +338,7 @@ client::CancellationToken AuthenticationClientImpl::SignInClient(
// settings object.
auto settings = settings_;
settings.token_endpoint_url = olp_client_host;
auto client = CreateOlpClient(settings, boost::none, false);
auto client = CreateOlpClient(settings, porting::none, false);

RequestTimer timer = CreateRequestTimer(client, context);

Expand Down Expand Up @@ -472,7 +472,7 @@ client::CancellationToken AuthenticationClientImpl::SignInApple(
return client::ApiError::Cancelled();
}

auto client = CreateOlpClient(settings_, boost::none);
auto client = CreateOlpClient(settings_, porting::none);

auto auth_response = CallApi(client, kOauthEndpoint, context,
properties.GetAccessToken(), request_body);
Expand Down Expand Up @@ -534,7 +534,7 @@ client::CancellationToken AuthenticationClientImpl::HandleUserRequest(
return client::ApiError::Cancelled();
}

auto client = CreateOlpClient(settings_, boost::none, false);
auto client = CreateOlpClient(settings_, porting::none, false);

RequestTimer timer = CreateRequestTimer(client, context);

Expand Down Expand Up @@ -834,12 +834,12 @@ client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateClientBody(

if (properties.scope) {
writer.Key(kScope);
writer.String(properties.scope.get().c_str());
writer.String(properties.scope->c_str());
}

if (properties.device_id) {
writer.Key(kDeviceId);
writer.String(properties.device_id.get().c_str());
writer.String(properties.device_id->c_str());
}

writer.EndObject();
Expand Down
2 changes: 1 addition & 1 deletion olp-cpp-sdk-authentication/src/AuthenticationClientImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class AuthenticationClientImpl {
const client::CancellationContext& context, const std::string& key);

template <typename SignInResponseType>
boost::optional<SignInResponseType> FindInCache(const std::string& key);
porting::optional<SignInResponseType> FindInCache(const std::string& key);

template <typename SignInResponseType>
void StoreInCache(const std::string& key, SignInResponseType);
Expand Down
Loading
Loading