diff --git a/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp b/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp index e9dc39d2..443f0138 100644 --- a/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp +++ b/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp @@ -75,7 +75,7 @@ bool AuthorizationService::loadLists() { } AuthorizationData *AuthorizationService::getLocalAuthorization(const char *idTag) { - if (!localAuthListEnabledBool->getBool()) { + if (!localAuthListEnabled()) { return nullptr; //auth cache will follow } @@ -101,6 +101,10 @@ size_t AuthorizationService::getLocalListSize() { return localAuthorizationList.size(); } +bool AuthorizationService::localAuthListEnabled() const { + return localAuthListEnabledBool && localAuthListEnabledBool->getBool(); +} + bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson, int listVersion, bool differential) { bool success = localAuthorizationList.readJson(localAuthorizationListJson, listVersion, differential, false); @@ -127,7 +131,7 @@ bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson, void AuthorizationService::notifyAuthorization(const char *idTag, JsonObject idTagInfo) { //check local list conflicts. In future: also update authorization cache - if (!localAuthListEnabledBool->getBool()) { + if (!localAuthListEnabled()) { return; //auth cache will follow } diff --git a/src/MicroOcpp/Model/Authorization/AuthorizationService.h b/src/MicroOcpp/Model/Authorization/AuthorizationService.h index 88ba7936..536bba1f 100644 --- a/src/MicroOcpp/Model/Authorization/AuthorizationService.h +++ b/src/MicroOcpp/Model/Authorization/AuthorizationService.h @@ -35,6 +35,7 @@ class AuthorizationService : public MemoryManaged { AuthorizationData *getLocalAuthorization(const char *idTag); int getLocalListVersion(); + bool localAuthListEnabled() const; size_t getLocalListSize(); //number of entries in current localAuthList; used in unit tests bool updateLocalList(JsonArray localAuthorizationListJson, int listVersion, bool differential); diff --git a/src/MicroOcpp/Model/Model.cpp b/src/MicroOcpp/Model/Model.cpp index f2e19c1e..fe59568f 100644 --- a/src/MicroOcpp/Model/Model.cpp +++ b/src/MicroOcpp/Model/Model.cpp @@ -317,7 +317,7 @@ void Model::updateSupportedStandardProfiles() { } #if MO_ENABLE_LOCAL_AUTH - if (authorizationService) { + if (authorizationService && authorizationService->localAuthListEnabled()) { if (!strstr(supportedFeatureProfilesString->getString(), "LocalAuthListManagement")) { if (!buf.empty()) buf += ','; buf += "LocalAuthListManagement"; diff --git a/src/MicroOcpp/Operations/GetLocalListVersion.cpp b/src/MicroOcpp/Operations/GetLocalListVersion.cpp index f2c8a058..4c2d4688 100644 --- a/src/MicroOcpp/Operations/GetLocalListVersion.cpp +++ b/src/MicroOcpp/Operations/GetLocalListVersion.cpp @@ -30,9 +30,11 @@ std::unique_ptr GetLocalListVersion::createConf(){ auto doc = makeJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1)); JsonObject payload = doc->to(); - if (auto authService = model.getAuthorizationService()) { + auto authService = model.getAuthorizationService(); + if (authService && authService->localAuthListEnabled()) { payload["listVersion"] = authService->getLocalListVersion(); } else { + //TC_042_1_CS Get Local List Version (not supported) payload["listVersion"] = -1; } return doc; diff --git a/src/MicroOcpp/Operations/SendLocalList.cpp b/src/MicroOcpp/Operations/SendLocalList.cpp index 45f0dfbe..29890024 100644 --- a/src/MicroOcpp/Operations/SendLocalList.cpp +++ b/src/MicroOcpp/Operations/SendLocalList.cpp @@ -27,6 +27,12 @@ const char* SendLocalList::getOperationType(){ void SendLocalList::processReq(JsonObject payload) { + //TC_043_1_CS Send Local Authorization List - NotSupported + if (!authService.localAuthListEnabled()) { + errorCode = "NotSupported"; + return; + } + if (!payload.containsKey("listVersion") || !payload.containsKey("updateType")) { errorCode = "FormationViolation"; return;