libepp_nicbr
Session.H
Go to the documentation of this file.
1 /* ${copyright}$ */
2 /* $Id: Session.H 1237 2014-11-12 13:02:37Z rafael $ */
7 #ifndef __SESSION_H__
8 #define __SESSION_H__
9 
10 #include <map>
11 
12 #include "libepp_nicbr.H"
13 
14 #include "DomParser.H"
15 #include "TransportTLS.H"
16 #include "Greeting.H"
17 #include "Action.H"
18 
19 //for systems that don't have srandomdev (e.g. Linux)
20 #ifndef HAVE_SRANDOMDEV
21 #define srandomdev() srand((unsigned) time(NULL))
22 #endif
23 
24 using std::auto_ptr;
25 using std::map;
26 
27 LIBEPP_NICBR_NS_BEGIN
28 
30 class Session
31 {
32 public:
34 
39  Session(const string &server = "localhost", const int port = 700,
40  const string &templates_dir = TEMPLATESDIR);
41 
43  ~Session();
44 
46 
49  void enable_xml_validation(const string &schemas_dir = SCHEMASDIR);
50 
53 
56 
59 
61 
66  void connect(const string &client_cert_file, const string &root_ca_file,
67  const string &pem_passphrase = "");
68 
70  void disconnect();
71 
73  void send_hello();
74 
76 
80 
82 
86  void process_action(Action *action_to_be_processed,
87  const string clTRID = "");
88 
90 
93  void runXML(const string& input);
94 
96 
99  string get_last_command() const;
100 
102 
105  string get_last_response() const;
106 
108 
111  string get_server() const;
112 
114 
117  int get_port() const;
118 
120 
123  void set_server(const string &server);
124 
126 
129  void set_port(const int &port);
130 
135 
138  void set_clTrID(const string &clTRID);
139 
142 
145  string get_clTrID() const;
146 
147 private:
149 
152  void read_templates(const string &templates_dir = TEMPLATESDIR);
153 
155  auto_ptr<DomParser> _parser;
156 
158  auto_ptr<TransportTLS> _transport;
159 
161  auto_ptr<Greeting> _greeting;
162 
164  map < ActionType, string, less<ActionType> > _templates;
165 
167  string _last_command;
168 
170  string _last_response;
171 
173  string _server;
174 
176  int _port;
177 
179  bool _cert_common_name_check_enabled;
180 
182  string _clTRID;
183 };
184 
185 
186 LIBEPP_NICBR_NS_END
187 #endif //__SESSION_H__
string get_last_command() const
Get last command.
void connect(const string &client_cert_file, const string &root_ca_file, const string &pem_passphrase="")
Establish the Connection.
void process_action(Action *action_to_be_processed, const string clTRID="")
Process Action.
void runXML(const string &input)
Send XML input command.
void send_hello()
Send Hello.
Project defines.
EPP DomParser Class.
void enable_xml_validation(const string &schemas_dir=SCHEMASDIR)
Enable XML Parser Validation.
TransportTLS class.
void set_server(const string &server)
Set EPP server name.
EPP Action Class.
Greeting * get_greeting()
Get Greeting.
EPP Action Class.
Definition: Action.H:24
void disconnect()
Close the connection.
void set_clTrID(const string &clTRID)
string get_clTrID() const
EPP Greeting Class.
EPP Session Class.
Definition: Session.H:30
int get_port() const
Get EPP server port.
EPP Greeting Class.
Definition: Greeting.H:21
void set_port(const int &port)
Set EPP server port.
string get_last_response() const
Get last response.
void disable_cert_common_name_check()
Disables peer's certificate common name check.
~Session()
Destructor.
void disable_xml_validation()
Disable XML Parser Validation.
void enable_cert_common_name_check()
Enables peer's certificate common name check.
string get_server() const
Get EPP server.
Session(const string &server="localhost", const int port=700, const string &templates_dir=TEMPLATESDIR)
Constructor.