Kanzi Connect  3.9.9
Kanzi Connect C++ API
kanzi::connect::ServerConfig Class Reference

Kanzi Connect Server configuration file handling. More...

#include <serverconfig.hpp>

Classes

class  AttributeList
 List of configuration specific attributes. More...
 
class  AttributeProviderBase
 Base class for other domain-classes that provide attributes. More...
 
class  ConnectionAdapter
 Connection adapter encapsulation. More...
 
class  CustomConfiguration
 Class to contain information about all custom configurations in server config. More...
 
class  Diagnostics
 Diagnostics configuration. More...
 
class  FlowControl
 Flow control configuration encapsulation. More...
 
class  HTTPProtocol
 HTTP Setting encapsulation. More...
 
class  Identity
 Server identity related attributes. More...
 
class  Log
 Log configuration. More...
 
class  Persistence
 Class comment. More...
 
class  Policy
 Policy configuration. More...
 
class  PublishedConfigurations
 Configurations published through the Configuration service. More...
 
class  Security
 Security configuration. More...
 
class  Service
 Service configuration. More...
 
class  WebSocket
 WebSocket configuration. More...
 

Public Types

typedef vector< ConnectionAdapterSharedPtrConnectionAdapterContainer
 
typedef shared_ptr< ConnectionAdapterConnectionAdapterSharedPtr
 
typedef vector< HTTPProtocolSharedPtrHTTPProtocolContainer
 
typedef shared_ptr< HTTPProtocolHTTPProtocolSharedPtr
 
typedef vector< ServiceSharedPtrServiceContainer
 
typedef shared_ptr< ServiceServiceSharedPtr
 

Public Member Functions

string buildReferredFileName (const string &filename)
 Builds a complete filename with path of a referred file. More...
 
const unordered_map< string, string > & getCivetOptions () const
 Retrieves the civet options specified inside the <httpserver> element. More...
 
ConnectionAdapterSharedPtr getConnectionAdapter (const string &type)
 Retrieves a connection adapter based on its type. More...
 
const ConnectionAdapterContainergetConnectionAdapters () const
 Retrieve list of connection adapters to configure. More...
 
CustomConfigurationgetCustomConfiguration (string path)
 Get the custom configuration specified by path. More...
 
vector< string > getDependentServicesRecursive (const string &name) const
 Retrieve list of services that depend from this service. More...
 
DiagnosticsgetDiagnostics ()
 Retrieve diagnostics information. More...
 
FlowControlgetFlowControl ()
 Retrieve server-wide flow control information for remote service operation. More...
 
HTTPProtocolSharedPtr getHTTPProtocol (const string &type)
 Retrieves a HTTP Protocol object based on requested type. More...
 
const HTTPProtocolContainergetHTTPProtocols () const
 Retrieve list of HTTP Protocol configurations. More...
 
IdentitygetIdentity ()
 Retrieve server-wide identity information. More...
 
LoggetLog ()
 Retrieve server-wide log information. More...
 
PersistencegetPersistence ()
 Retrieve server-wide persistence information. More...
 
PolicygetPolicyConfig ()
 Retrieve server-wide policy information. More...
 
PublishedConfigurationsgetPublishedConfigurations ()
 Retrieve the published configurations information. More...
 
SecuritygetSecurityConfig ()
 Retrieve server-wide security information. More...
 
ServiceSharedPtr getService (const string &name) const
 Retrieve service by name or by library name. More...
 
ServiceSharedPtr getServiceByLibraryName (const string &libraryname) const
 Retrieve service by library name. More...
 
vector< string > getServiceDependenciesRecursive (const string &name) const
 Retrieve service dependencies in recursive manner. More...
 
const ServiceContainergetServices () const
 Retrieve list of service configurations. More...
 
const AttributeListgetServicesAttributes () const
 Retrieve list of services attributes. More...
 
WebSocketgetWebSocketConfig ()
 Retrieve server-wide websocket information. More...
 
bool isValid ()
 IS configuration read from a valid file. More...
 
bool loadFromBuffer (const string &buffer)
 Loads the structure from provided buffer. More...
 
bool loadFromFile (const string &filename)
 Loads the structure from file provided. More...
 
bool loadFromFileset (FileSet &fileset)
 Loades the structure from passed fileset. More...
 
string readReferredFile (const string &filename)
 Reads a file that is referred from the server configuration file. More...
 
 ServerConfig ()
 C++ Constructor. More...
 
 ~ServerConfig ()
 Destructor. More...
 

Protected Member Functions

bool checkConnectionAdapters () const
 Checks that provided connectionadapter definitions are valid. More...
 
bool checkFilePresent (const string &filename) const
 checks whether file is available More...
 
bool checkFiles ()
 Checks that all attributes whom type is "file" can be read. More...
 
bool checkFilesFromAttributeList (AttributeList &attributes, bool &ok) const
 Goes through the list and checks that all file type attributes are accessible. More...
 
bool checkHTTPServer () const
 Checks that provided httpserver definitions are valid. More...
 
bool checkIdentity () const
 Checks that provided identity definitions are valid. More...
 
bool checkPersistence () const
 Checks that provided persistence definitions are valid. More...
 
bool checkServices () const
 Checks that provided service definitions are valid. More...
 
void findDependenciesRecursive (const string &dependency, vector< string > &dependencyChain, bool &recursionDetected) const
 Determines dependencies in recursive manner. More...
 
void getServiceDependenciesRecursive (ServiceSharedPtr service, vector< string > &serviceDependencies) const
 Resolves recursive dependencies to a specific service. More...
 
bool hasService (const string &name) const
 Checks whether <service> node with provided name exists. More...
 
bool loadFromBufferInternal (const string &buffer, bool cleanFileset)
 Load from buffer internal implementation. More...
 
void processAdapters (const tinyxml2::XMLElement *element)
 Processes <connectionadapters> node. More...
 
void processCustomConfiguration (const tinyxml2::XMLElement *element)
 Process any nodes that are not one of the known hard coded elements. More...
 
void processDiagnostics (const tinyxml2::XMLElement *element, Diagnostics &diagnostics)
 Process <diagnostics> node. More...
 
void processDocument (const tinyxml2::XMLElement *element)
 Processes the XML document. More...
 
void processFlowControl (const tinyxml2::XMLElement *element, FlowControl &flowcontrol)
 Processes <flowcontrol> node. More...
 
void processHttpServer (const tinyxml2::XMLElement *element)
 Process <httpserver> node. More...
 
void processIdentity (const tinyxml2::XMLElement *element, Identity &identity)
 Processes <identity> node. More...
 
void processLog (const tinyxml2::XMLElement *element, Log &policy)
 Processes <log> node. More...
 
void processPersistence (const tinyxml2::XMLElement *element, Persistence &persistence)
 Processes <persistence> node. More...
 
void processPolicy (const tinyxml2::XMLElement *element, Policy &policy)
 Processes <policy> node. More...
 
void processPublishedConfigurations (const tinyxml2::XMLElement *element, PublishedConfigurations &publishedConfigurations)
 Process <published_configurations> node. More...
 
void processSecurity (const tinyxml2::XMLElement *element, Security &security)
 Processes all child elements inside <security> element. More...
 
void processSecurityChilds (const tinyxml2::XMLElement *element, Service &security)
 Processes all <security> child objects from the provided object. More...
 
void processServices (const tinyxml2::XMLElement *element)
 Processes <services> node. More...
 

Static Protected Member Functions

static string platformSpecificBasePath (AttributeList &attributes)
 Tries to find a attribute used to specify platform specific base path for security files. More...
 
static void processAttributes (const tinyxml2::XMLElement *element, AttributeList &attributes)
 Processes all <attribute> nodes and fills the attribute list with those. More...
 

Detailed Description

Kanzi Connect Server configuration file handling.

Member Typedef Documentation

◆ ConnectionAdapterContainer

◆ ConnectionAdapterSharedPtr

◆ HTTPProtocolContainer

◆ HTTPProtocolSharedPtr

◆ ServiceContainer

◆ ServiceSharedPtr

Constructor & Destructor Documentation

◆ ServerConfig()

kanzi::connect::ServerConfig::ServerConfig ( )

C++ Constructor.

◆ ~ServerConfig()

kanzi::connect::ServerConfig::~ServerConfig ( )

Destructor.

Member Function Documentation

◆ buildReferredFileName()

string kanzi::connect::ServerConfig::buildReferredFileName ( const string &  filename)

Builds a complete filename with path of a referred file.

Parameters
filenameas defined on configuration
Returns
filename with path information added.

◆ checkConnectionAdapters()

bool kanzi::connect::ServerConfig::checkConnectionAdapters ( ) const
protected

Checks that provided connectionadapter definitions are valid.

Returns
true if valid.

◆ checkFilePresent()

bool kanzi::connect::ServerConfig::checkFilePresent ( const string &  filename) const
protected

checks whether file is available

Parameters
filenamethe file to check
Returns
true if file is found.

◆ checkFiles()

bool kanzi::connect::ServerConfig::checkFiles ( )
protected

Checks that all attributes whom type is "file" can be read.

Returns
true if valid.

◆ checkFilesFromAttributeList()

bool kanzi::connect::ServerConfig::checkFilesFromAttributeList ( AttributeList attributes,
bool &  ok 
) const
protected

Goes through the list and checks that all file type attributes are accessible.

Parameters
attributeslist of attributes to check
okwill be set to false if problems detected.
Returns
true if ok is true.

◆ checkHTTPServer()

bool kanzi::connect::ServerConfig::checkHTTPServer ( ) const
protected

Checks that provided httpserver definitions are valid.

Returns
true if valid.

◆ checkIdentity()

bool kanzi::connect::ServerConfig::checkIdentity ( ) const
protected

Checks that provided identity definitions are valid.

Returns
true if valid

◆ checkPersistence()

bool kanzi::connect::ServerConfig::checkPersistence ( ) const
protected

Checks that provided persistence definitions are valid.

Returns
true if valid

◆ checkServices()

bool kanzi::connect::ServerConfig::checkServices ( ) const
protected

Checks that provided service definitions are valid.

Returns
true if valid.

◆ findDependenciesRecursive()

void kanzi::connect::ServerConfig::findDependenciesRecursive ( const string &  dependency,
vector< string > &  dependencyChain,
bool &  recursionDetected 
) const
protected

Determines dependencies in recursive manner.

Parameters
dependencyname of the dependency
dependencyChainlist of dependencies discovered so far
recursionDetectedwill be set to true if depedency recursion is met.

◆ getCivetOptions()

const unordered_map<string, string>& kanzi::connect::ServerConfig::getCivetOptions ( ) const

Retrieves the civet options specified inside the <httpserver> element.

Returns
unordered_map where key: option name, value: option value

◆ getConnectionAdapter()

ConnectionAdapterSharedPtr kanzi::connect::ServerConfig::getConnectionAdapter ( const string &  type)

Retrieves a connection adapter based on its type.

Parameters
typetype of the connection adapter. E.g. "connect.bearer.tcp", "connect.bearer.ssl" or similar.
Returns
pointer to connection adapter or empty pointer.

◆ getConnectionAdapters()

const ConnectionAdapterContainer& kanzi::connect::ServerConfig::getConnectionAdapters ( ) const

Retrieve list of connection adapters to configure.

Returns
vector of items defining connection adapters.

◆ getCustomConfiguration()

CustomConfiguration* kanzi::connect::ServerConfig::getCustomConfiguration ( string  path)

Get the custom configuration specified by path.

Parameters
pathIdentifies which configuration to return (hierarchies separated by '.')
Returns
Pointer to the configuration or nullptr if not found (does not release ownership of configuration to caller)

◆ getDependentServicesRecursive()

vector<string> kanzi::connect::ServerConfig::getDependentServicesRecursive ( const string &  name) const

Retrieve list of services that depend from this service.

The returned dependencies are not in any specific order

Parameters
nameservice to inspect
Returns
list of service identifiers of services who depend from named service.

◆ getDiagnostics()

Diagnostics& kanzi::connect::ServerConfig::getDiagnostics ( )

Retrieve diagnostics information.

Returns
diagnostics configuration.

◆ getFlowControl()

FlowControl& kanzi::connect::ServerConfig::getFlowControl ( )

Retrieve server-wide flow control information for remote service operation.

Returns
flow control settings.

◆ getHTTPProtocol()

HTTPProtocolSharedPtr kanzi::connect::ServerConfig::getHTTPProtocol ( const string &  type)

Retrieves a HTTP Protocol object based on requested type.

Parameters
typeof the protocol to retrieve. E.g. "http", "https"
Returns
pointer to HTTPProtocol object or empty pointer.

◆ getHTTPProtocols()

const HTTPProtocolContainer& kanzi::connect::ServerConfig::getHTTPProtocols ( ) const

Retrieve list of HTTP Protocol configurations.

Returns
vector containing http configurations.

◆ getIdentity()

Identity& kanzi::connect::ServerConfig::getIdentity ( )

Retrieve server-wide identity information.

Returns
reference to identity information

◆ getLog()

Log& kanzi::connect::ServerConfig::getLog ( )

Retrieve server-wide log information.

Returns
reference to log information.

◆ getPersistence()

Persistence& kanzi::connect::ServerConfig::getPersistence ( )

Retrieve server-wide persistence information.

Returns
reference to persistence information

◆ getPolicyConfig()

Policy& kanzi::connect::ServerConfig::getPolicyConfig ( )

Retrieve server-wide policy information.

Returns
reference to policy information.

◆ getPublishedConfigurations()

PublishedConfigurations& kanzi::connect::ServerConfig::getPublishedConfigurations ( )

Retrieve the published configurations information.

Returns
Published configurations

◆ getSecurityConfig()

Security& kanzi::connect::ServerConfig::getSecurityConfig ( )

Retrieve server-wide security information.

Returns
reference to server-wide security definitions.

◆ getService()

ServiceSharedPtr kanzi::connect::ServerConfig::getService ( const string &  name) const

Retrieve service by name or by library name.

Parameters
namethe name for the service
Returns
shared pointer to service

◆ getServiceByLibraryName()

ServiceSharedPtr kanzi::connect::ServerConfig::getServiceByLibraryName ( const string &  libraryname) const

Retrieve service by library name.

Parameters
librarynamename of the library that identifies the service. Shall there be multiple service instances made from one library this returns the first.
Returns
shared pointer to service

◆ getServiceDependenciesRecursive() [1/2]

vector<string> kanzi::connect::ServerConfig::getServiceDependenciesRecursive ( const string &  name) const

Retrieve service dependencies in recursive manner.

The returned dependencies are not in any specific order.

Parameters
namethe name of the service whom dependencies are to be retrieved
Returns
vector of service identifiers that are dependant of the passed in service.

◆ getServiceDependenciesRecursive() [2/2]

void kanzi::connect::ServerConfig::getServiceDependenciesRecursive ( ServiceSharedPtr  service,
vector< string > &  serviceDependencies 
) const
protected

Resolves recursive dependencies to a specific service.

Parameters
servicethe service whom dependencies are to determined.
serviceDepdencieslist of collected dependencies.

◆ getServices()

const ServiceContainer& kanzi::connect::ServerConfig::getServices ( ) const

Retrieve list of service configurations.

Returns
vector of items containing service defitions

◆ getServicesAttributes()

const AttributeList& kanzi::connect::ServerConfig::getServicesAttributes ( ) const

Retrieve list of services attributes.

Returns
list of attributes.

◆ getWebSocketConfig()

WebSocket& kanzi::connect::ServerConfig::getWebSocketConfig ( )

Retrieve server-wide websocket information.

Returns
reference to websocket information.

◆ hasService()

bool kanzi::connect::ServerConfig::hasService ( const string &  name) const
protected

Checks whether <service> node with provided name exists.

Parameters
namethe name to check
Returns
true

◆ isValid()

bool kanzi::connect::ServerConfig::isValid ( )

IS configuration read from a valid file.

Returns
true if configuration read from a file.

◆ loadFromBuffer()

bool kanzi::connect::ServerConfig::loadFromBuffer ( const string &  buffer)

Loads the structure from provided buffer.

Parameters
bufferxml buffer
Returns
true if successfully loaded.

◆ loadFromBufferInternal()

bool kanzi::connect::ServerConfig::loadFromBufferInternal ( const string &  buffer,
bool  cleanFileset 
)
protected

Load from buffer internal implementation.

Parameters
bufferbuffer that contains the configuration
cleanFilesetif defined, then resets the member variable holding fileset
Returns
true if loading succeeded.

◆ loadFromFile()

bool kanzi::connect::ServerConfig::loadFromFile ( const string &  filename)

Loads the structure from file provided.

Parameters
filenamefull path to file to load
Returns
true if successfully loaded.

◆ loadFromFileset()

bool kanzi::connect::ServerConfig::loadFromFileset ( FileSet fileset)

Loades the structure from passed fileset.

Parameters
filesetfileset containing the configuration information
Returns
true if successfully initialized.

◆ platformSpecificBasePath()

static string kanzi::connect::ServerConfig::platformSpecificBasePath ( AttributeList attributes)
staticprotected

Tries to find a attribute used to specify platform specific base path for security files.

Attribute is named "basepath-linux", "basepath-win32", "basepath-qnx", "basepath-android" or "basepath-default" for generic base path.

Parameters
attributeslist of attributes to search from.
Returns
string specifying the path component, if any.

◆ processAdapters()

void kanzi::connect::ServerConfig::processAdapters ( const tinyxml2::XMLElement *  element)
protected

Processes <connectionadapters> node.

Parameters
elementthe <connectionadapters> node

◆ processAttributes()

static void kanzi::connect::ServerConfig::processAttributes ( const tinyxml2::XMLElement *  element,
AttributeList attributes 
)
staticprotected

Processes all <attribute> nodes and fills the attribute list with those.

Parameters
elementparent whom <attribute> childs are to be found.
attributeslist to fill with attribute information.

◆ processCustomConfiguration()

void kanzi::connect::ServerConfig::processCustomConfiguration ( const tinyxml2::XMLElement *  element)
protected

Process any nodes that are not one of the known hard coded elements.

Parameters
elementThe element to process

◆ processDiagnostics()

void kanzi::connect::ServerConfig::processDiagnostics ( const tinyxml2::XMLElement *  element,
Diagnostics diagnostics 
)
protected

Process <diagnostics> node.

Parameters
elementthe <diagnostics> element
diagnosticsthe diagnostics object

◆ processDocument()

void kanzi::connect::ServerConfig::processDocument ( const tinyxml2::XMLElement *  element)
protected

Processes the XML document.

Parameters
elementthe root element of the document.

◆ processFlowControl()

void kanzi::connect::ServerConfig::processFlowControl ( const tinyxml2::XMLElement *  element,
FlowControl flowcontrol 
)
protected

Processes <flowcontrol> node.

Parameters
elementthe <flowcontrol> element
flowcontrolthe FlowControl object

◆ processHttpServer()

void kanzi::connect::ServerConfig::processHttpServer ( const tinyxml2::XMLElement *  element)
protected

Process <httpserver> node.

Parameters
elementthe <httpserver> node.

◆ processIdentity()

void kanzi::connect::ServerConfig::processIdentity ( const tinyxml2::XMLElement *  element,
Identity identity 
)
protected

Processes <identity> node.

Parameters
elementthe <identity> element
identitythe identity object

◆ processLog()

void kanzi::connect::ServerConfig::processLog ( const tinyxml2::XMLElement *  element,
Log policy 
)
protected

Processes <log> node.

Parameters
elementthe <log> element
policythe policy object

◆ processPersistence()

void kanzi::connect::ServerConfig::processPersistence ( const tinyxml2::XMLElement *  element,
Persistence persistence 
)
protected

Processes <persistence> node.

Parameters
elementthe <persistence> element
persistencethe persistence object

◆ processPolicy()

void kanzi::connect::ServerConfig::processPolicy ( const tinyxml2::XMLElement *  element,
Policy policy 
)
protected

Processes <policy> node.

Parameters
elementthe <policy> element
policythe policy object

◆ processPublishedConfigurations()

void kanzi::connect::ServerConfig::processPublishedConfigurations ( const tinyxml2::XMLElement *  element,
PublishedConfigurations publishedConfigurations 
)
protected

Process <published_configurations> node.

Parameters
elementthe <published_configurations> element
publishedConfigurationsthe PublishedConfigurations object

◆ processSecurity()

void kanzi::connect::ServerConfig::processSecurity ( const tinyxml2::XMLElement *  element,
Security security 
)
protected

Processes all child elements inside <security> element.

Parameters
elementpointer to <security> element
securityobject to be filled with security attributes.

◆ processSecurityChilds()

void kanzi::connect::ServerConfig::processSecurityChilds ( const tinyxml2::XMLElement *  element,
Service security 
)
protected

Processes all <security> child objects from the provided object.

Parameters
elementthe parent element below which the <security> objects are searched.
securitysecurity object to be filled with security information found.

◆ processServices()

void kanzi::connect::ServerConfig::processServices ( const tinyxml2::XMLElement *  element)
protected

Processes <services> node.

Parameters
elementthe <services> node

◆ readReferredFile()

string kanzi::connect::ServerConfig::readReferredFile ( const string &  filename)

Reads a file that is referred from the server configuration file.

This method will adjust the path to be relative to the server configuration files location.

Parameters
filenamethe filename to be read.
Returns
file contents.

The documentation for this class was generated from the following file: