LCOV - code coverage report
Current view: top level - DCPS/security - TokenReader.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 4 100.0 %
Date: 2023-04-30 01:32:43 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *
       4             :  * Distributed under the OpenDDS License.
       5             :  * See: http://www.OpenDDS.org/license.html
       6             :  */
       7             : 
       8             : 
       9             : 
      10             : #ifndef OPENDDS_DCPS_SECURITY_TOKENREADER_H
      11             : #define OPENDDS_DCPS_SECURITY_TOKENREADER_H
      12             : 
      13             : #include "OpenDDS_Security_Export.h"
      14             : 
      15             : #include <dds/DdsSecurityCoreC.h>
      16             : #include <dds/Versioned_Namespace.h>
      17             : 
      18             : #if !defined (ACE_LACKS_PRAGMA_ONCE)
      19             : #pragma once
      20             : #endif /* ACE_LACKS_PRAGMA_ONCE */
      21             : 
      22             : class DDS_TEST;
      23             : 
      24             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      25             : 
      26             : namespace OpenDDS {
      27             : namespace Security {
      28             : 
      29             : /**
      30             : * @class TokenReader
      31             : *
      32             : * @brief Implements some simple wrapper functions to provide a const API
      33             : * around the Token data structure as specified in the DDS security specification
      34             : *
      35             : * See the DDS security specification, OMG formal/17-09-20, for a description of
      36             : * the interface this class is implementing.
      37             : *
      38             : */
      39             : 
      40             : class OpenDDS_Security_Export TokenReader
      41             : {
      42             : public:
      43             :   explicit TokenReader(const DDS::Security::Token& token_ref);
      44             :   virtual ~TokenReader();
      45             : 
      46             :   bool is_nil() const;
      47             :   const char* get_property_value(const std::string& property_name) const;
      48             :   const DDS::OctetSeq& get_bin_property_value(const std::string& property_name) const;
      49             : 
      50             :   CORBA::ULong get_num_properties() const;
      51             :   CORBA::ULong get_num_bin_properties() const;
      52             : 
      53             : private:
      54             :   const DDS::Security::Token& token_ref_;
      55             :   const DDS::OctetSeq _empty_seq_;
      56             : };
      57             : 
      58          74 : inline bool TokenReader::is_nil() const
      59             : {
      60          74 :   return ((token_ref_.binary_properties.length() == 0)
      61          16 :     && (token_ref_.properties.length() == 0)
      62          90 :     && (token_ref_.class_id[0] == '\0'));
      63             : }
      64             : 
      65             : inline CORBA::ULong TokenReader::get_num_properties() const
      66             : {
      67             :   return token_ref_.properties.length();
      68             : }
      69             : 
      70             : inline CORBA::ULong TokenReader::get_num_bin_properties() const
      71             : {
      72             :   return token_ref_.binary_properties.length();
      73             : }
      74             : } // namespace Security
      75             : } // namespace OpenDDS
      76             : 
      77             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
      78             : 
      79             : #endif

Generated by: LCOV version 1.16