22 #ifdef HAVE_SASL_SASL_H
25 #include <boost/shared_ptr.hpp>
26 #include <boost/scoped_ptr.hpp>
27 #include <boost/thread/locks.hpp>
28 #include <boost/thread/thread.hpp>
30 #include <thrift/transport/TBufferTransports.h>
40 namespace apache {
namespace thrift {
namespace transport {
41 TSaslServerTransport::TSaslServerTransport(shared_ptr<TTransport> transport)
47 const string& serverName,
50 const map<string, string>& props,
51 const vector<struct sasl_callback>& callbacks,
52 shared_ptr<TTransport> transport)
54 addServerDefinition(mechanism, protocol, serverName, realm, flags,
59 const std::map<std::string, TSaslServerDefinition*>& serverMap,
60 boost::shared_ptr<TTransport> transport)
71 TTransportException::INTERNAL_ERROR,
"Setting server in client transport");
73 sasl_.reset(saslServer);
83 string message_str(reinterpret_cast<char*>(message), resLength);
87 ss <<
"Expecting START status, received " << status;
89 reinterpret_cast<const uint8_t*>(ss.str().c_str()), ss.str().size());
92 map<string, TSaslServerDefinition*>::iterator defn =
96 ss <<
"Unsupported mechanism type " << message_str;
98 reinterpret_cast<const uint8_t*>(ss.str().c_str()), ss.str().size());
109 sasl_->evaluateChallengeOrResponse(
110 reinterpret_cast<const uint8_t*>(message_str.c_str()), resLength, &resLength);
115 shared_ptr<TTransport> trans) {
137 map<shared_ptr<TTransport>, shared_ptr<TBufferedTransport> >::iterator trans_map =
139 VLOG_EVERY_N(2, 100) <<
"getTransport(): transportMap_ size is: "
141 shared_ptr<TBufferedTransport> ret_transport;
144 ret_transport.reset(
new TBufferedTransport(wrapped));
145 ret_transport.get()->open();
148 ret_transport = trans_map->second;
151 return ret_transport;
boost::mutex transportMap_mutex_
std::map< boost::shared_ptr< TTransport >, boost::shared_ptr< TBufferedTransport > > transportMap_
const StringSearch UrlParser::protocol_search & protocol
void setSaslServer(sasl::TSasl *saslServer)
virtual void handleSaslStartMessage()
void sendSaslMessage(const NegotiationStatus status, const uint8_t *payload, const uint32_t length, bool flush=true)
bool isClient_
True if this is a client.
std::map< std::string, TSaslServerDefinition * > serverDefinitionMap_
TSaslServerTransport(const std::map< std::string, TSaslServerDefinition * > &serverMap, boost::shared_ptr< TTransport > transport)
boost::shared_ptr< sasl::TSasl > sasl_
std::vector< struct sasl_callback > callbacks_
virtual boost::shared_ptr< TTransport > getTransport(boost::shared_ptr< TTransport > trans)
std::map< std::string, TSaslServerDefinition * > serverDefinitionMap_
uint8_t * receiveSaslMessage(NegotiationStatus *status, uint32_t *length)