51
51
#include < app/codegen-data-model-provider/Instance.h>
52
52
#endif
53
53
54
+ #if !CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
55
+ #include < app/ember_coupling/EventPathValidity.mixin.h> // nogncheck
56
+ #endif
57
+
54
58
namespace chip {
55
59
namespace app {
56
60
@@ -544,105 +548,6 @@ CHIP_ERROR InteractionModelEngine::ParseAttributePaths(const Access::SubjectDesc
544
548
return err;
545
549
}
546
550
547
- #if !CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
548
- static bool CanAccessEvent (const Access::SubjectDescriptor & aSubjectDescriptor, const ConcreteClusterPath & aPath,
549
- Access::Privilege aNeededPrivilege)
550
- {
551
- Access::RequestPath requestPath{ .cluster = aPath.mClusterId ,
552
- .endpoint = aPath.mEndpointId ,
553
- .requestType = Access::RequestType::kEventReadRequest };
554
- // leave requestPath.entityId optional value unset to indicate wildcard
555
- CHIP_ERROR err = Access::GetAccessControl ().Check (aSubjectDescriptor, requestPath, aNeededPrivilege);
556
- return (err == CHIP_NO_ERROR);
557
- }
558
- #endif
559
-
560
- static bool CanAccessEvent (const Access::SubjectDescriptor & aSubjectDescriptor, const ConcreteEventPath & aPath)
561
- {
562
- Access::RequestPath requestPath{ .cluster = aPath.mClusterId ,
563
- .endpoint = aPath.mEndpointId ,
564
- .requestType = Access::RequestType::kEventReadRequest ,
565
- .entityId = aPath.mEventId };
566
- CHIP_ERROR err = Access::GetAccessControl ().Check (aSubjectDescriptor, requestPath, RequiredPrivilege::ForReadEvent (aPath));
567
- return (err == CHIP_NO_ERROR);
568
- }
569
-
570
- /* *
571
- * Helper to handle wildcard events in the event path.
572
- */
573
- static bool HasValidEventPathForEndpointAndCluster (EndpointId aEndpoint, const EmberAfCluster * aCluster,
574
- const EventPathParams & aEventPath,
575
- const Access::SubjectDescriptor & aSubjectDescriptor)
576
- {
577
- if (aEventPath.HasWildcardEventId ())
578
- {
579
- #if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
580
- for (decltype (aCluster->eventCount ) idx = 0 ; idx < aCluster->eventCount ; ++idx)
581
- {
582
- ConcreteEventPath path (aEndpoint, aCluster->clusterId , aCluster->eventList [idx]);
583
- // If we get here, the path exists. We just have to do an ACL check for it.
584
- bool isValid = CanAccessEvent (aSubjectDescriptor, path);
585
- if (isValid)
586
- {
587
- return true ;
588
- }
589
- }
590
-
591
- return false ;
592
- #else
593
- // We have no way to expand wildcards. Just assume that we would need
594
- // View permissions for whatever events are involved.
595
- ConcreteClusterPath clusterPath (aEndpoint, aCluster->clusterId );
596
- return CanAccessEvent (aSubjectDescriptor, clusterPath, Access::Privilege::kView );
597
- #endif
598
- }
599
-
600
- ConcreteEventPath path (aEndpoint, aCluster->clusterId , aEventPath.mEventId );
601
- if (CheckEventSupportStatus (path) != Status::Success)
602
- {
603
- // Not an existing event path.
604
- return false ;
605
- }
606
- return CanAccessEvent (aSubjectDescriptor, path);
607
- }
608
-
609
- /* *
610
- * Helper to handle wildcard clusters in the event path.
611
- */
612
- static bool HasValidEventPathForEndpoint (EndpointId aEndpoint, const EventPathParams & aEventPath,
613
- const Access::SubjectDescriptor & aSubjectDescriptor)
614
- {
615
- if (aEventPath.HasWildcardClusterId ())
616
- {
617
- auto * endpointType = emberAfFindEndpointType (aEndpoint);
618
- if (endpointType == nullptr )
619
- {
620
- // Not going to have any valid paths in here.
621
- return false ;
622
- }
623
-
624
- for (decltype (endpointType->clusterCount ) idx = 0 ; idx < endpointType->clusterCount ; ++idx)
625
- {
626
- bool hasValidPath =
627
- HasValidEventPathForEndpointAndCluster (aEndpoint, &endpointType->cluster [idx], aEventPath, aSubjectDescriptor);
628
- if (hasValidPath)
629
- {
630
- return true ;
631
- }
632
- }
633
-
634
- return false ;
635
- }
636
-
637
- auto * cluster = emberAfFindServerCluster (aEndpoint, aEventPath.mClusterId );
638
- if (cluster == nullptr )
639
- {
640
- // Nothing valid here.
641
- return false ;
642
- }
643
- return HasValidEventPathForEndpointAndCluster (aEndpoint, cluster, aEventPath, aSubjectDescriptor);
644
- }
645
-
646
551
CHIP_ERROR InteractionModelEngine::ParseEventPaths (const Access::SubjectDescriptor & aSubjectDescriptor,
647
552
EventPathIBs::Parser & aEventPathListParser, bool & aHasValidEventPath,
648
553
size_t & aRequestedEventPathCount)
@@ -670,6 +575,9 @@ CHIP_ERROR InteractionModelEngine::ParseEventPaths(const Access::SubjectDescript
670
575
continue ;
671
576
}
672
577
578
+ #if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
579
+ aHasValidEventPath = mDataModelProvider ->EventPathIncludesAccessibleConcretePath (eventPath, aSubjectDescriptor);
580
+ #else
673
581
// The definition of "valid path" is "path exists and ACL allows
674
582
// access". We need to do some expansion of wildcards to handle that.
675
583
if (eventPath.HasWildcardEndpointId ())
@@ -690,6 +598,7 @@ CHIP_ERROR InteractionModelEngine::ParseEventPaths(const Access::SubjectDescript
690
598
// emberAfFindEndpointType returns null for disabled endpoints.
691
599
aHasValidEventPath = HasValidEventPathForEndpoint (eventPath.mEndpointId , eventPath, aSubjectDescriptor);
692
600
}
601
+ #endif // CHIP_CONFIG_USE_EMBER_DATA_MODEL
693
602
}
694
603
695
604
if (err == CHIP_ERROR_END_OF_TLV)
0 commit comments