From 7c643055b4892c523558a3fe863873640454a431 Mon Sep 17 00:00:00 2001 From: Marc Lepage Date: Mon, 4 Apr 2022 20:14:33 -0400 Subject: [PATCH] Support remove fabric for access control extension Extension attribute needs its fabric scoped data removed when the fabric is removed. Part of issue #10252 --- .../access-control-server.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/app/clusters/access-control-server/access-control-server.cpp b/src/app/clusters/access-control-server/access-control-server.cpp index 537f9c9fb2e185..1e74fc875974e6 100644 --- a/src/app/clusters/access-control-server/access-control-server.cpp +++ b/src/app/clusters/access-control-server/access-control-server.cpp @@ -705,9 +705,27 @@ CHIP_ERROR AccessControlAttribute::WriteExtension(const ConcreteDataAttributePat AccessControlAttribute gAttribute; +class : public FabricTableDelegate +{ +public: + void OnFabricDeletedFromStorage(CompressedFabricId compressedId, FabricIndex fabricIndex) override + { + auto & storage = Server::GetInstance().GetPersistentStorage(); + DefaultStorageKeyAllocator key; + storage.SyncDeleteKeyValue(key.AccessControlExtensionEntry(fabricIndex)); + } + void OnFabricRetrievedFromStorage(FabricInfo * fabricInfo) override {} + void OnFabricPersistedToStorage(FabricInfo * fabricInfo) override {} + +} fabricTableDelegate; + } // namespace void MatterAccessControlPluginServerInitCallback() { + ChipLogProgress(DataManagement, "AccessControlCluster: initializing"); + registerAttributeAccessOverride(&gAttribute); + + Server::GetInstance().GetFabricTable().AddFabricDelegate(&fabricTableDelegate); }