libepp_nicbr
CommonData.H
Go to the documentation of this file.
1 /* ${copyright}$ */
2 /* $Id: CommonData.H 1263 2014-12-02 20:41:04Z mendelson $ */
7 #ifndef __COMMON_DATA_H__
8 #define __COMMON_DATA_H__
9 
10 #include <string>
11 #include <vector>
12 #include <set>
13 
14 #include "libepp_nicbr.H"
15 
16 using std::string;
17 using std::vector;
18 using std::set;
19 
20 LIBEPP_NICBR_NS_BEGIN
21 
23 enum ActionType {
24  UNSET_ACTION = -1,
25  LOGIN = 0,
26  LOGOUT,
27  HELLO,
28  POLL,
29  GREETING,
30  CONTACT_CHECK = 10,
31  CONTACT_CREATE,
32  CONTACT_INFO,
33  CONTACT_TRANSFER,
34  CONTACT_UPDATE,
35  CONTACT_PANDATA,
36  CONTACT_DELETE,
37  DOMAIN_CHECK = 20,
38  DOMAIN_CREATE,
39  DOMAIN_INFO,
40  DOMAIN_TRANSFER,
41  DOMAIN_RENEW,
42  DOMAIN_UPDATE,
43  DOMAIN_PANDATA,
44  DOMAIN_DELETE,
45  BR_ORG_CHECK = 30,
46  BR_ORG_INFO,
47  BR_ORG_CREATE,
48  BR_ORG_UPDATE,
49  BR_ORG_PANDATA,
50  BR_ORG_DELETE,
51  BR_DOMAIN_CHECK = 40,
52  BR_DOMAIN_INFO,
53  BR_DOMAIN_CREATE,
54  BR_DOMAIN_RENEW,
55  BR_DOMAIN_UPDATE,
56  BR_DOMAIN_PANDATA,
57  IP_NETWORK_CREATE = 50,
58  IP_NETWORK_CHECK,
59  IP_NETWORK_DELETE,
60  IP_NETWORK_RENEW,
61  IP_NETWORK_TRANSFER,
62  IP_NETWORK_INFO,
63  IP_NETWORK_UPDATE,
64  ASN_CHECK = 60,
65  ASN_CREATE,
66  ASN_DELETE,
67  ASN_RENEW,
68  ASN_TRANSFER,
69  ASN_INFO,
70  ASN_UPDATE,
71  DEF_REG_CHECK = 70,
72  DEF_REG_INFO,
73  DEF_REG_TRANSFER,
74  DEF_REG_CREATE,
75  DEF_REG_DELETE,
76  DEF_REG_RENEW,
77  DEF_REG_UPDATE,
78  ASN_RESERVE_CREATE = 80,
79  ASN_RESERVE_DELETE
80 };
81 
83 class AuthInfo {
84 public:
85  AuthInfo& operator=(const AuthInfo &authInfo) {
86  _roid = authInfo._roid;
87  _roid_f = authInfo._roid_f;
88  _pw = authInfo._pw;
89  _pw_f = authInfo._pw_f;
90  return *this;
91  }
92 
95  {
96  this->reset();
97  }
98 
100 
103  void set_roid(const string& roid)
104  {
105  _roid = roid;
106  if (roid != "") {
107  _roid_f = true;
108  }
109  }
110 
112 
115  string get_roid() const { return _roid; }
116 
118 
121  bool get_roid_f() const
122  {
123  return _roid_f;
124  }
125 
127 
130  void set_pw(const string& pw)
131  {
132  _pw = pw;
133  _pw_f = true;
134  }
135 
137 
140  string get_pw() const { return _pw; }
141 
143 
146  bool get_pw_f() const
147  {
148  return _pw_f;
149  }
150 
152  void reset()
153  {
154  _roid = "";
155  _roid_f = false;
156  _pw = "";
157  _pw_f = false;
158  }
159 
160 protected:
162  string _roid;
163 
165  bool _roid_f;
166 
168  string _pw;
169 
171  bool _pw_f;
172 
173 };
174 
175 struct NSIPAddr {
176  string version;
177  string addr;
178  bool operator<(const NSIPAddr &ip) const {
179  return addr < ip.addr;
180  }
181 };
182 
183 struct NameServer {
184  string name;
185  set<NSIPAddr> ips;
186  bool operator<(const NameServer &n) const {
187  return name < n.name;
188  }
189 };
190 
192 class IpRange
193 {
194 public:
195  IpRange() {
196  this->reset();
197  }
198 
199  bool operator<(const IpRange &ipRange) const
200  {
201  if (_ipBegin.compare(ipRange._ipBegin) < 0) {
202  return true;
203  }
204 
205  if (_ipBegin.compare(ipRange._ipBegin) == 0) {
206  if (_ipEnd.compare(ipRange._ipEnd) < 0) {
207  return true;
208  }
209 
210  return false;
211  }
212 
213  return false;
214  }
215 
216  void reset()
217  {
218  _version = "";
219  _ipBegin = "";
220  _ipEnd = "";
221  _available = false;
222  }
223 
224  void set_version(const string &version)
225  {
226  _version = version;
227  }
228 
229  string get_version() const
230  {
231  return _version;
232  }
233 
234  void set_ipBegin(const string &ipBegin)
235  {
236  _ipBegin = ipBegin;
237  }
238 
239  string get_ipBegin() const
240  {
241  return _ipBegin;
242  }
243 
244  void set_ipEnd(const string &ipEnd)
245  {
246  _ipEnd = ipEnd;
247  }
248 
249  string get_ipEnd() const
250  {
251  return _ipEnd;
252  }
253 
254  void set_available(const bool &available)
255  {
256  _available = available;
257  }
258 
259  bool get_available() const
260  {
261  return _available;
262  }
263 
264 private:
265  string _version;
266  string _ipBegin;
267  string _ipEnd;
268 
269  // Used in ip range check command
270  bool _available;
271 };
272 
273 #if USE_IP_MANAGEMENT
274 struct ReverseDns {
275  IpRange ipRange;
276  vector<string> nameservers;
277 };
278 #endif //USE_IP_MANAGEMENT
279 
281 class PostalInfo {
282 public:
283  PostalInfo() {
284  this->reset();
285  }
286 
287  void reset() {
288  _type_f = false;
289  _name_f = false;
290  _org_f = false;
291  _str1_f = false;
292  _str2_f = false;
293  _str3_f = false;
294  _city_f = false;
295  _sp_f = false;
296  _pc_f = false;
297  _cc_f = false;
298  }
299 
300  string get_type() const
301  {
302  return _type;
303  }
304 
305  void set_type(const string& type)
306  {
307  _type = type;
308  _type_f = true;
309  }
310 
311  string get_name() const
312  {
313  return _name;
314  }
315 
316  void set_name(const string& name)
317  {
318  _name = name;
319  _name_f = true;
320  }
321 
322  string get_org() const
323  {
324  return _org;
325  }
326 
327  void set_org(const string& org)
328  {
329  _org = org;
330  _org_f = true;
331  }
332 
333  string get_str1() const
334  {
335  return _str1;
336  }
337 
338  void set_str1(const string& str1)
339  {
340  _str1 = str1;
341  _str1_f = true;
342  }
343 
344  string get_str2() const
345  {
346  return _str2;
347  }
348 
349  void set_str2(const string& str2)
350  {
351  _str2 = str2;
352  _str2_f = true;
353  }
354 
355  string get_str3() const
356  {
357  return _str3;
358  }
359 
360  void set_str3(const string& str3)
361  {
362  _str3 = str3;
363  _str3_f = true;
364  }
365 
366  string get_city() const
367  {
368  return _city;
369  }
370 
371  void set_city(const string& city)
372  {
373  _city = city;
374  _city_f = true;
375  }
376 
377  string get_sp() const
378  {
379  return _sp;
380  }
381 
382  void set_sp(const string& sp)
383  {
384  _sp = sp;
385  _sp_f = true;
386  }
387 
388  string get_pc() const
389  {
390  return _pc;
391  }
392 
393  void set_pc(const string& pc)
394  {
395  _pc = pc;
396  _pc_f = true;
397  }
398 
399  string get_cc() const
400  {
401  return _cc;
402  }
403 
404  void set_cc(const string& cc)
405  {
406  _cc = cc;
407  _cc_f = true;
408  }
409 
410  bool get_type_f() const
411  {
412  return _type_f;
413  }
414 
415  bool get_name_f() const
416  {
417  return _name_f;
418  }
419 
420  bool get_org_f() const
421  {
422  return _org_f;
423  }
424 
425  bool get_str1_f() const
426  {
427  return _str1_f;
428  }
429 
430  bool get_str2_f() const
431  {
432  return _str2_f;
433  }
434 
435  bool get_str3_f() const
436  {
437  return _str3_f;
438  }
439 
440  bool get_city_f() const
441  {
442  return _city_f;
443  }
444 
445  bool get_sp_f() const
446  {
447  return _sp_f;
448  }
449 
450  bool get_pc_f() const
451  {
452  return _pc_f;
453  }
454 
455  bool get_cc_f() const
456  {
457  return _cc_f;
458  }
459 
460 private:
461  //Flags for PostalInfo attributes
462  bool _type_f;
463  bool _name_f;
464  bool _org_f;
465  bool _str1_f;
466  bool _str2_f;
467  bool _str3_f;
468  bool _city_f;
469  bool _sp_f;
470  bool _pc_f;
471  bool _cc_f;
472 
473  //PostalInfo attributes
474  string _type;
475  string _name;
476  string _org;
477  string _str1;
478  string _str2;
479  string _str3;
480  string _city;
481  string _sp;
482  string _pc;
483  string _cc;
484 };
485 
488 {
489 public:
490 
491  struct Disclose {
492  int flag;
493 
494  bool name_int;
495  bool name_loc;
496  bool org_int;
497  bool org_loc;
498  bool addr_int;
499  bool addr_loc;
500  bool voice;
501  bool fax;
502  bool email;
503 
504  Disclose() {
505  flag = -1;
506  name_int = false;
507  name_loc = false;
508  org_int = false;
509  org_loc = false;
510  addr_int = false;
511  addr_loc = false;
512  voice = false;
513  fax = false;
514  email = false;
515  }
516 
517  bool is_set() {
518  return ((flag == 0 || flag == 1) &&
519  (name_int || name_loc || org_int || org_loc || addr_int ||
520  addr_loc || voice || fax || email));
521  }
522  };
523 
524  struct Phone {
525  string ext;
526  string number;
527  };
528 
531  {
532  this->reset();
533  }
534 
536 
539  void set_id(const string &id);
540 
542 
545  void insert_postal_info(const PostalInfo& postal_info);
546 
548 
551  void set_voice(const Phone& voice);
552 
554 
557  void set_fax(const Phone& fax);
558 
560 
563  void set_email(const string &email);
564 
566 
569  void set_disclose(const Disclose &disclose);
570 
572 
575  string get_id() const;
576 
578 
581  vector<PostalInfo> get_postal_info() const;
582 
584 
587  Phone get_voice() const;
588 
590 
593  bool get_voice_f() const
594  {
595  return _voice_f;
596  }
597 
599 
602  Phone get_fax() const;
603 
605 
608  bool get_fax_f() const
609  {
610  return _fax_f;
611  }
612 
614 
617  string get_email() const;
618 
620 
623  bool get_email_f() const
624  {
625  return _email_f;
626  }
627 
629 
632  Disclose get_disclose() const;
633 
635  void reset();
636 
637 protected:
638 
640  string _id;
641 
643  vector<PostalInfo> _postal_info;
644 
647 
649  bool _voice_f;
650 
653 
655  bool _fax_f;
656 
658  string _email;
659 
661  bool _email_f;
662 
665 };
666 
668 {
669 public:
670  enum Value {
671  UNDEFINED,
672  NORMAL,
673  SUSPENDED
674  };
675 };
676 
679 {
680 public:
682  enum Value {
683  NONE,
684  ADD_PERIOD,
685  AUTO_RENEW_PERIOD,
686  RENEW_PERIOD,
687  TRANSFER_PERIOD,
688  PENDING_DELETE,
689  PENDING_RESTORE,
690  REDEMPTION_PERIOD,
691  };
692 
694 
698  static Value stringToStatus(const string &value) {
699  if (value == "addPeriod") {
700  return ADD_PERIOD;
701  } else if (value == "autoRenewPeriod") {
702  return AUTO_RENEW_PERIOD;
703  } else if (value == "renewPeriod") {
704  return RENEW_PERIOD;
705  } else if (value == "transferPeriod") {
706  return TRANSFER_PERIOD;
707  } else if (value == "pendingDelete") {
708  return PENDING_DELETE;
709  } else if (value == "pendingRestore") {
710  return PENDING_RESTORE;
711  } else if (value == "redemptionPeriod") {
712  return REDEMPTION_PERIOD;
713  }
714 
715  return NONE;
716  }
717 
719 
723  static string statusToString(const Value value) {
724  switch(value) {
725  case NONE:
726  break;
727  case ADD_PERIOD:
728  return "addPeriod";
729  case AUTO_RENEW_PERIOD:
730  return "autoRenewPeriod";
731  case RENEW_PERIOD:
732  return "renewPeriod";
733  case TRANSFER_PERIOD:
734  return "transferPeriod";
735  case PENDING_DELETE:
736  return "pendingDelete";
737  case PENDING_RESTORE:
738  return "pendingRestore";
739  case REDEMPTION_PERIOD:
740  return "redemptionPeriod";
741  }
742 
743  return "";
744  }
745 };
746 
749 {
750 public:
752  enum Value {
753  NONE,
754  PREMIUM,
755  STANDARD
756  };
757 
760  /*
761  @param level Enum name's level
762  @return text representation of the level
763  */
764  static string toStr(const Value level)
765  {
766  switch(level) {
767  case NONE:
768  break;
769  case PREMIUM:
770  return "premium";
771  case STANDARD:
772  return "standard";
773  }
774 
775  return "";
776  }
777 
780  /*
781  @param level text based level
782  @return enum representation of the level
783  */
784  static Value fromStr(const string &level)
785  {
786  if (level == "premium") {
787  return PREMIUM;
788  } else if (level == "standard") {
789  return STANDARD;
790  }
791 
792  return NONE;
793  }
794 };
795 
798 {
799 public:
802  _name(""),
803  _level(DefRegLevel::NONE)
804  {
805  }
806 
808  /*
809  @param name Defensive registration name
810  @param level Name's level
811  */
812  DefRegName(const string &name, const DefRegLevel::Value level) :
813  _name(name),
814  _level(level)
815  {
816  }
817 
821  /*
822  @param other other Name object
823  @return true if one name is less than the other or false otherwise
824  */
825  bool operator<(const DefRegName &other) const
826  {
827  return _name < other._name;
828  }
829 
831  /*
832  @param name name
833  */
834  void set_name(const string &name)
835  {
836  _name = name;
837  }
838 
840  /*
841  @return name
842  */
843  string get_name() const
844  {
845  return _name;
846  }
847 
849  /*
850  @param level name's level
851  */
852  void set_level(const DefRegLevel::Value level)
853  {
854  _level = level;
855  }
856 
858  /*
859  @return name's level
860  */
862  {
863  return _level;
864  }
865 
867  void reset()
868  {
869  _name = "";
870  _level = DefRegLevel::NONE;
871  }
872 
873 private:
875  string _name;
877  DefRegLevel::Value _level;
878 };
879 
882 {
883 public:
885  enum Value {
886  NONE,
887  QUERY,
888  REQUEST,
889  CANCEL,
890  APPROVE,
891  REJECT
892  };
893 
896  /*
897  @param operation transfer operation
898  @return text representation of the operation
899  */
900  static string toStr(const Value operation) {
901  switch(operation) {
902  case NONE:
903  break;
904  case QUERY:
905  return "query";
906  case REQUEST:
907  return "request";
908  case CANCEL:
909  return "cancel";
910  case APPROVE:
911  return "approve";
912  case REJECT:
913  return "reject";
914  }
915 
916  return "";
917  }
918 
921  /*
922  @param operationStr text based operation
923  @return enum representation of the operation
924  */
925  static Value fromStr(const string operationStr) {
926  if (operationStr == "query") {
927  return QUERY;
928  } else if (operationStr == "request") {
929  return REQUEST;
930  } else if (operationStr == "cancel") {
931  return CANCEL;
932  } else if (operationStr == "approve") {
933  return APPROVE;
934  } else if (operationStr == "reject") {
935  return REJECT;
936  }
937 
938  return NONE;
939  }
940 };
941 
942 LIBEPP_NICBR_NS_END
943 #endif //__COMMON_DATA_H__
void set_level(const DefRegLevel::Value level)
Sets the name's level.
Definition: CommonData.H:852
string _id
Contact id.
Definition: CommonData.H:640
void set_name(const string &name)
Sets the name.
Definition: CommonData.H:834
DefRegName()
Default constructor.
Definition: CommonData.H:801
CommonData()
Constructor.
Definition: CommonData.H:530
void set_id(const string &id)
Sets the object's id.
string _pw
password
Definition: CommonData.H:168
bool get_email_f() const
Returns the object's email change flag.
Definition: CommonData.H:623
static Value stringToStatus(const string &value)
Convert a text based status into a enum status.
Definition: CommonData.H:698
string get_email() const
Returns the object's email.
Value
Possible operation values.
Definition: CommonData.H:885
Project defines.
Disclose get_disclose() const
Returns the object's disclosure policy.
void set_disclose(const Disclose &disclose)
Sets the object's disclosure policy.
bool get_fax_f() const
Returns the object's fax change flag.
Definition: CommonData.H:608
void set_email(const string &email)
Sets the object's email.
EPP defensive registration Name Class.
Definition: CommonData.H:797
Definition: CommonData.H:183
Definition: CommonData.H:667
Phone _fax
Contact's fax (optional)
Definition: CommonData.H:652
string _roid
repository object ID
Definition: CommonData.H:162
EPP RGP Status Class.
Definition: CommonData.H:678
PostalInfo class.
Definition: CommonData.H:281
vector< PostalInfo > _postal_info
Postal Info list (just 1 or 2 elements)
Definition: CommonData.H:643
void set_roid(const string &roid)
Sets repository object ID.
Definition: CommonData.H:103
void set_fax(const Phone &fax)
Sets the object's fax number.
Value
Possible name's values.
Definition: CommonData.H:752
void insert_postal_info(const PostalInfo &postal_info)
Inserts postal information into the object.
string get_roid() const
Returns repository object ID.
Definition: CommonData.H:115
Describes IpRange structure.
Definition: CommonData.H:192
EPP defensive registration Level Class.
Definition: CommonData.H:748
Phone get_fax() const
Returns the object's fax number.
static string toStr(const Value operation)
Definition: CommonData.H:900
bool get_pw_f() const
Returns the password change flag.
Definition: CommonData.H:146
static string statusToString(const Value value)
Convert a enum based status into a text status.
Definition: CommonData.H:723
void set_voice(const Phone &voice)
Sets the object's voice telephone number.
AuthInfo()
Default constructor.
Definition: CommonData.H:94
Phone _voice
Contact's voice telephone number (optional)
Definition: CommonData.H:646
bool get_roid_f() const
Returns the roid change flag.
Definition: CommonData.H:121
void reset()
Reset all object attributes.
Definition: CommonData.H:152
Definition: CommonData.H:491
string get_name() const
Returns the name.
Definition: CommonData.H:843
vector< PostalInfo > get_postal_info() const
Returns the object's postal information.
static Value fromStr(const string operationStr)
Definition: CommonData.H:925
bool operator<(const DefRegName &other) const
Definition: CommonData.H:825
bool _pw_f
password change flag
Definition: CommonData.H:171
EPP CommonData Class.
Definition: CommonData.H:487
Value
List of RGP status acording to RFC 3915.
Definition: CommonData.H:682
Phone get_voice() const
Returns the object's voice telephone number.
ActionType
Action Types.
Definition: CommonData.H:23
string get_pw() const
Returns the password.
Definition: CommonData.H:140
Disclose _disclose
Disclose information (optional)
Definition: CommonData.H:664
EPP Transfer Operation Class.
Definition: CommonData.H:881
DefRegName(const string &name, const DefRegLevel::Value level)
Constructor.
Definition: CommonData.H:812
bool _roid_f
roid change flag
Definition: CommonData.H:165
bool get_voice_f() const
Returns the object's voice change flag.
Definition: CommonData.H:593
Definition: CommonData.H:524
bool _email_f
E-mail change flag.
Definition: CommonData.H:661
DefRegLevel::Value get_level() const
Return name's level.
Definition: CommonData.H:861
bool _voice_f
Voice change flag.
Definition: CommonData.H:649
Definition: CommonData.H:175
static Value fromStr(const string &level)
Definition: CommonData.H:784
void reset()
Resets object attributes.
Definition: CommonData.H:867
string get_id() const
Returns the object's id.
bool _fax_f
Fax change flag.
Definition: CommonData.H:655
string _email
Contact's email.
Definition: CommonData.H:658
void set_pw(const string &pw)
Sets password.
Definition: CommonData.H:130
static string toStr(const Value level)
Definition: CommonData.H:764
AuthInfo Class.
Definition: CommonData.H:83
void reset()
reset attributes