1 /* 2 * Copyright (C) 2006-2021 Registro.br. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 1. Redistribution of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 18 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 19 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 21 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 22 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 * DAMAGE. 24 */ 25 /* $Id$ */ 26 /** @file RGPRestore.H 27 * @brief EPP/RGP Restore information class 28 */ 29 30 #ifndef __RGP_RESTORE_H__ 31 #define __RGP_RESTORE_H__ 32 33 #include <string> 34 35 #include "libepp_nicbr.H" 36 37 using std::string; 38 39 LIBEPP_NICBR_NS_BEGIN 40 41 /// EPP RGPReport Class 42 class RGPReport 43 { 44 public: 45 /// Default constructor RGPReport()46 RGPReport() 47 { 48 this->reset(); 49 } 50 51 /// Sets the pre data 52 /** 53 @param pre_data data that existed for the domain name prior to 54 the domain name being deleted 55 */ set_pre_data(const string & pre_data)56 void set_pre_data(const string &pre_data) 57 { 58 _pre_data = pre_data; 59 } 60 61 /// Returns the pre data 62 /** 63 @return data that existed for the domain name prior to the domain 64 name being deleted 65 */ get_pre_data()66 string get_pre_data() const 67 { 68 return _pre_data; 69 } 70 71 /// Sets the post data 72 /** 73 @param post_data data that exists for the domain name at the time 74 the restore report is submitted 75 */ set_post_data(const string & post_data)76 void set_post_data(const string &post_data) 77 { 78 _post_data = post_data; 79 } 80 81 /// Returns the post data 82 /** 83 @return data that exists for the domain name at the time the 84 restore report is submitted 85 */ get_post_data()86 string get_post_data() const 87 { 88 return _post_data; 89 } 90 91 /// Sets the del time 92 /** 93 @param del_time date and time when the domain name delete request 94 was sent to the server 95 */ set_del_time(const string & del_time)96 void set_del_time(const string &del_time) 97 { 98 _del_time = del_time; 99 } 100 101 /// Returns the del time 102 /** 103 @return date and time when the domain name delete request was 104 sent to the server 105 */ get_del_time()106 string get_del_time() const 107 { 108 return _del_time; 109 } 110 111 /// Sets the res time 112 /** 113 @param res_time date and time when the original <rgp:restore> 114 command was sent to the server 115 */ set_res_time(const string & res_time)116 void set_res_time(const string &res_time) 117 { 118 _res_time = res_time; 119 } 120 121 /// Returns the res time 122 /** 123 @return date and time when the original <rgp:restore> command was 124 sent to the server 125 */ get_res_time()126 string get_res_time() const 127 { 128 return _res_time; 129 } 130 131 /// Sets the res reason 132 /** 133 @param res_reason brief explanation of the reason for restoring 134 the domain name 135 */ set_res_reason(const string & res_reason)136 void set_res_reason(const string &res_reason) 137 { 138 _res_reason = res_reason; 139 } 140 141 /// Returns the res reason 142 /** 143 @return brief explanation of the reason for restoring the domain 144 name 145 */ get_res_reason()146 string get_res_reason() const 147 { 148 return _res_reason; 149 } 150 151 /// Sets the statement 152 /** 153 @param statement1 text statement that the client has not restored 154 the domain name in order to assume the rights to use or sell the 155 domain name for itself or for any third party 156 */ set_statement1(const string & statement1)157 void set_statement1(const string &statement1) 158 { 159 _statement1 = statement1; 160 } 161 162 163 /// Sets the statement and language 164 /** 165 @param statement1 text statement that the client has not restored 166 the domain name in order to assume the rights to use or sell the 167 domain name for itself or for any third party 168 @param lang statement1 language 169 */ set_statement1(const string & statement1,const string & lang)170 void set_statement1(const string &statement1, const string &lang) 171 { 172 _statement1 = statement1; 173 _statement1_lang = lang; 174 } 175 176 /// Returns the statement 177 /** 178 @return text statement that the client has not restored the 179 domain name in order to assume the rights to use or sell the 180 domain name for itself or for any third party 181 */ get_statement1()182 string get_statement1() const 183 { 184 return _statement1; 185 } 186 187 /// Returns the statement language 188 /** 189 @return statement language 190 */ get_statement1_lang()191 string get_statement1_lang() const 192 { 193 return _statement1_lang; 194 } 195 196 /// Sets the statement 197 /** 198 @param statement2 text statement that the information in the 199 restore report is factual to the best of the client's knowledge 200 */ set_statement2(const string & statement2)201 void set_statement2(const string &statement2) 202 { 203 _statement2 = statement2; 204 } 205 206 /// Sets the statement and language 207 /** 208 @param statement2 text statement that the information in the 209 restore report is factual to the best of the client's knowledge 210 @param lang statement language 211 */ set_statement2(const string & statement2,const string & lang)212 void set_statement2(const string &statement2, const string &lang) 213 { 214 _statement2 = statement2; 215 _statement2_lang = lang; 216 } 217 218 /// Returns the statement 219 /** 220 @return text statement that the information in the restore report 221 is factual to the best of the client's knowledge 222 */ get_statement2()223 string get_statement2() const 224 { 225 return _statement2; 226 } 227 228 /// Returns the statement language 229 /** 230 @return statement language 231 */ get_statement2_lang()232 string get_statement2_lang() const 233 { 234 return _statement2_lang; 235 } 236 237 /// Sets the other 238 /** 239 @param other any information needed to support the statements 240 provided by the client 241 */ set_other(const string & other)242 void set_other(const string &other) 243 { 244 _other = other; 245 } 246 247 /// Returns the other 248 /** 249 @return any information needed to support the statements provided 250 by the client 251 */ get_other()252 string get_other() const 253 { 254 return _other; 255 } 256 257 /// Reset all object attributes reset()258 void reset() 259 { 260 _pre_data = ""; 261 _post_data = ""; 262 _del_time = ""; 263 _res_time = ""; 264 _res_reason = ""; 265 _statement1 = ""; 266 _statement1_lang = ""; 267 _statement2 = ""; 268 _statement2_lang = ""; 269 _other = ""; 270 } 271 272 private: 273 /// Registration data that existed for the domain name prior to the 274 /// domain name being deleted 275 string _pre_data; 276 277 /// Registration data that exists for the domain name at the time 278 /// the restore report is submitted 279 string _post_data; 280 281 /// Date and time when the domain name delete request was sent to 282 /// the server 283 string _del_time; 284 285 /// Date and time when the original <rgp:restore> command was sent 286 /// to the server 287 string _res_time; 288 289 /// Brief explanation of the reason for restoring the domain name 290 string _res_reason; 291 292 /// Text statement that the client has not restored the domain name 293 /// in order to assume the rights to use or sell the domain name for 294 /// itself or for any third party 295 string _statement1; 296 297 /// Statement1 language (by default en - english) 298 string _statement1_lang; 299 300 /// Text statement that the information in the restore report is 301 /// factual to the best of the client's knowledge 302 string _statement2; 303 304 /// Statement2 language (by default en - english) 305 string _statement2_lang; 306 307 /// Information needed to support the statements provided by the 308 /// client 309 string _other; 310 }; 311 312 /// EPP RGPRestore Class 313 class RGPRestore { 314 public: 315 /// EPP RGPRestore Operation Class 316 class Operation 317 { 318 public: 319 /// List of RGP restore operations acording to RFC 3915 320 enum Value { 321 NONE, 322 REQUEST, 323 REPORT 324 }; 325 326 /// Convert the enum value into the text value acording to RFC 327 /// 3915 328 /** 329 @param value enum value 330 @return text representation acording to RFC 3915 331 */ toString(const Value value)332 static string toString(const Value value) 333 { 334 switch(value) { 335 case NONE: 336 break; 337 case REQUEST: 338 return "request"; 339 case REPORT: 340 return "report"; 341 } 342 343 return ""; 344 } 345 fromString(const string & value)346 static Value fromString(const string &value) 347 { 348 if (value == "request") { 349 return REQUEST; 350 } else if (value == "report") { 351 return REPORT; 352 } 353 354 return NONE; 355 } 356 }; 357 358 /// Default constructor RGPRestore()359 RGPRestore() 360 { 361 this->reset(); 362 } 363 364 /// Sets the operation 365 /** 366 @param operation describes the redemption grace period operation 367 being requested 368 */ set_operation(const Operation::Value operation)369 void set_operation(const Operation::Value operation) 370 { 371 _operation = operation; 372 } 373 374 /// Returns the operation 375 /** 376 @return describes the redemption grace period operation being 377 requested 378 */ get_operation()379 Operation::Value get_operation() const 380 { 381 return _operation; 382 } 383 384 /// Sets the report 385 /** 386 @param report extra information in case of a report operation 387 */ set_report(const RGPReport & report)388 void set_report(const RGPReport &report) 389 { 390 _report = report; 391 } 392 393 /// Returns the report 394 /** 395 @return extra information in case of a report operation 396 */ get_report()397 RGPReport get_report() const 398 { 399 return _report; 400 } 401 402 /// Reset all object attributes reset()403 void reset() 404 { 405 _operation = Operation::NONE; 406 _report.reset(); 407 } 408 409 private: 410 /// Describes the redemption grace period operation being requested 411 Operation::Value _operation; 412 413 /// Extra information in case of a report operation 414 RGPReport _report; 415 }; 416 417 LIBEPP_NICBR_NS_END 418 419 #endif // __RGP_RESTORE_H__ 420