| 477 | } |
| 478 | |
| 479 | ::CORBA::Boolean AccessControlBuiltInImpl::check_create_topic( |
| 480 | ::DDS::Security::PermissionsHandle permissions_handle, |
| 481 | ::DDS::Security::DomainId_t domain_id, |
| 482 | const char * topic_name, |
| 483 | const ::DDS::TopicQos & /*qos*/, |
| 484 | ::DDS::Security::SecurityException & ex) |
| 485 | { |
| 486 | if (DDS::HANDLE_NIL == permissions_handle) { |
| 487 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_topic: Invalid permissions handle"); |
| 488 | } |
| 489 | if (0 == topic_name) { |
| 490 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_topic: Invalid Topic Name"); |
| 491 | } |
| 492 | |
| 493 | ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, handle_mutex_, false); |
| 494 | |
| 495 | ACPermsMap::iterator ac_iter = local_ac_perms_.find(permissions_handle); |
| 496 | |
| 497 | if (ac_iter == local_ac_perms_.end()) { |
| 498 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_topic: No matching permissions handle present"); |
| 499 | } |
| 500 | |
| 501 | // Check the Governance file for allowable topic attributes |
| 502 | |
| 503 | if (domain_id != ac_iter->second.domain_id) { |
| 504 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_topic: Requested domain ID does not match permissions handle"); |
| 505 | } |
| 506 | |
| 507 | ::DDS::Security::DomainId_t domain_to_find = ac_iter->second.domain_id; |
| 508 | |
| 509 | gov_iter begin = ac_iter->second.gov->access_rules().begin(); |
| 510 | gov_iter end = ac_iter->second.gov->access_rules().end(); |
| 511 | |
| 512 | for (gov_iter giter = begin; giter != end; ++giter) { |
| 513 | |
| 514 | if (giter->domains.has(domain_to_find)) { |
| 515 | Governance::TopicAccessRules::iterator tr_iter; |
| 516 | |
| 517 | for (tr_iter = giter->topic_rules.begin(); tr_iter != giter->topic_rules.end(); ++tr_iter) { |
| 518 | if (pattern_match(topic_name, tr_iter->topic_expression.c_str())) { |
| 519 | if (!tr_iter->topic_attrs.is_read_protected || !tr_iter->topic_attrs.is_write_protected) { |
| 520 | return true; |
| 521 | } |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | const Permissions::Grant_rch grant = ac_iter->second.perm->find_grant(ac_iter->second.subject); |
| 528 | if (!grant) { |
| 529 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_topic: grant not found"); |
| 530 | } |
| 531 | |
| 532 | const time_t now_utc = utc_now(); |
| 533 | if (!validate_date_time(grant->validity, now_utc, ex)) { |
| 534 | return false; |
| 535 | } |
| 536 |
no test coverage detected