00001
00002
00007 #ifndef __KEYDATA_H__
00008 #define __KEYDATA_H__
00009
00010 #include "stdint.h"
00011 #include "StrUtil.H"
00012
00013 LIBEPP_NICBR_NS_BEGIN
00014
00015 class KeyData {
00016 public:
00017 unsigned int get_flags() const
00018 {
00019 return _flags;
00020 }
00021
00022 unsigned int get_protocol() const
00023 {
00024 return _protocol;
00025 }
00026
00027 unsigned int get_algorithm() const
00028 {
00029 return _algorithm;
00030 }
00031
00032 string get_pub_key() const
00033 {
00034 return _pub_key;
00035 }
00036
00037 void set_flags(unsigned int flags)
00038 {
00039 _flags = flags;
00040 }
00041
00042 void set_protocol(unsigned int protocol)
00043 {
00044 _protocol = protocol;
00045 }
00046
00047 void set_algorithm(unsigned int algorithm)
00048 {
00049 _algorithm = algorithm;
00050 }
00051
00052 void set_pub_key(string pub_key)
00053 {
00054 _pub_key = pub_key;
00055 }
00056
00057 KeyData& operator=(const KeyData &key_data) {
00058 _flags = key_data._flags;
00059 _protocol = key_data._protocol;
00060 _algorithm = key_data._algorithm;
00061 _pub_key = key_data._pub_key;
00062
00063 return *this;
00064 }
00065
00066 KeyData() {
00067 this->reset();
00068 }
00069
00070 bool is_set() {
00071 return (_flags != 0 && _protocol != 0 && _algorithm != 0 &&
00072 _pub_key != "");
00073 }
00074
00075 void reset() {
00076 _flags = 0;
00077 _protocol = 0;
00078 _algorithm = 0;
00079 _pub_key = "";
00080 }
00081
00082 string get_xml_format() const
00083 {
00084 return "<secDNS:keyData>"
00085 "<secDNS:flags>" + StrUtil::to_string("%u", _flags) +
00086 "</secDNS:flags>"
00087 "<secDNS:protocol>" + StrUtil::to_string("%u", _protocol) +
00088 "</secDNS:protocol>"
00089 "<secDNS:alg>" + StrUtil::to_string("%u", _algorithm) +
00090 "</secDNS:alg>"
00091 "<secDNS:pubKey>" + _pub_key +
00092 "</secDNS:pubKey>" +
00093 "</secDNS:keyData>";
00094 }
00095
00096 private:
00097 uint16_t _flags;
00098 uint8_t _protocol;
00099 uint8_t _algorithm;
00100 string _pub_key;
00101
00102 };
00103 LIBEPP_NICBR_NS_END
00104 #endif //__KEYDATA_H__