OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Public Attributes | List of all members
OpenDDS::Security::Permissions::Action Struct Reference

#include <Permissions.h>

Collaboration diagram for OpenDDS::Security::Permissions::Action:
Collaboration graph
[legend]

Public Member Functions

bool topic_matches (const char *topic) const
 
bool partitions_match (const DDS::StringSeq &entity_partitions, AllowDeny_t allow_or_deny) const
 

Public Attributes

PublishSubscribe_t ps_type
 
std::vector< std::string > topics
 
std::vector< std::string > partitions
 

Detailed Description

Definition at line 47 of file Permissions.h.

Member Function Documentation

◆ partitions_match()

bool OpenDDS::Security::Permissions::Action::partitions_match ( const DDS::StringSeq entity_partitions,
AllowDeny_t  allow_or_deny 
) const

Definition at line 232 of file Permissions.cpp.

References OpenDDS::Security::Permissions::ALLOW, OpenDDS::Security::Permissions::DENY, OPENDDS_END_VERSIONED_NAMESPACE_DECL, and OpenDDS::Security::AccessControlBuiltInImpl::pattern_match().

233 {
234  const unsigned int n_entity_names = entity_partitions.length();
235  if (partitions.empty()) {
236  if (allow_or_deny == DENY) {
237  // DDS-Security v1.1 9.4.1.3.2.3.2.4
238  // If there is no <partitions> section ... the deny action would
239  // apply independent of the partition associated with the DDS Endpoint
240  return true;
241  }
242  // DDS-Security v1.1 9.4.1.3.2.3.1.4
243  // If there is no <partitions> Section within an allow rule, then the default "empty string" partition is
244  // assumed. ... This means that the allow rule would only allow a DataWriter to publish on
245  // the "empty string" partition.
246  // DDS v1.4 2.2.3 "PARTITION"
247  // The zero-length sequence is treated as a special value equivalent to a sequence containing a single
248  // element consisting of the empty string.
249  return n_entity_names == 0 || (n_entity_names == 1 && entity_partitions[0].in()[0] == 0);
250  }
251 
252  for (unsigned int i = 0; i < n_entity_names; ++i) {
253  bool found = false;
254  for (vsiter_t perm_it = partitions.begin(); !found && perm_it != partitions.end(); ++perm_it) {
255  if (AccessControlBuiltInImpl::pattern_match(entity_partitions[i], perm_it->c_str())) {
256  found = true;
257  }
258  }
259  if (allow_or_deny == ALLOW && !found) {
260  // DDS-Security v1.1 9.4.1.3.2.3.1.4
261  // In order for an action to meet the allowed partitions condition that appears
262  // within an allow rule, the set of the Partitions associated with the DDS entity
263  // ... must be contained in the set of partitions defined by the allowed partitions
264  // condition section.
265  return false; // i'th QoS partition name is not matched by any <partition> in Permissions
266  }
267  if (allow_or_deny == DENY && found) {
268  // DDS-Security v1.1 9.4.1.3.2.3.2.4
269  // In order for an action to be denied it must meet the denied partitions condition.
270  // For this to happen one [or] more of the partition names associated with the DDS Entity
271  // ... must match one [of] the partitions ... listed in the partitions condition section.
272  return true; // i'th QoS partition name matches some <partition> in Permissions
273  }
274  }
275 
276  return allow_or_deny == ALLOW;
277 }
static bool pattern_match(const char *string, const char *pattern)
std::vector< std::string > partitions
Definition: Permissions.h:50

◆ topic_matches()

bool OpenDDS::Security::Permissions::Action::topic_matches ( const char *  topic) const

Definition at line 222 of file Permissions.cpp.

References OpenDDS::Security::AccessControlBuiltInImpl::pattern_match().

223 {
224  for (vsiter_t it = topics.begin(); it != topics.end(); ++it) {
225  if (AccessControlBuiltInImpl::pattern_match(topic, it->c_str())) {
226  return true;
227  }
228  }
229  return false;
230 }
std::vector< std::string > topics
Definition: Permissions.h:49
static bool pattern_match(const char *string, const char *pattern)

Member Data Documentation

◆ partitions

std::vector<std::string> OpenDDS::Security::Permissions::Action::partitions

Definition at line 50 of file Permissions.h.

Referenced by OpenDDS::Security::Permissions::load().

◆ ps_type

PublishSubscribe_t OpenDDS::Security::Permissions::Action::ps_type

Definition at line 48 of file Permissions.h.

Referenced by OpenDDS::Security::Permissions::load().

◆ topics

std::vector<std::string> OpenDDS::Security::Permissions::Action::topics

Definition at line 49 of file Permissions.h.

Referenced by OpenDDS::Security::Permissions::load().


The documentation for this struct was generated from the following files: