00001 /* 00002 * Distributed under the OpenDDS License. 00003 * See: http://www.OpenDDS.org/license.html 00004 */ 00005 00006 #ifndef OPENDDS_ACCESS_PERMISSIONS_H 00007 #define OPENDDS_ACCESS_PERMISSIONS_H 00008 00009 #include "dds/DCPS/security/SSL/SignedDocument.h" 00010 #include "Governance.h" 00011 #include <list> 00012 00013 namespace OpenDDS { 00014 namespace Security { 00015 00016 class Permissions : public DCPS::RcObject { 00017 public: 00018 00019 typedef DCPS::RcHandle<Permissions> shared_ptr; 00020 00021 enum AllowDeny_t 00022 { 00023 ALLOW, 00024 DENY 00025 }; 00026 00027 enum PublishSubscribe_t 00028 { 00029 PUBLISH, 00030 SUBSCRIBE 00031 }; 00032 00033 struct Validity_t { 00034 std::string not_before; 00035 std::string not_after; 00036 }; 00037 00038 struct PermissionTopicPsRule { 00039 PublishSubscribe_t ps_type; 00040 std::vector<std::string> topic_list; 00041 }; 00042 00043 struct PermissionPartitionPs { 00044 PublishSubscribe_t ps_type; 00045 std::vector<std::string> partition_list; 00046 }; 00047 00048 typedef std::list<PermissionTopicPsRule> TopicPsRules; 00049 00050 struct PermissionTopicRule { 00051 AllowDeny_t ad_type; 00052 std::set< ::DDS::Security::DomainId_t > domain_list; 00053 TopicPsRules topic_ps_rules; 00054 }; 00055 00056 typedef std::list<PermissionPartitionPs> PartitionPsList; 00057 00058 struct PermissionsPartition { 00059 AllowDeny_t ad_type; 00060 std::set< ::DDS::Security::DomainId_t > domain_list; 00061 PartitionPsList partition_ps; 00062 }; 00063 00064 typedef std::list<PermissionTopicRule> TopicRules; 00065 typedef std::list<PermissionsPartition> Partitions; 00066 00067 struct PermissionGrantRule { 00068 std::string grant_name; 00069 std::string subject; 00070 Validity_t validity; 00071 std::string default_permission; 00072 TopicRules PermissionTopicRules; 00073 Partitions PermissionPartitions; 00074 }; 00075 00076 typedef std::vector<PermissionGrantRule> PermissionGrantRules; 00077 00078 struct AcPerms { 00079 DDS::Security::DomainId_t domain_id; 00080 PermissionGrantRules perm_rules; 00081 DDS::Security::PermissionsToken perm_token; 00082 DDS::Security::PermissionsCredentialToken perm_cred_token; 00083 }; 00084 00085 Permissions(); 00086 00087 int load(const SSL::SignedDocument& doc); 00088 00089 AcPerms& data() 00090 { 00091 return perm_data_; 00092 } 00093 00094 const std::string& subject_name() 00095 { 00096 return subject_name_; 00097 } 00098 00099 private: 00100 00101 bool extract_subject_name(const SSL::SignedDocument& doc); 00102 00103 AcPerms perm_data_; 00104 std::string subject_name_; 00105 00106 }; 00107 00108 } 00109 } 00110 00111 #endif