00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.OpenDDS.org/license.html 00006 */ 00007 00008 00009 00010 #ifndef DDS_DCPS_TOKEN_READER_IMPL_H 00011 #define DDS_DCPS_TOKEN_READER_IMPL_H 00012 00013 #include "dds/DCPS/security/DdsSecurity_Export.h" 00014 00015 #include "dds/DdsSecurityCoreC.h" 00016 #include "dds/Versioned_Namespace.h" 00017 00018 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00019 #pragma once 00020 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00021 00022 class DDS_TEST; 00023 00024 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00025 00026 namespace OpenDDS { 00027 namespace Security { 00028 00029 /** 00030 * @class TokenReader 00031 * 00032 * @brief Implements some simple wrapper functions to provide a const API 00033 * around the Token data structure as specified in the DDS security specification 00034 * 00035 * See the DDS security specification, OMG formal/17-09-20, for a description of 00036 * the interface this class is implementing. 00037 * 00038 */ 00039 00040 class DdsSecurity_Export TokenReader 00041 { 00042 public: 00043 00044 TokenReader(const DDS::Security::Token& token_ref); 00045 virtual ~TokenReader(); 00046 00047 bool is_nil() const; 00048 const char* get_property_value(const std::string& property_name) const; 00049 const DDS::OctetSeq& get_bin_property_value(const std::string& property_name) const; 00050 00051 CORBA::ULong get_num_properties() const; 00052 CORBA::ULong get_num_bin_properties() const; 00053 00054 private: 00055 const DDS::Security::Token& token_ref_; 00056 const DDS::OctetSeq _empty_seq_; 00057 }; 00058 00059 inline bool TokenReader::is_nil() const 00060 { 00061 return ((token_ref_.binary_properties.length() == 0) 00062 && (token_ref_.properties.length() == 0) 00063 && (token_ref_.class_id[0] == '\0')); 00064 } 00065 00066 inline CORBA::ULong TokenReader::get_num_properties() const 00067 { 00068 return token_ref_.properties.length(); 00069 } 00070 00071 inline CORBA::ULong TokenReader::get_num_bin_properties() const 00072 { 00073 return token_ref_.binary_properties.length(); 00074 } 00075 } // namespace Security 00076 } // namespace OpenDDS 00077 00078 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00079 00080 #endif