20 using namespace OpcUa;
26 OpcUaParameters(
const Common::Logger::SharedPtr & logger)
31 std::vector<ApplicationData> GetApplications(
const std::vector<Common::ParametersGroup> & applicationGroups)
const 33 std::vector<ApplicationData> applications;
37 Log(
"Found group : ", subGroup.Name);
39 if (subGroup.Name ==
"application")
42 applications.push_back(application);
47 Log(
"Unknown parameters group: ", subGroup.Name);
54 std::vector<Common::ParametersGroup> GetAddonParameters(
const std::vector<ApplicationData> & endpoints)
const 56 std::vector<Common::ParametersGroup> result(endpoints.size());
57 std::transform(endpoints.begin(), endpoints.end(), result.begin(), [
this](
const ApplicationData & app)
59 return ApplicationToParametersGroup(app);
67 if (typeName ==
"anonymous" || typeName.empty())
70 else if (typeName ==
"user_name")
73 else if (typeName ==
"certificate")
76 else if (typeName ==
"issued_token")
79 throw std::logic_error(
"Unknown token type '" + typeName +
"'");
96 return "issued_token";
99 throw std::logic_error(
"Unknown token type '" + std::to_string((
unsigned)type) +
"'");
105 if (typeName ==
"client" || typeName.empty())
108 else if (typeName ==
"server")
111 else if (typeName ==
"client_and_server")
114 else if (typeName ==
"discovery_server")
117 throw std::logic_error(
"Invalid name of type application type: " + typeName);
131 return "client_and_server";
134 return "discovery_server";
137 throw std::logic_error(
"Unknown application type: " + std::to_string((
unsigned)type));
143 if (modeName ==
"none" || modeName.empty())
146 else if (modeName ==
"sign")
149 else if (modeName ==
"sign_encrypt")
152 throw std::logic_error(
"Unknown security mode name: " + modeName);
166 return "sign_encrypt";
169 throw std::logic_error(
"Unknown security mode: " + std::to_string((
unsigned)mode));
173 UserTokenPolicy GetUserTokenPolicy(
const std::vector<Common::Parameter> & params)
const 175 Log(
"Parsing user token policy.");
180 if (
param.Name ==
"id")
183 else if (
param.Name ==
"type")
186 else if (
param.Name ==
"uri")
189 else if (
param.Name ==
"issued_token_type")
192 else if (
param.Name ==
"issuer_endpoint_url")
196 {
Log(
"Unknown policy token field",
param.Name,
param.Value); }
204 Log(
"Parsing user token policy.");
216 Log(
"Parsing endpoint parameters.");
223 if (param.
Name ==
"security_mode")
226 if (param.
Name ==
"security_level")
229 else if (param.
Name ==
"security_policy_uri")
232 else if (param.
Name ==
"transport_profile_uri")
235 else if (param.
Name ==
"url")
239 {
Log(
"Unknown endpoint parameter: ", param.
Name,
"=", param.
Value); }
244 if (subGroup.
Name ==
"user_token_policy")
252 Log(
"Unknown group of endpoint parameters: ", subGroup.
Name);
270 ed.Groups.push_back(GetUserTokenPolicy(policy));
278 Log(
"Parsing application parameters.");
283 Log(
"Parsing app paramter ", param.
Name,
" = ", param.
Value);
285 if (param.
Name ==
"uri")
290 else if (param.
Name ==
"product_uri")
295 else if (param.
Name ==
"gateway_server_uri")
300 else if (param.
Name ==
"discovery_profile")
305 else if (param.
Name ==
"name")
310 else if (param.
Name ==
"type")
317 Log(
"Unknown application parameter: ", param.
Name,
"=", param.
Value);
323 Log(
"parsing group ", group.
Name);
325 if (group.
Name ==
"endpoint")
334 Log(
"Unknown group in the applications parameters: ", group.
Name);
358 result.Groups.push_back(GetEndpointDescription(endpoint));
365 template <
typename T,
typename...
Args>
366 void Log(T && msg,
Args... args)
const 393 Common::Logger::SharedPtr Logger;
397 std::vector<OpcUa::Server::ApplicationData>
OpcUa::ParseEndpointsParameters(
const std::vector<Common::ParametersGroup> & applicationGroups,
const Common::Logger::SharedPtr & logger)
399 OpcUaParameters parser(logger);
400 const std::vector<OpcUa::Server::ApplicationData> & data = parser.GetApplications(applicationGroups);
404 std::vector<Common::ParametersGroup>
OpcUa::CreateCommonParameters(
const std::vector<Server::ApplicationData> & endpoints,
const Common::Logger::SharedPtr & logger)
406 OpcUaParameters parser(logger);
407 const std::vector<Common::ParametersGroup> & result = parser.GetAddonParameters(endpoints);
ApplicationDescription Application
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
std::vector< OpcUa::UserTokenPolicy > UserIdentityTokens
std::string SecurityPolicyUri
std::vector< Parameter > Parameters
std::string GatewayServerUri
std::string SecurityPolicyUri
std::vector< ParametersGroup > Groups
std::vector< EndpointDescription > Endpoints
#define LOG_DEBUG(__logger__,...)
std::string IssuedTokenType
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
OpcUa::ApplicationDescription Server
std::string TransportProfileUri
OpcUa::ApplicationType ApplicationType
GTEST_API_ void Log(LogSeverity severity, const string &message, int stack_frames_to_skip)
std::string DiscoveryProfileUri
OpcUa::MessageSecurityMode SecurityMode
OPC UA Address space part. GNU LGPL.
std::string ApplicationUri
OpcUa::LocalizedText ApplicationName
std::vector< Server::ApplicationData > ParseEndpointsParameters(const std::vector< Common::ParametersGroup > &rootGroup, const Common::Logger::SharedPtr &logger)
OpcUa::UserTokenType TokenType
std::vector< std::string > DiscoveryUrls
std::string IssuerEndpointUrl
std::vector< Common::ParametersGroup > CreateCommonParameters(const std::vector< Server::ApplicationData > &endpoints, const Common::Logger::SharedPtr &logger)