Line data Source code
1 : /* 2 : * Distributed under the OpenDDS License. 3 : * See: http://www.OpenDDS.org/license.html 4 : */ 5 : 6 : #ifndef OPENDDS_DCPS_SECURITY_AUTHENTICATION_LOCALAUTHCREDENTIALDATA_H 7 : #define OPENDDS_DCPS_SECURITY_AUTHENTICATION_LOCALAUTHCREDENTIALDATA_H 8 : 9 : #include <string> 10 : 11 : #include "dds/DCPS/security/SSL/Certificate.h" 12 : #include "dds/DCPS/security/SSL/PrivateKey.h" 13 : #include "dds/DCPS/security/SSL/DiffieHellman.h" 14 : #include "dds/DCPS/security/SSL/Utils.h" 15 : 16 : #include "dds/DCPS/RcObject.h" 17 : #include "dds/DdsDcpsCoreC.h" 18 : #include "dds/DdsSecurityCoreC.h" 19 : 20 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 21 : 22 : namespace OpenDDS { 23 : namespace Security { 24 : 25 : class OpenDDS_Security_Export CredentialHash 26 : { 27 : public: 28 26 : CredentialHash(const SSL::Certificate& cid, const SSL::DiffieHellman& dh, const DDS::OctetSeq& cpdata, const DDS::OctetSeq& cperm) 29 26 : : pubcert_(cid), dh_(dh), participant_topic_data_(cpdata), permissions_data_(cperm) 30 : { 31 26 : } 32 : 33 : int operator()(DDS::OctetSeq& dst) const; 34 : 35 : private: 36 : const SSL::Certificate& pubcert_; 37 : const SSL::DiffieHellman& dh_; 38 : const DDS::OctetSeq& participant_topic_data_; 39 : const DDS::OctetSeq& permissions_data_; 40 : }; 41 : 42 : class OpenDDS_Security_Export LocalAuthCredentialData : public DCPS::RcObject { 43 : public: 44 : typedef DCPS::RcHandle<LocalAuthCredentialData> shared_ptr; 45 : 46 : LocalAuthCredentialData(); 47 : 48 : virtual ~LocalAuthCredentialData(); 49 : 50 : bool load_access_permissions(const DDS::Security::PermissionsCredentialToken& src, 51 : DDS::Security::SecurityException& ex); 52 : 53 : bool load_credentials(const DDS::PropertySeq& props, DDS::Security::SecurityException& ex); 54 : 55 33 : const SSL::Certificate& get_ca_cert() const 56 : { 57 33 : return *ca_cert_; 58 : } 59 : 60 85 : const SSL::Certificate& get_participant_cert() const 61 : { 62 85 : return *participant_cert_; 63 : } 64 : 65 12 : const SSL::PrivateKey& get_participant_private_key() const 66 : { 67 12 : return *participant_pkey_; 68 : } 69 : 70 28 : const DDS::OctetSeq& get_access_permissions() const 71 : { 72 28 : return access_permissions_; 73 : } 74 : 75 22 : bool validate() const 76 : { 77 22 : if (!participant_cert_) { 78 0 : ACE_ERROR((LM_WARNING, 79 : "(%P|%t) LocalAuthCredentialData::validate(): WARNING: participant_cert_ is null," 80 : " some of the security properties might be missing!\n")); 81 0 : return false; 82 : } 83 22 : if (!ca_cert_) { 84 0 : ACE_ERROR((LM_WARNING, 85 : "(%P|%t) LocalAuthCredentialData::validate(): WARNING: ca_cert_ is null," 86 : " some of the security properties might be missing!\n")); 87 0 : return false; 88 : } 89 22 : return X509_V_OK == participant_cert_->validate(*ca_cert_); 90 : } 91 : 92 : private: 93 : 94 : SSL::Certificate::unique_ptr ca_cert_; 95 : SSL::Certificate::unique_ptr participant_cert_; 96 : SSL::PrivateKey::unique_ptr participant_pkey_; 97 : DDS::OctetSeq access_permissions_; 98 : }; 99 : 100 : } 101 : } 102 : 103 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 104 : 105 : #endif