zmqpp  4.1.2
C++ bindings for 0mq (libzmq)
zap_request.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * This file is part of zmqpp.
7  * Copyright (c) 2011-2015 Contributors as noted in the AUTHORS file.
8  */
9 
17 #ifndef ZMQPP_ZAP_REQUEST_HPP_
18 #define ZMQPP_ZAP_REQUEST_HPP_
19 
20 #include <string>
21 #include "socket.hpp"
22 #include <unordered_map>
23 #include <vector>
24 
25 #if (ZMQ_VERSION_MAJOR > 3)
26 
27 namespace zmqpp
28 {
29 
35 class zap_request {
36 public:
40  zap_request(socket& handler, bool logging);
41 
45  void reply(const std::string &status_code, const std::string &status_text,
46  const std::string &user_id,
47  const std::unordered_map<std::string, std::string> &metadata_pairs = std::unordered_map<std::string, std::string>());
48 
53  static std::vector<std::uint8_t> serialize_metadata(
54  const std::unordered_map<std::string, std::string> &metadata_pairs);
55 
59  const std::string & get_version() const {
60  return version;
61  }
62 
66  const std::string & get_domain() const {
67  return domain;
68  }
69 
73  const std::string & get_address() const {
74  return address;
75  }
76 
80  const std::string & get_identity() const {
81  return identity;
82  }
83 
87  const std::string & get_mechanism() const {
88  return mechanism;
89  }
90 
94  const std::string & get_username() const {
95  return username;
96  }
97 
101  const std::string & get_password() const {
102  return password;
103  }
104 
109  const std::string & get_client_key() const {
110  return client_key;
111  }
112 
116  const std::string & get_principal() const {
117  return principal;
118  }
119 
120 private:
122  std::string version;
123  std::string sequence;
124  std::string domain;
125  std::string address;
126  std::string identity;
127  std::string mechanism;
128  std::string username;
129  std::string password;
130  std::string client_key;
131  std::string principal;
132  bool verbose;
133 
134  // No copy - private and not implemented
137 };
138 
139 }
140 
141 #endif
142 
143 #endif /* ZMQPP_ZAP_REQUEST_HPP_ */
The socket class represents the zmq sockets.
Definition: socket.hpp:76
A class for working with ZAP requests and replies.
Definition: zap_request.hpp:35
const std::string & get_password() const
Get password for PLAIN security mechanism.
Definition: zap_request.hpp:101
std::string principal
GSSAPI client principal.
Definition: zap_request.hpp:131
void reply(const std::string &status_code, const std::string &status_text, const std::string &user_id, const std::unordered_map< std::string, std::string > &metadata_pairs=std::unordered_map< std::string, std::string >())
Send a ZAP reply to the handler socket.
Definition: zap_request.cpp:78
zap_request & operator=(zap_request const &) NOEXCEPT ZMQPP_EXPLICITLY_DELETED
std::string domain
Server socket domain.
Definition: zap_request.hpp:124
std::string username
PLAIN user name.
Definition: zap_request.hpp:128
zap_request(zap_request const &) ZMQPP_EXPLICITLY_DELETED
const std::string & get_client_key() const
Definition: zap_request.hpp:109
socket & zap_socket
Socket we're talking to.
Definition: zap_request.hpp:121
static std::vector< std::uint8_t > serialize_metadata(const std::unordered_map< std::string, std::string > &metadata_pairs)
Serialize a map of metadata (name, value) pairs to ZMTP/3.0 wire format as specified in ZRFC27 (http:...
Definition: zap_request.cpp:100
std::string identity
Server socket idenntity.
Definition: zap_request.hpp:126
const std::string & get_username() const
Get username for PLAIN security mechanism.
Definition: zap_request.hpp:94
std::string address
Client IP address.
Definition: zap_request.hpp:125
const std::string & get_mechanism() const
Get Security Mechanism.
Definition: zap_request.hpp:87
std::string password
PLAIN password, in clear text.
Definition: zap_request.hpp:129
const std::string & get_principal() const
Get principal for GSSAPI security mechanism.
Definition: zap_request.hpp:116
const std::string & get_version() const
Get Version.
Definition: zap_request.hpp:59
const std::string & get_domain() const
Get Domain.
Definition: zap_request.hpp:66
std::string version
Version number, must be "1.0".
Definition: zap_request.hpp:122
bool verbose
Log ZAP requests and replies?
Definition: zap_request.hpp:132
const std::string & get_address() const
Get Address.
Definition: zap_request.hpp:73
std::string mechanism
Security mechansim.
Definition: zap_request.hpp:127
std::string sequence
Sequence number of request.
Definition: zap_request.hpp:123
std::string client_key
CURVE client public key in ASCII.
Definition: zap_request.hpp:130
const std::string & get_identity() const
Get Identity.
Definition: zap_request.hpp:80
zap_request(socket &handler, bool logging)
Receive a ZAP valid request from the handler socket.
Definition: zap_request.cpp:36
#define NOEXCEPT
Definition: compatibility.hpp:122
#define ZMQPP_EXPLICITLY_DELETED
Definition: compatibility.hpp:107
C++ wrapper around zmq.
Definition: actor.cpp:30