Browse Source

codedweller namespace to CFGmgr

master
Pete McNeil 4 years ago
parent
commit
01ddf0c328
2 changed files with 60 additions and 60 deletions
  1. 34
    34
      snfCFGmgr.cpp
  2. 26
    26
      snfCFGmgr.hpp

+ 34
- 34
snfCFGmgr.cpp View File

@@ -492,7 +492,7 @@ void fixPathTermination(string& s) {
}

void snfCFGData::initializeFromFile(const char* FileName) { // Initialize from the provided file.
ConfigurationData MyCFGData(FileName); // Create a cfg data object from the file.
cd::ConfigurationData MyCFGData(FileName); // Create a cfg data object from the file.
if(0 == MyCFGData.Data(0)) throw false; // If we didn't read a config file throw!
MyCFGReader.initialize(); // Initialize to defaults.
MyCFGReader.interpret(MyCFGData); // Interpret the data.
@@ -556,37 +556,37 @@ void snfCFGmgr::initialize(
InitLicenseId = (NULL==LicenseId)?"":LicenseId; // any time load() is called.
InitAuthentication = (NULL==Authentication)?"":Authentication;
}
//*****************************************************************************
//// IMPORTANT: If the authentication string is provided in the initialize() it
//// MUST NOT be put into D.node_authentication.
//*****************************************************************************
//// When the license ID and security string come from an OEM application they
//// may not appear in the configuration files. If that is the case we will assume
//// that they developer wants to keep the security string secret by encrypting it
//// in their application and providing it to SNF at runtime. In that case we will
//// not display the security key in the configuration log.
////
//// To prevent hacking attempts, if the authentication information appears to be
//// provided by configuration data then we will build the string from that data.
//// that way an attacker can't trick the application into disclosing the true
//// authentication string -- they will only get out what they put in.
string SecurityKeyDisplayString(snfCFGData& D) { // Returns appropriate SecurityKey: data
string ConfigLogSecurityKey = "************************"; // Start with a masked display.
if(0 < D.node_authentication.length()) { // If auth info is in the config files then
ConfigLogSecurityKey = D.node_licenseid + D.node_authentication; // build up the key from that data so it
} // can be displayed in the config log.
return ConfigLogSecurityKey;
}
//*****************************************************************************
//// IMPORTANT: If the authentication string is provided in the initialize() it
//// MUST NOT be put into D.node_authentication.
//*****************************************************************************
//// When the license ID and security string come from an OEM application they
//// may not appear in the configuration files. If that is the case we will assume
//// that they developer wants to keep the security string secret by encrypting it
//// in their application and providing it to SNF at runtime. In that case we will
//// not display the security key in the configuration log.
////
//// To prevent hacking attempts, if the authentication information appears to be
//// provided by configuration data then we will build the string from that data.
//// that way an attacker can't trick the application into disclosing the true
//// authentication string -- they will only get out what they put in.
string SecurityKeyDisplayString(snfCFGData& D) { // Returns appropriate SecurityKey: data
string ConfigLogSecurityKey = "************************"; // Start with a masked display.
if(0 < D.node_authentication.length()) { // If auth info is in the config files then
ConfigLogSecurityKey = D.node_licenseid + D.node_authentication; // build up the key from that data so it
} // can be displayed in the config log.
return ConfigLogSecurityKey;
}

void logCFGData(snfCFGData& D) { // Log interpreted cfg data (debug aid).

try {
string CFGLogPath; // Build the snf_cfg log path.
CFGLogPath = D.paths_log_path +
D.node_licenseid + "_snf_engine_cfg.log";
D.node_licenseid + "_snf_engine_cfg.log";

ofstream cfgl(CFGLogPath.c_str(), ios::trunc); // Open and truncate the cfg log file.
cfgl // Report important cfg information.
@@ -986,8 +986,8 @@ void snfCFGmgr::load() {
//// If an identity path has been provided we must load that data.

if(0 < CFGData.node_identity.length()) { // If an identity path was provided
ConfigurationData Identity(CFGData.node_identity.c_str()); // then get the data from that file.
ConfigurationElement IdentityReader("snf"); // Create an Identity reader and
cd::ConfigurationData Identity(CFGData.node_identity.c_str()); // then get the data from that file.
cd::ConfigurationElement IdentityReader("snf"); // Create an Identity reader and
IdentityReader // configure it.
.Element("identity")
.Attribute("licenseid", CFGData.node_licenseid)
@@ -998,15 +998,15 @@ void snfCFGmgr::load() {
}

//// The SecurityKey is built from the licenseID and the Authentication
if(InitLicenseIdIsProvided) { // If the LicenseID is OEM provided then
CFGData.SecurityKey = InitLicenseId; // the first part of our security key is that.
CFGData.SecurityKey = InitLicenseId; // the first part of our security key is that.
CFGData.node_licenseid = InitLicenseId; // Also override any file-loaded license ID.
} else { // If it was not provided then we will get
CFGData.SecurityKey = CFGData.node_licenseid; // the LicenseID from our config file.
}
string LicenseIDToUse = CFGData.SecurityKey; // Grab the License ID we want to use.
string LicenseIDToUse = CFGData.SecurityKey; // Grab the License ID we want to use.

if(InitAuthenticationIsProvided) { // If the Authentication has been provided then
CFGData.SecurityKey += InitAuthentication; // we use it for the second part of our
@@ -1018,11 +1018,11 @@ void snfCFGmgr::load() {

if(InitPathIsRulebase) { // If the Rulebase path was provided
CFGData.RuleFilePath = InitFileName; // then we have our rulebase path.
} else { // If not then we must figure it out...
} else { // If not then we must figure it out...
CFGData.RuleFilePath = // We build the path from the base
CFGData.paths_rulebase_path + // rulebase path concattonated with
LicenseIDToUse + // the license id concattonated with
SNFExt; // the rulebase extension.
SNFExt; // the rulebase extension.
}

// Once all of the configuration data is correct we make it active.

+ 26
- 26
snfCFGmgr.hpp View File

@@ -17,7 +17,7 @@
#include <string>
#include <set>

using namespace std;
namespace cd = codedweller;

const unsigned long int HeaderDirectiveBypass = 0x00000001; // Bypass hd rule flag.
const unsigned long int HeaderDirectiveWhite = 0x00000002; // White hd rule flag.
@@ -25,12 +25,12 @@ const unsigned long int HeaderDirectiveDrillDown = 0x00000004;
const unsigned long int HeaderDirectiveSource = 0x00000008; // Source rule flag.
const unsigned long int HeaderDirectiveContext = 0x80000000; // Context activation flag.

class HeaderDirectiveHandler : public Configurator { // Handle inputs to header directives.
class HeaderDirectiveHandler : public cd::Configurator { // Handle inputs to header directives.
public:

HeaderDirectiveSet HeaderDirectives; // Managed set of Header Directives.

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator call adds the Input.
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator call adds the Input.

if(HeaderDirectiveContext == ContextInput.Directive) { // If a context has been established
ContextInput.Context = HeaderDirectives.size() + 1; // then setup the context ID and
@@ -54,7 +54,7 @@ class HeaderDirectiveHandler : public Configurator {

};

class HeaderDirectiveInitializer : public Configurator { // Initializes Header Directives.
class HeaderDirectiveInitializer : public cd::Configurator { // Initializes Header Directives.
private:

HeaderDirectiveHandler* MyTarget; // Needs to know it's target.
@@ -65,14 +65,14 @@ class HeaderDirectiveInitializer : public Configurator {

void setTarget(HeaderDirectiveHandler& H) { MyTarget = &H; } // We have a way to set the target though ;-)

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator() function goes to the
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator() function goes to the
if(NULL!=MyTarget) { // target (if it's set) and pushes the
MyTarget->reset(); // reset button (empties the set).
}
}
};

class HeaderDirectiveWhiteHeaderInitializer : public Configurator { // Initializes White Header Directives.
class HeaderDirectiveWhiteHeaderInitializer : public cd::Configurator { // Initializes White Header Directives.
private:

HeaderDirectiveHandler* MyTarget; // Needs to know it's target.
@@ -83,7 +83,7 @@ class HeaderDirectiveWhiteHeaderInitializer : public Configurator {

void setTarget(HeaderDirectiveHandler& H) { MyTarget = &H; } // We have a way to set the target though ;-)

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator() function goes to the
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator() function goes to the
if(NULL!=MyTarget) { // target (if it's set) and sets it up
MyTarget->ContextInput.clear(); // for a white header directive.
MyTarget->DirectiveInput.clear();
@@ -92,7 +92,7 @@ class HeaderDirectiveWhiteHeaderInitializer : public Configurator {
}
};

class HeaderDirectiveBypassHeaderInitializer : public Configurator { // Initializes Bypass Header Directives.
class HeaderDirectiveBypassHeaderInitializer : public cd::Configurator { // Initializes Bypass Header Directives.
private:

HeaderDirectiveHandler* MyTarget; // Needs to know it's target.
@@ -103,7 +103,7 @@ class HeaderDirectiveBypassHeaderInitializer : public Configurator {

void setTarget(HeaderDirectiveHandler& H) { MyTarget = &H; } // We have a way to set the target though ;-)

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator() function goes to the
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator() function goes to the
if(NULL!=MyTarget) { // target (if it's set) and sets it up
MyTarget->ContextInput.clear(); // for a bypass header directive.
MyTarget->DirectiveInput.clear();
@@ -112,7 +112,7 @@ class HeaderDirectiveBypassHeaderInitializer : public Configurator {
}
};

class HeaderDirectiveDrilldownInitializer : public Configurator { // Initializes Drilldown Header Directives.
class HeaderDirectiveDrilldownInitializer : public cd::Configurator { // Initializes Drilldown Header Directives.
private:

HeaderDirectiveHandler* MyTarget; // Needs to know it's target.
@@ -123,7 +123,7 @@ class HeaderDirectiveDrilldownInitializer : public Configurator {

void setTarget(HeaderDirectiveHandler& H) { MyTarget = &H; } // We have a way to set the target though ;-)

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator() function goes to the
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator() function goes to the
if(NULL!=MyTarget) { // target (if it's set) and sets it up for
MyTarget->ContextInput.clear(); // a drilldown header directive.
MyTarget->DirectiveInput.clear();
@@ -133,7 +133,7 @@ class HeaderDirectiveDrilldownInitializer : public Configurator {
}
};

class HeaderDirectiveSourceHeaderInitializer : public Configurator { // Initializes Source Header Directives.
class HeaderDirectiveSourceHeaderInitializer : public cd::Configurator { // Initializes Source Header Directives.
private:

HeaderDirectiveHandler* MyTarget; // Needs to know it's target.
@@ -144,7 +144,7 @@ class HeaderDirectiveSourceHeaderInitializer : public Configurator {

void setTarget(HeaderDirectiveHandler& H) { MyTarget = &H; } // We have a way to set the target though ;-)

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator() function goes to the
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator() function goes to the
if(NULL!=MyTarget) { // target (if it's set) and sets it up
MyTarget->ContextInput.clear(); // for a context sensitive source header
MyTarget->DirectiveInput.clear(); // directive. Activation context as well
@@ -186,10 +186,10 @@ class RangePoint {
}
};

class RangeHandler : public Configurator { // The handler adds edgepoints and holds and
class RangeHandler : public cd::Configurator { // The handler adds edgepoints and holds and
public: // tests the set that defines the region.

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The () operator adds EdgeInput to the list.
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The () operator adds EdgeInput to the list.
EdgeMap.insert(EdgeInput);
}

@@ -207,7 +207,7 @@ class RangeHandler : public Configurator {

};

class RangeInitializer : public Configurator { // The RangeInitializer Configurator.
class RangeInitializer : public cd::Configurator { // The RangeInitializer Configurator.
private:

RangeHandler* MyTarget; // Needs to know it's target.
@@ -218,16 +218,16 @@ class RangeInitializer : public Configurator {

void setTarget(RangeHandler& H) { MyTarget = &H; } // We have a way to set the target though ;-)

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The configurator() function goes to the
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The configurator() function goes to the
if(NULL!=MyTarget) { // target (if it's set) and pushes the
MyTarget->reset(); // reset button.
}
}
};

class IntegerSetHandler : public Configurator { // Integer set handler for rule panics.
class IntegerSetHandler : public cd::Configurator { // Integer set handler for rule panics.
public:
void operator()(ConfigurationElement& E, ConfigurationData& D) { // The operator() inserts IntegerInput
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The operator() inserts IntegerInput
IntegerSet.insert(IntegerInput); // if it's not already a member.
}

@@ -239,7 +239,7 @@ class IntegerSetHandler : public Configurator {
void reset() { IntegerSet.clear(); } // How to reset (clear) the list.
};

class IntegerSetInitializer : public Configurator { // The initializer resets the set.
class IntegerSetInitializer : public cd::Configurator { // The initializer resets the set.
private:

IntegerSetHandler* MyTarget; // It needs to know which set to init.
@@ -250,7 +250,7 @@ class IntegerSetInitializer : public Configurator {

void setTarget(IntegerSetHandler& H) { MyTarget = &H; } // Set a pointer to the handler.

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The operator() does the trick.
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The operator() does the trick.
if(NULL!=MyTarget) {
MyTarget->reset();
}
@@ -270,7 +270,7 @@ class XHDRSymbol {
} // in this case.
};

class XHDRSymbolsHandler : public Configurator { // XHDRSymbol hander.
class XHDRSymbolsHandler : public cd::Configurator { // XHDRSymbol hander.
public:
set<XHDRSymbol> SymbolHeaders; // Carries a set of Symbol Headers.

@@ -289,14 +289,14 @@ class XHDRSymbolsHandler : public Configurator {
int Symbol; // Input Symbol value.
string Header; // Input Header value.

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The operator() inserts an XHDRSymbol
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The operator() inserts an XHDRSymbol
if(OnOff) { // if the header entry is turned on and
SymbolHeaders.insert(XHDRSymbol(Symbol, Header)); // if it's not already a member.
}
}
};

class XHDRSymbolsInitializer : public Configurator { // The XHDRSymbols initializer.
class XHDRSymbolsInitializer : public cd::Configurator { // The XHDRSymbols initializer.
private:

XHDRSymbolsHandler* MyTarget; // It needs to know which set to init.
@@ -307,7 +307,7 @@ class XHDRSymbolsInitializer : public Configurator {

void setTarget(XHDRSymbolsHandler& H) { MyTarget = &H; } // Set a pointer to the handler.

void operator()(ConfigurationElement& E, ConfigurationData& D) { // The operator() does the trick.
void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The operator() does the trick.
if(NULL!=MyTarget) {
MyTarget->reset();
}
@@ -336,7 +336,7 @@ const int LogOutputMode_Inject = 3;
class snfCFGData { // Object that stores our config data.
private:

ConfigurationElement MyCFGReader; // This is how we read our cfg data.
cd::ConfigurationElement MyCFGReader; // This is how we read our cfg data.

public:


Loading…
Cancel
Save