| 348 | } |
| 349 | |
| 350 | ::CORBA::Boolean AccessControlBuiltInImpl::check_create_datawriter( |
| 351 | ::DDS::Security::PermissionsHandle permissions_handle, |
| 352 | ::DDS::Security::DomainId_t domain_id, |
| 353 | const char * topic_name, |
| 354 | const ::DDS::DataWriterQos & /*qos*/, |
| 355 | const ::DDS::PartitionQosPolicy & partition, |
| 356 | const ::DDS::Security::DataTags & /*data_tag*/, |
| 357 | ::DDS::Security::SecurityException & ex) |
| 358 | { |
| 359 | if (DDS::HANDLE_NIL == permissions_handle) { |
| 360 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datawriter: Invalid permissions handle"); |
| 361 | } |
| 362 | if (0 == topic_name) { |
| 363 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datawriter: Invalid Topic Name"); |
| 364 | } |
| 365 | |
| 366 | ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, handle_mutex_, false); |
| 367 | |
| 368 | ACPermsMap::iterator ac_iter = local_ac_perms_.find(permissions_handle); |
| 369 | |
| 370 | if (ac_iter == local_ac_perms_.end()) { |
| 371 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datawriter: No matching permissions handle present"); |
| 372 | } |
| 373 | |
| 374 | gov_iter begin = ac_iter->second.gov->access_rules().begin(); |
| 375 | gov_iter end = ac_iter->second.gov->access_rules().end(); |
| 376 | |
| 377 | for (gov_iter giter = begin; giter != end; ++giter) { |
| 378 | |
| 379 | if (giter->domains.has(domain_id)) { |
| 380 | Governance::TopicAccessRules::iterator tr_iter; |
| 381 | |
| 382 | for (tr_iter = giter->topic_rules.begin(); tr_iter != giter->topic_rules.end(); ++tr_iter) { |
| 383 | if (pattern_match(topic_name, tr_iter->topic_expression.c_str())) { |
| 384 | if (!tr_iter->topic_attrs.is_write_protected) { |
| 385 | return true; |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // Check the Permissions file |
| 393 | |
| 394 | const Permissions::Grant_rch grant = ac_iter->second.perm->find_grant(ac_iter->second.subject); |
| 395 | if (!grant) { |
| 396 | return CommonUtilities::set_security_error(ex, -1, 0, "AccessControlBuiltInImpl::check_create_datawriter: Permissions grant not found"); |
| 397 | } |
| 398 | |
| 399 | const time_t now_utc = utc_now(); |
| 400 | if (!validate_date_time(grant->validity, now_utc, ex)) { |
| 401 | return false; |
| 402 | } |
| 403 | |
| 404 | time_t expiration_time = grant->validity.not_after; |
| 405 | if (!search_permissions(topic_name, domain_id, partition, Permissions::PUBLISH, *grant, now_utc, expiration_time, ex)) { |
| 406 | return false; |
| 407 | } |
no test coverage detected