Skip to content

Commit

Permalink
Move EndpointSecurityAttributes.h to /attributes and create EndpointS…
Browse files Browse the repository at this point in the history
…ecurityAttributes.cpp

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
  • Loading branch information
elianalf committed May 24, 2024
1 parent 5410eba commit 6f337ea
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 75 deletions.
8 changes: 3 additions & 5 deletions include/fastdds/rtps/attributes/EndpointAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
#include <fastdds/rtps/common/Guid.h>
#include <fastdds/rtps/common/LocatorList.hpp>
#include <fastdds/rtps/common/Types.h>

#if HAVE_SECURITY
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#endif // HAVE_SECURITY

#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#endif // if HAVE_SECURITY
namespace eprosima {
namespace fastrtps {
namespace rtps {
Expand Down Expand Up @@ -164,7 +162,7 @@ class EndpointAttributes
int16_t m_entityID = -1;

#if HAVE_SECURITY
//! Security attributes
//! Security attributes
security::EndpointSecurityAttributes security_attributes_;
#endif // HAVE_SECURITY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef _FASTDDS_RTPS_SECURITY_ACCESSCONTROL_ENDPOINTSECURITYATTRIBUTES_H_
#define _FASTDDS_RTPS_SECURITY_ACCESSCONTROL_ENDPOINTSECURITYATTRIBUTES_H_

#include <rtps/security/accesscontrol/SecurityMaskUtilities.h>
#include <cstdint>

namespace eprosima {
namespace fastrtps {
Expand Down Expand Up @@ -56,23 +56,7 @@ struct PluginEndpointSecurityAttributes
bool is_submessage_origin_authenticated;
bool is_payload_encrypted;

inline PluginEndpointSecurityAttributesMask mask() const
{
PluginEndpointSecurityAttributesMask rv = PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_VALID;
if (is_submessage_encrypted)
{
rv |= PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_ENCRYPTED;
}
if (is_submessage_origin_authenticated)
{
rv |= PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_ORIGIN_AUTHENTICATED;
}
if (is_payload_encrypted)
{
rv |= PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_PAYLOAD_ENCRYPTED;
}
return rv;
}
PluginEndpointSecurityAttributesMask mask() const;

};

Expand Down Expand Up @@ -130,47 +114,11 @@ struct EndpointSecurityAttributes

PluginEndpointSecurityAttributesMask plugin_endpoint_attributes;

inline EndpointSecurityAttributesMask mask() const
{
EndpointSecurityAttributesMask rv = ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_VALID;
if (is_read_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_READ_PROTECTED;
}
if (is_write_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_WRITE_PROTECTED;
}
if (is_discovery_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_DISCOVERY_PROTECTED;
}
if (is_liveliness_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_LIVELINESS_PROTECTED;
}
if (is_submessage_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_PROTECTED;
}
if (is_payload_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_PAYLOAD_PROTECTED;
}
if (is_key_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_KEY_PROTECTED;
}
return rv;
}
EndpointSecurityAttributesMask mask() const;

inline bool match(
bool match(
const EndpointSecurityAttributesMask remoteMask,
const PluginEndpointSecurityAttributesMask remotePluginMask) const
{
return security_mask_matches(mask(), remoteMask) &&
security_mask_matches(plugin_endpoint_attributes, remotePluginMask);
}
const PluginEndpointSecurityAttributesMask remotePluginMask) const;

};

Expand Down
7 changes: 3 additions & 4 deletions include/fastdds/rtps/builtin/data/ReaderProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#include <fastdds/dds/subscriber/qos/ReaderQos.hpp>
#if HAVE_SECURITY
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#endif // if HAVE_SECURITY
#include <fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp>
#include <fastdds/rtps/attributes/WriterAttributes.h>
#include <fastdds/rtps/builtin/data/ContentFilterProperty.hpp>
#include <fastdds/rtps/common/RemoteLocators.hpp>
#include <fastdds/rtps/common/VendorId_t.hpp>
#include <fastdds/rtps/attributes/TopicAttributes.h>
#if HAVE_SECURITY
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#endif // if HAVE_SECURITY


namespace eprosima {
namespace fastrtps {
Expand Down
2 changes: 1 addition & 1 deletion include/fastdds/rtps/builtin/data/WriterProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <fastdds/rtps/common/RemoteLocators.hpp>
#include <fastdds/rtps/common/VendorId_t.hpp>
#if HAVE_SECURITY
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#endif // if HAVE_SECURITY


Expand Down
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ set(${PROJECT_NAME}_source_files
fastdds/topic/TopicProxyFactory.cpp
fastdds/topic/TypeSupport.cpp
fastdds/utils/QosConverters.cpp
rtps/attributes/EndpointSecurityAttributes.cpp
rtps/attributes/PropertyPolicy.cpp
rtps/attributes/RTPSParticipantAttributes.cpp
rtps/attributes/ThreadSettings.cpp
Expand Down
97 changes: 97 additions & 0 deletions src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file EndpointSecurityAttributes.cpp
*/

#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>

#include <rtps/security/accesscontrol/SecurityMaskUtilities.h>

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

typedef uint32_t PluginEndpointSecurityAttributesMask;

PluginEndpointSecurityAttributesMask PluginEndpointSecurityAttributes::mask() const
{
PluginEndpointSecurityAttributesMask rv = PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_VALID;
if (is_submessage_encrypted)
{
rv |= PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_ENCRYPTED;
}
if (is_submessage_origin_authenticated)
{
rv |= PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_ORIGIN_AUTHENTICATED;
}
if (is_payload_encrypted)
{
rv |= PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_PAYLOAD_ENCRYPTED;
}
return rv;
}

typedef uint32_t EndpointSecurityAttributesMask;


EndpointSecurityAttributesMask EndpointSecurityAttributes::mask() const
{
EndpointSecurityAttributesMask rv = ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_VALID;
if (is_read_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_READ_PROTECTED;
}
if (is_write_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_WRITE_PROTECTED;
}
if (is_discovery_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_DISCOVERY_PROTECTED;
}
if (is_liveliness_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_LIVELINESS_PROTECTED;
}
if (is_submessage_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_PROTECTED;
}
if (is_payload_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_PAYLOAD_PROTECTED;
}
if (is_key_protected)
{
rv |= ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_KEY_PROTECTED;
}
return rv;
}

bool EndpointSecurityAttributes::match(
const EndpointSecurityAttributesMask remoteMask,
const PluginEndpointSecurityAttributesMask remotePluginMask) const
{
return security_mask_matches(mask(), remoteMask) &&
security_mask_matches(plugin_endpoint_attributes, remotePluginMask);
}


} // namespace security
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
2 changes: 1 addition & 1 deletion src/cpp/rtps/security/SecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <thread>

#include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#include <fastdds/rtps/attributes/HistoryAttributes.h>
#include <fastdds/rtps/builtin/data/ParticipantProxyData.h>
#include <fastdds/rtps/builtin/data/ReaderProxyData.h>
Expand All @@ -43,7 +44,6 @@
#include <rtps/network/NetworkFactory.h>
#include <rtps/participant/RTPSParticipantImpl.h>
#include <rtps/security/accesscontrol/AccessControl.h>
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
#include <rtps/security/accesscontrol/SecurityMaskUtilities.h>
#include <rtps/security/authentication/Authentication.h>
Expand Down
7 changes: 4 additions & 3 deletions src/cpp/rtps/security/cryptography/CryptoKeyFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
#ifndef _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_
#define _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_

#include <memory>

#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>

#include <rtps/security/cryptography/CryptoTypes.h>
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <rtps/security/accesscontrol/ParticipantSecurityAttributes.h>

#include <memory>

namespace eprosima {
namespace fastrtps {
namespace rtps {
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/security/accesscontrol/AccessPermissionsHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define __SECURITY_ACCESSCONTROL_ACCESSPERMISSIONSHANDLE_H__

#include <fastdds/rtps/common/Token.h>
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#include <rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
#include <rtps/security/common/Handle.h>
#include <security/accesscontrol/PermissionsTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/security/cryptography/AESGCMGMAC_Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define _SECURITY_AUTHENTICATION_AESGCMGMAC_TYPES_H_

#include <fastdds/rtps/attributes/PropertyPolicy.h>
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#include <rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
#include <rtps/security/common/Handle.h>
#include <rtps/security/common/SharedSecretHandle.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <fastdds/rtps/common/RemoteLocators.hpp>
#include <fastdds/rtps/common/VendorId_t.hpp>
#if HAVE_SECURITY
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#endif // if HAVE_SECURITY

namespace eprosima {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <fastdds/rtps/common/RemoteLocators.hpp>

#if HAVE_SECURITY
#include <rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#include <fastdds/rtps/attributes/EndpointSecurityAttributes.h>
#endif // if HAVE_SECURITY

namespace eprosima {
Expand Down
1 change: 1 addition & 0 deletions test/unittest/dds/publisher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/QosConverters.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp
Expand Down
1 change: 1 addition & 0 deletions test/unittest/rtps/discovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(EDPTESTS_SOURCE EdpTests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp
Expand Down
1 change: 1 addition & 0 deletions test/unittest/rtps/security/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ endif()
set(SOURCES_SECURITY_TEST_SOURCE
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp
Expand Down
1 change: 1 addition & 0 deletions test/unittest/security/accesscontrol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(COMMON_SOURCES_ACCESS_CONTROL_TEST_SOURCE
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp
Expand Down
1 change: 1 addition & 0 deletions test/unittest/security/authentication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ endif()
set(COMMON_SOURCES_AUTH_PLUGIN_TEST_SOURCE
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/GuidPrefix_t.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp
Expand Down
2 changes: 2 additions & 0 deletions test/unittest/statistics/dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX)
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/QosConverters.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp
Expand Down Expand Up @@ -350,6 +351,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX)
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/QosConverters.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/BuiltinProtocols.cpp
Expand Down

0 comments on commit 6f337ea

Please sign in to comment.