diff --git a/sros2/sros2/api/__init__.py b/sros2/sros2/api/__init__.py
index cb8d20c3..b5cc7a76 100644
--- a/sros2/sros2/api/__init__.py
+++ b/sros2/sros2/api/__init__.py
@@ -197,15 +197,15 @@ def create_ca_key_cert(ecdsa_param_path, ca_conf_path, ca_key_path, ca_cert_path
(openssl_executable, ecdsa_param_path, ca_key_path, ca_cert_path, ca_conf_path))
-def create_governance_file(path, domain_id):
- # for this application we are only looking to authenticate and encrypt;
- # we do not need/want access control at this point.
- governance_xml_path = get_transport_default('dds', 'governance.xml')
- governance_xml = etree.parse(governance_xml_path)
-
+def create_governance_file(path, domain_id, policy_element):
governance_xsd_path = get_transport_schema('dds', 'governance.xsd')
governance_xsd = etree.XMLSchema(etree.parse(governance_xsd_path))
+ governance_xsl_path = get_transport_template('dds', 'governance.xsl')
+ governance_xsl = etree.XSLT(etree.parse(governance_xsl_path))
+
+ governance_xml = governance_xsl(policy_element)
+
domain_id_elements = governance_xml.findall(
'domain_access_rules/domain_rule/domains/id')
for domain_id_element in domain_id_elements:
@@ -220,7 +220,7 @@ def create_governance_file(path, domain_id):
f.write(etree.tostring(governance_xml, pretty_print=True))
-def create_signed_governance_file(signed_gov_path, gov_path, ca_cert_path, ca_key_path):
+def create_signed_governance_file(gov_path, signed_gov_path, ca_cert_path, ca_key_path):
openssl_executable = find_openssl_executable()
check_openssl_version(openssl_executable)
run_shell_command(
@@ -257,23 +257,6 @@ def create_keystore(keystore_path):
else:
print('found CA key and cert, not creating new ones!')
- # create governance file
- gov_path = os.path.join(keystore_path, 'governance.xml')
- if not os.path.isfile(gov_path):
- print('creating governance file: %s' % gov_path)
- domain_id = os.getenv(DOMAIN_ID_ENV, '0')
- create_governance_file(gov_path, domain_id)
- else:
- print('found governance file, not creating a new one!')
-
- # sign governance file
- signed_gov_path = os.path.join(keystore_path, 'governance.p7s')
- if not os.path.isfile(signed_gov_path):
- print('creating signed governance file: %s' % signed_gov_path)
- create_signed_governance_file(signed_gov_path, gov_path, ca_cert_path, ca_key_path)
- else:
- print('found signed governance file, not creating a new one!')
-
# create index file
index_path = os.path.join(keystore_path, 'index.txt')
if not os.path.isfile(index_path):
@@ -297,7 +280,6 @@ def is_valid_keystore(path):
res &= os.path.isfile(os.path.join(path, 'index.txt'))
res &= os.path.isfile(os.path.join(path, 'ca.key.pem'))
res &= os.path.isfile(os.path.join(path, 'ca.cert.pem'))
- res &= os.path.isfile(os.path.join(path, 'governance.p7s'))
return res
@@ -409,6 +391,7 @@ def create_signed_permissions_file(
def create_permission(keystore_path, identity, policy_file_path):
policy_element = get_policy(identity, policy_file_path)
create_permissions_from_policy_element(keystore_path, identity, policy_element)
+ create_governance_from_policy_element(keystore_path, identity, policy_element)
return True
@@ -428,6 +411,22 @@ def create_permissions_from_policy_element(keystore_path, identity, policy_eleme
keystore_ca_cert_path, keystore_ca_key_path)
+def create_governance_from_policy_element(keystore_path, identity, policy_element):
+ domain_id = os.getenv(DOMAIN_ID_ENV, '0')
+ relative_path = os.path.normpath(identity.lstrip('/'))
+ key_dir = os.path.join(keystore_path, relative_path)
+ print('key_dir %s' % key_dir)
+ governance_path = os.path.join(key_dir, 'governance.xml')
+ create_governance_file(governance_path, domain_id, policy_element)
+
+ signed_governance_path = os.path.join(key_dir, 'governance.p7s')
+ keystore_ca_cert_path = os.path.join(keystore_path, 'ca.cert.pem')
+ keystore_ca_key_path = os.path.join(keystore_path, 'ca.key.pem')
+ create_signed_governance_file(
+ governance_path, signed_governance_path,
+ keystore_ca_cert_path, keystore_ca_key_path)
+
+
def create_key(keystore_path, identity):
if not is_valid_keystore(keystore_path):
print("'%s' is not a valid keystore " % keystore_path)
@@ -447,10 +446,10 @@ def create_key(keystore_path, identity):
shutil.copyfile(keystore_ca_cert_path, dest_identity_ca_cert_path)
shutil.copyfile(keystore_ca_cert_path, dest_permissions_ca_cert_path)
- # copy the governance file in there
- keystore_governance_path = os.path.join(keystore_path, 'governance.p7s')
- dest_governance_path = os.path.join(key_dir, 'governance.p7s')
- shutil.copyfile(keystore_governance_path, dest_governance_path)
+ # # copy the governance file in there
+ # keystore_governance_path = os.path.join(keystore_path, 'governance.p7s')
+ # dest_governance_path = os.path.join(key_dir, 'governance.p7s')
+ # shutil.copyfile(keystore_governance_path, dest_governance_path)
ecdsa_param_path = os.path.join(key_dir, 'ecdsaparam')
if not os.path.isfile(ecdsa_param_path):
@@ -505,6 +504,15 @@ def create_key(keystore_path, identity):
permissions_path, signed_permissions_path,
keystore_ca_cert_path, keystore_ca_key_path)
+ governance_path = os.path.join(key_dir, 'governance.xml')
+ create_governance_file(governance_path, domain_id, policy_element)
+ signed_governance_path = os.path.join(key_dir, 'governance.p7s')
+ keystore_ca_key_path = os.path.join(keystore_path, 'ca.key.pem')
+ create_signed_governance_file(
+ governance_path, signed_governance_path,
+ keystore_ca_cert_path, keystore_ca_key_path)
+
+
return True
@@ -550,4 +558,6 @@ def generate_artifacts(keystore_path=None, identity_names=[], policy_files=[]):
policy_element = get_policy_from_tree(identity_name, policy_tree)
create_permissions_from_policy_element(
keystore_path, identity_name, policy_element)
+ create_governance_from_policy_element(
+ keystore_path, identity_name, policy_element)
return True
diff --git a/sros2/sros2/policy/defaults/dds/governance.xml b/sros2/sros2/policy/defaults/dds/governance.xml
index 24aedcbe..e0d80f08 100644
--- a/sros2/sros2/policy/defaults/dds/governance.xml
+++ b/sros2/sros2/policy/defaults/dds/governance.xml
@@ -8,8 +8,8 @@
false
true
- ENCRYPT
- ENCRYPT
+ SIGN
+ SIGN
SIGN
@@ -18,7 +18,7 @@
true
true
true
- ENCRYPT
+ SIGN
ENCRYPT
diff --git a/sros2/sros2/policy/defaults/policy.xml b/sros2/sros2/policy/defaults/policy.xml
index 552a2055..efcdb8f0 100644
--- a/sros2/sros2/policy/defaults/policy.xml
+++ b/sros2/sros2/policy/defaults/policy.xml
@@ -2,13 +2,13 @@
-
+
/*
-
+
/*
-
+
/*
diff --git a/sros2/sros2/policy/schemas/policy.xsd b/sros2/sros2/policy/schemas/policy.xsd
index 8086516e..93f576f7 100644
--- a/sros2/sros2/policy/schemas/policy.xsd
+++ b/sros2/sros2/policy/schemas/policy.xsd
@@ -40,6 +40,7 @@
+
@@ -49,6 +50,7 @@
+
@@ -58,6 +60,7 @@
+
@@ -72,4 +75,12 @@
+
+
+
+
+
+
+
+
diff --git a/sros2/sros2/policy/templates/dds/governance.xsl b/sros2/sros2/policy/templates/dds/governance.xsl
new file mode 100644
index 00000000..a9d601cc
--- /dev/null
+++ b/sros2/sros2/policy/templates/dds/governance.xsl
@@ -0,0 +1,202 @@
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ true
+ SIGN
+ SIGN
+ SIGN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+ rt
+
+
+
+
+
+
+
+
+
+
+
+
+
+ rqRequest
+
+
+
+
+
+ rrReply
+
+
+
+
+
+
+
+
+
+
+
+
+
+ rq/_action/cancel_goalRequest
+
+
+
+
+
+ rr/_action/cancel_goalReply
+
+
+
+
+
+ rq/_action/get_resultRequest
+
+
+
+
+
+ rr/_action/get_resultReply
+
+
+
+
+
+ rq/_action/send_goalRequest
+
+
+
+
+
+ rr/_action/send_goalReply
+
+
+
+
+
+ rt/_action/feedback
+
+
+
+
+
+ rt/_action/status
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sros2/test/policies/add_two_ints.xml b/sros2/test/policies/add_two_ints.xml
index 9becfffd..0fa4685e 100644
--- a/sros2/test/policies/add_two_ints.xml
+++ b/sros2/test/policies/add_two_ints.xml
@@ -5,14 +5,14 @@
-
+
add_two_ints
-
+
add_two_ints
diff --git a/sros2/test/policies/common/node/logging.xml b/sros2/test/policies/common/node/logging.xml
index c7fb80ae..10679736 100644
--- a/sros2/test/policies/common/node/logging.xml
+++ b/sros2/test/policies/common/node/logging.xml
@@ -1,6 +1,6 @@
-
+
rosout
diff --git a/sros2/test/policies/common/node/parameters.xml b/sros2/test/policies/common/node/parameters.xml
index f6ef2bb6..c8eb937a 100644
--- a/sros2/test/policies/common/node/parameters.xml
+++ b/sros2/test/policies/common/node/parameters.xml
@@ -1,10 +1,10 @@
-
+
parameter_events
-
+
~describe_parameters
~get_parameter_types
~get_parameters
diff --git a/sros2/test/policies/common/node/time.xml b/sros2/test/policies/common/node/time.xml
index 2b36c72d..8f2413ec 100644
--- a/sros2/test/policies/common/node/time.xml
+++ b/sros2/test/policies/common/node/time.xml
@@ -1,6 +1,6 @@
-
+
/clock
diff --git a/sros2/test/policies/minimal_action.xml b/sros2/test/policies/minimal_action.xml
index f8e0f10f..d456b615 100644
--- a/sros2/test/policies/minimal_action.xml
+++ b/sros2/test/policies/minimal_action.xml
@@ -5,14 +5,14 @@
-
+
fibonacci
-
+
fibonacci
diff --git a/sros2/test/policies/sample_policy.xml b/sros2/test/policies/sample_policy.xml
index 589a05e3..f2f2f6ff 100644
--- a/sros2/test/policies/sample_policy.xml
+++ b/sros2/test/policies/sample_policy.xml
@@ -11,13 +11,13 @@
-
+
fibonacci
-
+
add_two_ints
-
+
chatter
diff --git a/sros2/test/policies/talker_listener.xml b/sros2/test/policies/talker_listener.xml
index 88709bd9..ff61de19 100644
--- a/sros2/test/policies/talker_listener.xml
+++ b/sros2/test/policies/talker_listener.xml
@@ -5,14 +5,14 @@
-
+
chatter
-
+
chatter