OpenDDS  Snapshot(2023/04/07-19:43)
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
OpenDDS::Security::Governance Class Reference

#include <Governance.h>

Inheritance diagram for OpenDDS::Security::Governance:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::Security::Governance:
Collaboration graph
[legend]

Classes

struct  DomainRule
 
struct  TopicAccessRule
 

Public Types

typedef DCPS::RcHandle< Governanceshared_ptr
 
typedef std::vector< TopicAccessRuleTopicAccessRules
 
typedef std::vector< DomainRuleGovernanceAccessRules
 

Public Member Functions

 Governance ()
 
int load (const SSL::SignedDocument &doc)
 
GovernanceAccessRulesaccess_rules ()
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Private Attributes

GovernanceAccessRules access_rules_
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Detailed Description

Definition at line 24 of file Governance.h.

Member Typedef Documentation

◆ GovernanceAccessRules

Definition at line 44 of file Governance.h.

◆ shared_ptr

Definition at line 26 of file Governance.h.

◆ TopicAccessRules

Definition at line 36 of file Governance.h.

Constructor & Destructor Documentation

◆ Governance()

OpenDDS::Security::Governance::Governance ( )

Member Function Documentation

◆ access_rules()

GovernanceAccessRules& OpenDDS::Security::Governance::access_rules ( )
inline

Definition at line 50 of file Governance.h.

References access_rules_.

51  {
52  return access_rules_;
53  }
GovernanceAccessRules access_rules_
Definition: Governance.h:56

◆ load()

int OpenDDS::Security::Governance::load ( const SSL::SignedDocument doc)

Definition at line 112 of file Governance.cpp.

References OpenDDS::DCPS::SecurityDebug::access_error, ACE_ERROR, ACE_TEXT(), ACE_TEXT_CHAR_TO_TCHAR, DDS::Security::ParticipantSecurityAttributes::allow_unauthenticated_participants, OpenDDS::Security::SSL::SignedDocument::content(), OpenDDS::Security::Governance::TopicAccessRule::data_protection_kind, OpenDDS::Security::Governance::DomainRule::domain_attrs, OpenDDS::Security::Governance::DomainRule::domains, OpenDDS::Security::SSL::SignedDocument::filename(), OpenDDS::Security::XmlUtils::get_parser(), DDS::Security::ParticipantSecurityAttributes::is_access_protected, DDS::Security::ParticipantSecurityAttributes::is_discovery_protected, DDS::Security::TopicSecurityAttributes::is_discovery_protected, DDS::Security::ParticipantSecurityAttributes::is_liveliness_protected, DDS::Security::TopicSecurityAttributes::is_liveliness_protected, DDS::Security::TopicSecurityAttributes::is_read_protected, DDS::Security::ParticipantSecurityAttributes::is_rtps_protected, DDS::Security::TopicSecurityAttributes::is_write_protected, LM_ERROR, OpenDDS::Security::Governance::TopicAccessRule::metadata_protection_kind, name, OPENDDS_END_VERSIONED_NAMESPACE_DECL, OpenDDS::Security::XmlUtils::parse_domain_id_set(), DDS::Security::ParticipantSecurityAttributes::plugin_participant_attributes, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_BUILTIN_IS_DISCOVERY_ENCRYPTED, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_DISCOVERY_ORIGIN_AUTHENTICATED, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_LIVELINESS_ENCRYPTED, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_LIVELINESS_ORIGIN_AUTHENTICATED, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_RTPS_ENCRYPTED, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_RTPS_ORIGIN_AUTHENTICATED, DDS::Security::PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_VALID, OpenDDS::DCPS::security_debug, OpenDDS::Security::XmlUtils::to_string(), OpenDDS::Security::Governance::TopicAccessRule::topic_attrs, OpenDDS::Security::Governance::TopicAccessRule::topic_expression, and OpenDDS::Security::Governance::DomainRule::topic_rules.

113 {
114  const std::string& xml = doc.content();
115  ParserPtr parser;
116  if (!get_parser(parser, doc.filename(), xml)) {
118  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} Governance::load: "
119  "get_parser failed\n"));
120  }
121  return -1;
122  }
123 
124  // Find the domain rules
125  const xercesc::DOMNodeList* const domainRules = parser->getDocument()->getDocumentElement()->
126  getElementsByTagName(XStr(ACE_TEXT("domain_rule")));
127  for (XMLSize_t r = 0, dr_len = domainRules->getLength(); r < dr_len; ++r) {
128  Governance::DomainRule domain_rule;
129  domain_rule.domain_attrs.plugin_participant_attributes = 0;
130  const xercesc::DOMElement* const domain_rule_el =
131  dynamic_cast<const xercesc::DOMElement*>(domainRules->item(r));
132  if (!domain_rule_el) {
134  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} Governance::load: "
135  "domain_rule_el is null\n"));
136  }
137  return -1;
138  }
139 
140  // Process domain ids this domain rule applies to
141  const xercesc::DOMNodeList* const ruleNodes = domain_rule_el->getChildNodes();
142  for (XMLSize_t rn = 0, rn_len = ruleNodes->getLength(); rn < rn_len; rn++) {
143  const xercesc::DOMNode* const ruleNode = ruleNodes->item(rn);
144  const XStr dn_tag = ruleNode->getNodeName();
145  if (ACE_TEXT("domains") == dn_tag) {
146  if (!parse_domain_id_set(ruleNode, domain_rule.domains)) {
148  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} Governance::load: "
149  "failed to process domain ids in \"%C\"\n",
150  doc.filename().c_str()));
151  }
152  return -1;
153  }
154  }
155  }
156 
157  // Process allow_unauthenticated_participants
158  if (!get_bool_tag(doc, domain_rule_el, ACE_TEXT("allow_unauthenticated_participants"),
159  domain_rule.domain_attrs.allow_unauthenticated_participants)) {
160  return -1;
161  }
162 
163  // Process enable_join_access_control
164  if (!get_bool_tag(doc, domain_rule_el, ACE_TEXT("enable_join_access_control"),
165  domain_rule.domain_attrs.is_access_protected)) {
166  return -1;
167  }
168 
169  // Process discovery_protection_kind
170  if (!get_protection_kind(doc, domain_rule_el, ACE_TEXT("discovery_protection_kind"),
171  domain_rule.domain_attrs.is_discovery_protected,
172  domain_rule.domain_attrs.plugin_participant_attributes,
175  return -1;
176  }
177 
178  // Process liveliness_protection_kind
179  if (!get_protection_kind(doc, domain_rule_el, ACE_TEXT("liveliness_protection_kind"),
180  domain_rule.domain_attrs.is_liveliness_protected,
181  domain_rule.domain_attrs.plugin_participant_attributes,
184  return -1;
185  }
186 
187  // Process rtps_protection_kind
188  if (!get_protection_kind(doc, domain_rule_el, ACE_TEXT("rtps_protection_kind"),
189  domain_rule.domain_attrs.is_rtps_protected,
190  domain_rule.domain_attrs.plugin_participant_attributes,
193  return -1;
194  }
195 
196  domain_rule.domain_attrs.plugin_participant_attributes |=
198 
199  // Process topic rules
200  const xercesc::DOMNodeList* topic_rules =
201  domain_rule_el->getElementsByTagName(XStr(ACE_TEXT("topic_rule")));
202  for (XMLSize_t tr = 0, tr_len = topic_rules->getLength(); tr < tr_len; tr++) {
203  const xercesc::DOMNode* topic_rule = topic_rules->item(tr);
204  const xercesc::DOMNodeList* topic_rule_nodes = topic_rule->getChildNodes();
205  Governance::TopicAccessRule t_rules;
206  for (XMLSize_t trn = 0, trn_len = topic_rule_nodes->getLength(); trn < trn_len; trn++) {
207  const xercesc::DOMNode* topic_rule_node = topic_rule_nodes->item(trn);
208  const std::string name = to_string(topic_rule_node->getNodeName());
209 
210  bool* bool_value = 0;
211  if (name == "topic_expression") {
212  t_rules.topic_expression = to_string(topic_rule_node);
213  } else if (name == "enable_discovery_protection") {
214  bool_value = &t_rules.topic_attrs.is_discovery_protected;
215  } else if (name == "enable_liveliness_protection") {
216  bool_value = &t_rules.topic_attrs.is_liveliness_protected;
217  } else if (name == "enable_read_access_control") {
218  bool_value = &t_rules.topic_attrs.is_read_protected;
219  } else if (name == "enable_write_access_control") {
220  bool_value = &t_rules.topic_attrs.is_write_protected;
221  } else if (name == "metadata_protection_kind") {
222  t_rules.metadata_protection_kind = to_string(topic_rule_node);
223  } else if (name == "data_protection_kind") {
224  t_rules.data_protection_kind = to_string(topic_rule_node);
225  }
226 
227  if (bool_value && !get_bool_tag_value(doc, topic_rule_node,
228  ACE_TEXT_CHAR_TO_TCHAR(name.c_str()), *bool_value)) {
229  return -1;
230  }
231  }
232  domain_rule.topic_rules.push_back(t_rules);
233  }
234 
235  access_rules_.push_back(domain_rule);
236  } // domain_rule
237 
238  return 0;
239 }
#define ACE_ERROR(X)
DCPS::unique_ptr< xercesc::XercesDOMParser > ParserPtr
Definition: XmlUtils.h:32
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_RTPS_ORIGIN_AUTHENTICATED
GovernanceAccessRules access_rules_
Definition: Governance.h:56
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_LIVELINESS_ENCRYPTED
const char * to_string(MessageId value)
#define ACE_TEXT_CHAR_TO_TCHAR(STRING)
const char *const name
Definition: debug.cpp:60
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_DISCOVERY_ORIGIN_AUTHENTICATED
ACE_TEXT("TCP_Factory")
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_BUILTIN_IS_DISCOVERY_ENCRYPTED
bool parse_domain_id_set(const xercesc::DOMNode *node, Security::DomainIdSet &domain_id_set)
Definition: XmlUtils.cpp:445
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_RTPS_ENCRYPTED
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_LIVELINESS_ORIGIN_AUTHENTICATED
OpenDDS_Dcps_Export SecurityDebug security_debug
Definition: debug.cpp:32
bool get_parser(ParserPtr &parser, const std::string &filename, const std::string &xml)
Definition: XmlUtils.cpp:71
bool access_error
Permissions and Governance.
Definition: debug.h:132
const ParticipantSecurityAttributesMask PLUGIN_PARTICIPANT_SECURITY_ATTRIBUTES_FLAG_IS_VALID

Member Data Documentation

◆ access_rules_

GovernanceAccessRules OpenDDS::Security::Governance::access_rules_
private

Definition at line 56 of file Governance.h.

Referenced by access_rules().


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