| 412 | } |
| 413 | |
| 414 | ::CORBA::Boolean AccessControlBuiltInImpl::check_create_datareader( |
| 415 | ::DDS::Security::PermissionsHandle permissions_handle, |
| 416 | ::DDS::Security::DomainId_t domain_id, |
| 417 | const char * topic_name, |
| 418 | const ::DDS::DataReaderQos & /*qos*/, |
| 419 | const ::DDS::PartitionQosPolicy & partition, |
| 420 | const ::DDS::Security::DataTags & /*data_tag*/, |
| 421 | ::DDS::Security::SecurityException & ex) |
| 422 | { |
| 423 | if (DDS::HANDLE_NIL == permissions_handle) { |
| 424 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datareader: Invalid permissions handle"); |
| 425 | } |
| 426 | |
| 427 | if (0 == topic_name) { |
| 428 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datareader: Invalid Topic Name"); |
| 429 | } |
| 430 | |
| 431 | ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, handle_mutex_, false); |
| 432 | |
| 433 | ACPermsMap::iterator ac_iter = local_ac_perms_.find(permissions_handle); |
| 434 | |
| 435 | if (ac_iter == local_ac_perms_.end()) { |
| 436 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datareader: No matching permissions handle present"); |
| 437 | } |
| 438 | |
| 439 | gov_iter begin = ac_iter->second.gov->access_rules().begin(); |
| 440 | gov_iter end = ac_iter->second.gov->access_rules().end(); |
| 441 | |
| 442 | for (gov_iter giter = begin; giter != end; ++giter) { |
| 443 | |
| 444 | if (giter->domains.has(domain_id)) { |
| 445 | Governance::TopicAccessRules::iterator tr_iter; |
| 446 | |
| 447 | for (tr_iter = giter->topic_rules.begin(); tr_iter != giter->topic_rules.end(); ++tr_iter) { |
| 448 | if (pattern_match(topic_name, tr_iter->topic_expression.c_str())) { |
| 449 | if (!tr_iter->topic_attrs.is_read_protected) { |
| 450 | return true; |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | // Check the Permissions file |
| 458 | |
| 459 | const Permissions::Grant_rch grant = ac_iter->second.perm->find_grant(ac_iter->second.subject); |
| 460 | if (!grant) { |
| 461 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datareader: Permissions grant not found"); |
| 462 | } |
| 463 | |
| 464 | const time_t now_utc = utc_now(); |
| 465 | if (!validate_date_time(grant->validity, now_utc, ex)) { |
| 466 | return false; |
| 467 | } |
| 468 | |
| 469 | time_t expiration_time = grant->validity.not_after; |
| 470 | if (!search_permissions(topic_name, domain_id, partition, Permissions::SUBSCRIBE, *grant, now_utc, expiration_time, ex)) { |
| 471 | return false; |
no test coverage detected