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  DomainInfoCmd.H
27  *  @brief EPP DomainInfoCmd Class
28  */
29 
30 #ifndef __DOMAIN_INFO_CMD_H__
31 #define __DOMAIN_INFO_CMD_H__
32 
33 #include <string>
34 
35 #include "libepp_nicbr.H"
36 
37 #include "Command.H"
38 #include "CommonData.H"
39 #include "LaunchInfoCmd.H"
40 
41 using std::string;
42 
43 LIBEPP_NICBR_NS_BEGIN
44 
45 /// EPP DomainInfoCmd Class
46 class DomainInfoCmd : public Command
47 {
48 public:
49 
50 	/// Default constructor
Command(false)51 	DomainInfoCmd(bool reset = true) : Command(false)
52 	{
53 		if (reset) {
54 			this->reset();
55 		}
56 	}
57 
58 	/// Sets domain name
59 	/**
60 	   @param name   fully qualified domain name
61 	*/
set_name(const string & name)62 	void set_name(const string& name) { _name = name; }
63 
64 	/// Returns domain name
65 	/**
66 	   @return fully qualified domain name
67 	*/
get_name()68 	string get_name() const { return _name; }
69 
70 	/*! @brief Sets "hosts" attribute which controls return of information
71 	 *  describing hosts
72 	 */
73 	/**
74 	   @param hosts_control   "all" (default), "del", "sub", "none"
75 	*/
set_hosts_control(const string & hosts_control)76 	void set_hosts_control(const string& hosts_control)
77 	{
78 		_hosts_control = hosts_control;
79 	}
80 
81 	/// Returns hosts control attribute
82 	/**
83 	   @return hosts control attribute
84 	*/
get_hosts_control()85 	string get_hosts_control() const { return _hosts_control; }
86 
87 	/// Sets authorization information
88 	/**
89 	   @param authInfo   domain authorization information
90 	*/
set_authInfo(const AuthInfo & authInfo)91 	void set_authInfo(const AuthInfo &authInfo)
92 	{
93 		_authInfo = authInfo;
94 	}
95 
96 	/// Returns authorization information
97 	/**
98 	   @return authorization information
99 	*/
get_authInfo()100 	AuthInfo get_authInfo() const { return _authInfo; }
101 
102 	/// Sets the launch
103 	/**
104 	 * @param launch launch
105 	 */
set_launch(const LaunchInfoCmd & launch)106 	void set_launch(const LaunchInfoCmd &launch) { _launch = launch; }
107 
108 	/// Returns the launch
109 	/**
110 	 * @return launch
111 	 */
get_launch()112 	LaunchInfoCmd get_launch() const { return _launch; }
113 
114 	/// Check if there is any extension
has_extension()115 	bool has_extension() const {
116 		return has_launch_extension();
117 	}
118 
119 	/// Check if there is launch extension
has_launch_extension()120 	bool has_launch_extension() const {
121 		return _launch.get_phase().get_phase() != LaunchPhase::NONE;
122 	}
123 
124 	/// Reset object attributes
reset()125 	void reset()
126 	{
127 		Command::reset();
128 		_name = "";
129 		_hosts_control = "all";
130 		_authInfo.reset();
131 		_launch.reset();
132 	}
133 
134 protected:
135 	/// fully qualified domain name
136 	string _name;
137 
138 	/// controls return of information describing hosts related to
139 	/// domain object
140 	string _hosts_control;
141 
142 	/// authorization information
143 	AuthInfo _authInfo;
144 
145 	/// Launch
146 	LaunchInfoCmd _launch;
147 };
148 
149 LIBEPP_NICBR_NS_END
150 #endif //__DOMAIN_INFO_CMD_H__
151