| 816 | } |
| 817 | |
| 818 | ::CORBA::Boolean AccessControlBuiltInImpl::check_remote_topic( |
| 819 | ::DDS::Security::PermissionsHandle permissions_handle, |
| 820 | ::DDS::Security::DomainId_t domain_id, |
| 821 | const ::DDS::TopicBuiltinTopicData & topic_data, |
| 822 | ::DDS::Security::SecurityException & ex) |
| 823 | { |
| 824 | // NOTE: permissions_handle is for the remote DomainParticipant. |
| 825 | if (DDS::HANDLE_NIL == permissions_handle) { |
| 826 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_remote_topic: Invalid permissions handle"); |
| 827 | } |
| 828 | |
| 829 | if (topic_data.name[0] == 0) { |
| 830 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_remote_topic: Invalid topic data"); |
| 831 | } |
| 832 | |
| 833 | ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, handle_mutex_, false); |
| 834 | |
| 835 | ACPermsMap::iterator ac_iter = local_ac_perms_.find(permissions_handle); |
| 836 | |
| 837 | if (ac_iter == local_ac_perms_.end()) { |
| 838 | return CommonUtilities::set_security_error(ex,-1, 0, "AccessControlBuiltInImpl::check_remote_topic: No matching permissions handle present"); |
| 839 | } |
| 840 | |
| 841 | // Compare the PluginClassName and MajorVersion of the local permissions_token |
| 842 | // with those in the remote_permissions_token. |
| 843 | const std::string remote_class_id = ac_iter->second.perm->perm_token_.class_id.in(); |
| 844 | |
| 845 | std::string local_plugin_class_name, |
| 846 | remote_plugin_class_name; |
| 847 | int local_major_ver = 0, |
| 848 | local_minor_ver, |
| 849 | remote_major_ver, |
| 850 | remote_minor_ver; |
| 851 | |
| 852 | if (remote_class_id.length() > 0) { |
| 853 | parse_class_id(remote_class_id, remote_plugin_class_name, remote_major_ver, remote_minor_ver); |
| 854 | } else { |
| 855 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_remote_topic: Invalid remote class ID"); |
| 856 | } |
| 857 | |
| 858 | for (ACPermsMap::iterator local_iter = local_ac_perms_.begin(); local_iter != local_ac_perms_.end(); ++local_iter) { |
| 859 | if (local_iter->second.domain_id == domain_id && local_iter->first != permissions_handle) { |
| 860 | const std::string local_class_id = local_iter->second.perm->perm_token_.class_id.in(); |
| 861 | |
| 862 | if (local_class_id.length() > 0) { |
| 863 | parse_class_id(local_class_id, local_plugin_class_name, local_major_ver, local_minor_ver); |
| 864 | break; |
| 865 | } else { |
| 866 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_remote_topic: Invalid local class ID"); |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | if (strcmp(local_plugin_class_name.c_str(), remote_plugin_class_name.c_str())) { |
| 872 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_remote_topic: Class ID plugin class name do not match"); |
| 873 | } |
| 874 | |
| 875 | if (local_major_ver != remote_major_ver) { |
no test coverage detected