|
| 1 | +# Example Code: Dynamic Permissions |
| 2 | + |
| 3 | +## Concept |
| 4 | + |
| 5 | +This example showcases how the Security Plugins enforce Permissions Document |
| 6 | +expiration, and how the Permissions Document can be renewed to resume |
| 7 | +communication. |
| 8 | + |
| 9 | +## Building the Example |
| 10 | + |
| 11 | +Use the following commands to build the example and get the executables that |
| 12 | +you can run: |
| 13 | + |
| 14 | +```sh |
| 15 | +cd c++11/ |
| 16 | +mkdir build && cd build |
| 17 | +cmake .. |
| 18 | +cmake --build . |
| 19 | +``` |
| 20 | + |
| 21 | +You can optionally pass the |
| 22 | +``-DCONNEXTDDS_DIR=<your_connext_installation_directory>``, |
| 23 | +``-DOPENSSL_ROOT_DIR=<your_openssl_installation_directory>``, |
| 24 | +``-DCONNEXTDDS_ARCH=<your_architecture>``, |
| 25 | +``-DCMAKE_BUILD_TYPE=<Debug/Release>``, and |
| 26 | +``-DBUILD_SHARED_LIBS=<ON/OFF>`` variables to the cmake configuration step. |
| 27 | + |
| 28 | +After building the example, you will have a publisher Permissions Document that |
| 29 | +expires in 1 minute. If you need to re-create it, please remove this file from |
| 30 | +your build directory and re-run the ``createExpiringPermissions`` target. |
| 31 | + |
| 32 | +```sh |
| 33 | +rm security/ecdsa01/xml/Permissions2_expiring.xml && \ |
| 34 | + cmake --build . --target createExpiringPermissions |
| 35 | +``` |
| 36 | + |
| 37 | +## Running the example |
| 38 | + |
| 39 | +Demo is based on a standard rtiddsgen publisher and subscriber example code. |
| 40 | + |
| 41 | +Run a publisher and a subscriber in separate terminal windows. |
| 42 | + |
| 43 | +```sh |
| 44 | +./dynamic_permissions_publisher |
| 45 | +``` |
| 46 | + |
| 47 | +```sh |
| 48 | +./dynamic_permissions_subscriber |
| 49 | +``` |
| 50 | + |
| 51 | +Verify that they communicate and that the subscriber is receiving data. |
| 52 | + |
| 53 | +```sh |
| 54 | +# Publisher |
| 55 | +Writing ::DynamicPermissions, count 0 |
| 56 | +Writing ::DynamicPermissions, count 1 |
| 57 | +# [...] |
| 58 | + |
| 59 | +# Subscriber |
| 60 | +::DynamicPermissions subscriber sleeping up to 1 sec... |
| 61 | +[value: 0] |
| 62 | +::DynamicPermissions subscriber sleeping up to 1 sec... |
| 63 | +[value: 1] |
| 64 | +::DynamicPermissions subscriber sleeping up to 1 sec... |
| 65 | +# [...] |
| 66 | +``` |
| 67 | + |
| 68 | +Once the Permissions Document of the publisher DomainParticipant expires, you |
| 69 | +will see the following error messages: |
| 70 | + |
| 71 | +```sh |
| 72 | +# Publisher |
| 73 | +ERROR [0x831AB06E,0x43876C36,0xFD825600:0x000001C1|ADVANCE NOTIFY INVALID LOCAL PERMISSIONS|CHECK STATUS|LC:Security] RTI_Security_PermissionsGrant_isValidTime:{"DDS:Security:LogTopicV2":{"f":"10","s":"3","t":{"s":"1748517658","n":"108000"},"h":"RTISP-10036","i":"0.0.0.0","a":"RTI Secure DDS Application","p":"85264","k":"50331706","x":[{"DDS":[{"domain_id":"0"},{"guid":"831AB06E.43876C36.FD825600.000001C1"},{"plugin_class":"DDS:Access:Permissions"},{"plugin_method":"RTI_Security_PermissionsGrant_isValidTime"}]}],"m":"now is after not_after of permissions file"}} |
| 74 | +ERROR [0x831AB06E,0x43876C36,0xFD825600:0x000001C1|ADVANCE NOTIFY INVALID LOCAL PERMISSIONS|CHECK STATUS|LC:Security] RTI_Security_AccessControl_validate_status:{"DDS:Security:LogTopicV2":{"f":"10","s":"3","t":{"s":"1748517658","n":"192000"},"h":"RTISP-10036","i":"0.0.0.0","a":"RTI Secure DDS Application","p":"85264","k":"50331706","x":[{"DDS":[{"domain_id":"0"},{"guid":"831AB06E.43876C36.FD825600.000001C1"},{"plugin_class":"DDS:Access:Permissions"},{"plugin_method":"RTI_Security_AccessControl_validate_status"}]}],"m":"permissions' validity period is invalid."}} |
| 75 | +ERROR [0x831AB06E,0x43876C36,0xFD825600:0x000001C1|ADVANCE NOTIFY INVALID LOCAL PERMISSIONS|CHECK STATUS|LC:Security] PRESParticipant_onSecurityLocalCredentialValidateEvent:FAILED TO VALIDATE | Local permissions credentials. |
| 76 | +ERROR [0x831AB06E,0x43876C36,0xFD825600:0x000001C1|ADVANCE NOTIFY INVALID LOCAL PERMISSIONS|LC:Security] PRESParticipant_onSecurityLocalCredentialEventListener:FAILED TO VALIDATE | Local credentials. |
| 77 | + |
| 78 | +# Subscriber |
| 79 | +ERROR [PARSE MESSAGE|0xDED844B7,0x87B9550F,0xB66DD964:0x000201C4{Entity=DR,MessageKind=DATA}|RECEIVE FROM 0x831AB06E,0x43876C36,0xFD825600:0x000201C3|:0x000001C1{Domain=0}|RECEIVE SAMPLE|PROCESS HANDSHAKE|GET SECURITY STATE|LC:Security] RTI_Security_PermissionsGrant_isValidTime:{"DDS:Security:LogTopicV2":{"f":"10","s":"3","t":{"s":"1748517682","n":"984966998"},"h":"RTISP-10036","i":"0.0.0.0","a":"RTI Secure DDS Application","p":"85248","k":"50331706","x":[{"DDS":[{"domain_id":"0"},{"guid":"DED844B7.87B9550F.B66DD964.000001C1"},{"plugin_class":"DDS:Access:Permissions"},{"plugin_method":"RTI_Security_PermissionsGrant_isValidTime"}]}],"m":"now is after not_after of permissions file"}} |
| 80 | +ERROR [PARSE MESSAGE|0xDED844B7,0x87B9550F,0xB66DD964:0x000201C4{Entity=DR,MessageKind=DATA}|RECEIVE FROM 0x831AB06E,0x43876C36,0xFD825600:0x000201C3|:0x000001C1{Domain=0}|RECEIVE SAMPLE|PROCESS HANDSHAKE|GET SECURITY STATE|LC:Security] RTI_Security_AccessControl_validatePermissionsDocument:{"DDS:Security:LogTopicV2":{"f":"10","s":"3","t":{"s":"1748517682","n":"985028998"},"h":"RTISP-10036","i":"0.0.0.0","a":"RTI Secure DDS Application","p":"85248","k":"50331706","x":[{"DDS":[{"domain_id":"0"},{"guid":"DED844B7.87B9550F.B66DD964.000001C1"},{"plugin_class":"DDS:Access:Permissions"},{"plugin_method":"RTI_Security_AccessControl_validatePermissionsDocument"}]}],"m":"grant has invalid time"}} |
| 81 | +ERROR [PARSE MESSAGE|0xDED844B7,0x87B9550F,0xB66DD964:0x000201C4{Entity=DR,MessageKind=DATA}|RECEIVE FROM 0x831AB06E,0x43876C36,0xFD825600:0x000201C3|:0x000001C1{Domain=0}|RECEIVE SAMPLE|PROCESS HANDSHAKE|GET SECURITY STATE|LC:Security] RTI_Security_AccessControl_validate_remote_permissions:{"DDS:Security:LogTopicV2":{"f":"10","s":"1","t":{"s":"1748517682","n":"985044998"},"h":"RTISP-10036","i":"0.0.0.0","a":"RTI Secure DDS Application","p":"85248","k":"50331706","x":[{"DDS":[{"domain_id":"0"},{"guid":"DED844B7.87B9550F.B66DD964.000001C1"},{"plugin_class":"DDS:Access:Permissions"},{"plugin_method":"RTI_Security_AccessControl_validate_remote_permissions"}]}],"m":"failed to validate remote permissions"}} |
| 82 | +ERROR [PARSE MESSAGE|0xDED844B7,0x87B9550F,0xB66DD964:0x000201C4{Entity=DR,MessageKind=DATA}|RECEIVE FROM 0x831AB06E,0x43876C36,0xFD825600:0x000201C3|:0x000001C1{Domain=0}|RECEIVE SAMPLE|PROCESS HANDSHAKE|GET SECURITY STATE|LC:Security] DDS_DomainParticipantTrustPlugins_forwardGetAuthenticatedRemoteParticipantSecurityState:FAILED TO VALIDATE | Remote permissions. |
| 83 | +ERROR [PARSE MESSAGE|0xDED844B7,0x87B9550F,0xB66DD964:0x000201C4{Entity=DR,MessageKind=DATA}|RECEIVE FROM 0x831AB06E,0x43876C36,0xFD825600:0x000201C3|:0x000001C1{Domain=0}|RECEIVE SAMPLE|PROCESS HANDSHAKE|LC:Security] PRESParticipant_authorizeRemoteParticipant:{"DDS:Security:LogTopicV2":{"f":"10","s":"3","t":{"s":"1748517682","n":"985078998"},"h":"RTISP-10036","i":"0.0.0.0","a":"RTI Secure DDS Application","p":"85248","k":"50331706","x":[{"DDS":[{"domain_id":"0"},{"guid":"DED844B7.87B9550F.B66DD964.000001C1"},{"plugin_class":"RTI:Auth"},{"plugin_method":"PRESParticipant_authorizeRemoteParticipant"}]}],"m":"unauthorized remote participant 831ab06e.43876c36.fd825600 denied by local participant ded844b7.87b9550f.b66dd964"}} |
| 84 | +ERROR [PARSE MESSAGE|0xDED844B7,0x87B9550F,0xB66DD964:0x000201C4{Entity=DR,MessageKind=DATA}|RECEIVE FROM 0x831AB06E,0x43876C36,0xFD825600:0x000201C3|:0x000001C1{Domain=0}|RECEIVE SAMPLE|PROCESS HANDSHAKE|LC:Security] PRESParticipant_processHandshake:FAILED TO VALIDATE | Failed to authorize remote DP (GUID: 0x831AB06E,0x43876C36,0xFD825600:0x000001C1). |
| 85 | +``` |
| 86 | + |
| 87 | +Communication will stop. |
| 88 | + |
| 89 | +## Renewing the Permissions Document |
| 90 | + |
| 91 | +This example updates the publisher DomainParticipant's Permissions Document |
| 92 | +after 70 samples. At that point, communication with the subscriber will |
| 93 | +resume. |
0 commit comments