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_WRITER_IMPL_H 00011 #define DDS_DCPS_TOKEN_WRITER_IMPL_H 00012 00013 #include "dds/DCPS/security/DdsSecurity_Export.h" 00014 #include "dds/DCPS/SequenceIterator.h" 00015 #include "dds/DdsSecurityCoreC.h" 00016 #include "dds/Versioned_Namespace.h" 00017 #include "TokenReader.h" 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 #pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 class DDS_TEST; 00024 00025 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 namespace OpenDDS { 00028 namespace Security { 00029 00030 /** 00031 * @class TokenWriter 00032 * 00033 * @brief Implements some simple wrapper functions to provide a non-const API 00034 * around the Token data structure as specified in the DDS security specification 00035 * 00036 * See the DDS security specification, OMG formal/17-09-20, for a description of 00037 * the interface this class is implementing. 00038 * 00039 */ 00040 00041 class DdsSecurity_Export TokenWriter 00042 { 00043 public: 00044 TokenWriter(DDS::Security::Token& token_ref); 00045 TokenWriter(DDS::Security::Token& token_ref, const std::string& class_id); 00046 00047 virtual ~TokenWriter(); 00048 00049 const TokenReader& get_reader(); 00050 00051 void set_class_id(const std::string& class_name); 00052 00053 void add_property(const char* prop_name, const char* prop_value, bool propagate = true); 00054 void add_property(const char* prop_name, const DDS::OctetSeq& prop_value, bool propagate = true); 00055 void add_bin_property(const char* prop_name, const DDS::OctetSeq& prop_value, bool propagate = true); 00056 void add_bin_property(const char* prop_name, const std::string& prop_value, bool propagate = true); 00057 00058 private: 00059 DCPS::SequenceBackInsertIterator<DDS::BinaryPropertySeq> binary_property_inserter_; 00060 DCPS::SequenceBackInsertIterator<DDS::PropertySeq> property_inserter_; 00061 DDS::Security::Token& token_ref_; 00062 OpenDDS::Security::TokenReader reader_; 00063 }; 00064 00065 inline const TokenReader& TokenWriter::get_reader() 00066 { 00067 return reader_; 00068 } 00069 00070 inline void TokenWriter::set_class_id(const std::string& class_id) 00071 { 00072 token_ref_.class_id = class_id.c_str(); 00073 } 00074 00075 00076 } // namespace Security 00077 } // namespace OpenDDS 00078 00079 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00080 00081 #endif