OnixS C++ ICE Binary Order Entry Handler 1.0.0
API Documentation
Loading...
Searching...
No Matches
BgwCredentials.h
Go to the documentation of this file.
1/*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19
20#pragma once
21
22#include <OnixS/ICE/BOE/ABI.h>
26
27#include <string>
28
30namespace Tools {
31
34{
36 std::string host;
37
40
43 std::string ipSessionToken;
44
46 bool valid() const noexcept
47 {
48 return !host.empty() && !ipSessionToken.empty() && port != 0;
49 }
50
52 explicit operator bool() const noexcept
53 {
54 return valid();
55 }
56
59 {
60 if(!(entry.success() && *entry.success() == Messaging::BooleanEnum::True))
61 throw std::runtime_error("IPReport::UsersEntry is invalid: success flag is missing or not set to True.");
62
63 if(!entry.ipAddress() || !entry.port() || !entry.ipSessionToken())
64 throw std::runtime_error("Invalid 'IPReport::UsersEntry'");
65
66 BgwCredentials credentials;
67
68 credentials.host = Messaging::toStr(*entry.ipAddress());
69 credentials.port = *entry.port();
70 credentials.ipSessionToken = *entry.ipSessionToken();
71
72 return credentials;
73 }
74};
75
76
77}
#define ONIXS_ICEBOE_NAMESPACE_BEGIN
Definition ABI.h:94
#define ONIXS_ICEBOE_NAMESPACE_END
Definition ABI.h:98
std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &)
Serializes a fixed-point decimal into a string.
unsigned short Port
Definition Defines.h:40
auto success() const noexcept
uint8NULL.
Definition Messages.h:8552
auto port() const noexcept
int16NULL.
Definition Messages.h:8607
auto ipSessionToken() const noexcept
ipSessionToken for the Gateway ID for assigned ipAddress and port for use in Binary Order Gateway Log...
Definition Messages.h:8634
auto ipAddress() const noexcept
Provides access to ipAddress field.
Definition Messages.h:8578
Connection credentials for Binary Utility Service Gateway.
static BgwCredentials create(Messaging::IPReport::UsersEntry entry)
Creates BgwCredentials from the given IPReport::UsersEntry instance.
std::string host
IP address of the gateway endpoint.
bool valid() const noexcept
Checks whether all required fields are present and usable.
Port port
Network port number of the gateway endpoint.
std::string ipSessionToken
ipSessionToken from Binary Utility Service Gateway (BUS).