00001 /* ${copyright}$ */ 00002 /* $Id: DomainCreateCmd.H 1076 2010-08-03 18:55:45Z rafael $ */ 00007 #ifndef __DOMAIN_CREATE_CMD_H__ 00008 #define __DOMAIN_CREATE_CMD_H__ 00009 00010 #include <string> 00011 #include <vector> 00012 #include <map> 00013 #include <list> 00014 00015 #include "libepp_nicbr.H" 00016 00017 #include "Command.H" 00018 #include "CommonData.H" // struct NameServer 00019 #include "DSInfo.H" 00020 #include "RegistrationPeriod.H" 00021 00022 using std::string; 00023 using std::set; 00024 using std::map; 00025 using std::list; 00026 using std::less; 00027 00028 LIBEPP_NICBR_NS_BEGIN 00029 00031 class DomainCreateCmd : public Command 00032 { 00033 public: 00035 DomainCreateCmd(bool reset = true) : Command(false) 00036 { 00037 if (reset) { 00038 this->reset(); 00039 } 00040 } 00041 00043 00046 void set_name(const string& name) { _name = name; } 00047 00049 00052 string get_name() const { return _name; } 00053 00055 00059 void set_period(const int time, const string& unit) 00060 { 00061 _period.time = time; 00062 _period.unit = unit; 00063 } 00064 00066 00069 RegistrationPeriod get_period() const { return _period; } 00070 00072 00075 void insert_nameserver(const struct NameServer &nameserver) 00076 { 00077 _nameservers.push_back(nameserver); 00078 } 00079 00081 00084 vector<struct NameServer> get_nameservers() const { return _nameservers; } 00085 00087 00090 void set_registrant(const string& registrant) { _registrant = registrant; } 00091 00093 00096 string get_registrant() const { return _registrant; } 00097 00099 00103 void insert_contact(const string& type, const string& identification) 00104 { 00105 _contacts[type] = identification; 00106 } 00107 00109 00112 map< string, string, less<string> > get_contacts() const { return _contacts; } 00113 00115 00118 void set_authInfo(const AuthInfo &authInfo) 00119 { 00120 _authInfo = authInfo; 00121 } 00122 00124 00127 AuthInfo get_authInfo() const { return _authInfo; } 00128 00129 //******************** RFC 4310/5910 BEGIN ******************** 00131 00134 void set_secDnsVersion(string secDnsVersion) 00135 { 00136 _secDnsVersion = secDnsVersion; 00137 } 00138 00140 00143 string get_secDnsVersion() const 00144 { 00145 return _secDnsVersion; 00146 } 00147 00149 00152 void add_dsInfo(const DSInfo &ds_info) 00153 { 00154 _ds_list.push_back(ds_info); 00155 } 00156 00158 00161 list<DSInfo> get_dsInfo() const 00162 { 00163 return _ds_list; 00164 } 00165 00167 00170 void add_keyData(const KeyData &dnskey_data) 00171 { 00172 _dnskey_list.push_back(dnskey_data); 00173 } 00174 00176 00179 list<KeyData> get_keyDataList() const 00180 { 00181 return _dnskey_list; 00182 } 00183 00185 00188 void set_max_sig_life(const unsigned int max_sig_life) 00189 { 00190 _max_sig_life = max_sig_life; 00191 } 00192 00194 00197 unsigned int get_max_sig_life() const 00198 { 00199 return _max_sig_life; 00200 } 00201 00202 //******************** RFC 4310/5910 END ******************** 00203 00205 bool has_extension() const { 00206 return has_secdns_extension(); 00207 } 00208 00210 bool has_secdns_extension() const { 00211 bool hasSecDns10 = _secDnsVersion == "1.0" && !_ds_list.empty(); 00212 00213 bool hasSecDns11 = _secDnsVersion == "1.1" && 00214 !(_ds_list.empty() && _dnskey_list.empty()); 00215 00216 return (hasSecDns10 || hasSecDns11); 00217 } 00218 00220 void reset() 00221 { 00222 Command::reset(); 00223 _name = ""; 00224 _period.time = 0; 00225 _period.unit = ""; 00226 _nameservers.clear(); 00227 _registrant = ""; 00228 _contacts.clear(); 00229 _authInfo.reset(); 00230 _secDnsVersion = "1.1"; 00231 _max_sig_life = 0; 00232 _ds_list.clear(); 00233 _dnskey_list.clear(); 00234 } 00235 00236 protected: 00238 string _name; 00239 00241 RegistrationPeriod _period; 00242 00244 vector<struct NameServer> _nameservers; 00245 00247 string _registrant; 00248 00250 map< string, string, less<string> > _contacts; 00251 00253 AuthInfo _authInfo; 00254 00256 string _secDnsVersion; 00257 00259 unsigned int _max_sig_life; 00260 00262 list<DSInfo> _ds_list; 00263 00265 list<KeyData> _dnskey_list; 00266 }; 00267 00268 LIBEPP_NICBR_NS_END 00269 #endif //__DOMAIN_CREATE_CMD_H__