TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LoginRESTService Class Reference

#include <LoginRESTService.h>

Classes

struct  ContentTypePlugin
 
struct  LoginTicket
 
struct  ResponseCodePlugin
 

Public Member Functions

 LoginRESTService ()
 
bool Start (boost::asio::io_service &ioService)
 
void Stop ()
 
boost::asio::ip::tcp::endpoint
const
GetAddressForClient (boost::asio::ip::address const &address) const
 
std::unique_ptr
< Battlenet::Session::AccountInfo
VerifyLoginTicket (std::string const &id)
 

Static Public Member Functions

static LoginRESTServiceInstance ()
 

Private Member Functions

void Run ()
 
int32 HandleGet (soap *soapClient)
 
int32 HandlePost (soap *soapClient)
 
int32 SendResponse (soap *soapClient, google::protobuf::Message const &response)
 
std::string CalculateShaPassHash (std::string const &name, std::string const &password)
 
void AddLoginTicket (std::string const &id, std::unique_ptr< Battlenet::Session::AccountInfo > accountInfo)
 
void CleanupLoginTickets (boost::system::error_code const &error)
 

Private Attributes

std::thread _thread
 
std::atomic< bool_stopped
 
Battlenet::JSON::Login::FormInputs _formInputs
 
std::string _bindIP
 
int32 _port
 
boost::asio::ip::tcp::endpoint _externalAddress
 
boost::asio::ip::tcp::endpoint _localAddress
 
std::mutex _loginTicketMutex
 
std::unordered_map
< std::string, LoginTicket
_validLoginTickets
 
boost::asio::deadline_timer * _loginTicketCleanupTimer
 

Friends

int32 handle_get_plugin (soap *soapClient)
 
int32 handle_post_plugin (soap *soapClient)
 

Constructor & Destructor Documentation

LoginRESTService::LoginRESTService ( )
inline
38 : _stopped(false), _port(0) { }
int32 _port
Definition: LoginRESTService.h:100
std::atomic< bool > _stopped
Definition: LoginRESTService.h:97

Member Function Documentation

void LoginRESTService::AddLoginTicket ( std::string const id,
std::unique_ptr< Battlenet::Session::AccountInfo accountInfo 
)
private
338 {
339  std::unique_lock<std::mutex> lock(_loginTicketMutex);
340 
341  _validLoginTickets[id] = { id, std::move(accountInfo), time(nullptr) + 10 };
342 }
std::mutex _loginTicketMutex
Definition: LoginRESTService.h:103
std::unordered_map< std::string, LoginTicket > _validLoginTickets
Definition: LoginRESTService.h:104

+ Here is the caller graph for this function:

std::string LoginRESTService::CalculateShaPassHash ( std::string const name,
std::string const password 
)
private
305 {
306  SHA256Hash email;
307  email.UpdateData(name);
308  email.Finalize();
309 
310  SHA256Hash sha;
311  sha.UpdateData(ByteArrayToHexStr(email.GetDigest(), email.GetLength()));
312  sha.UpdateData(":");
313  sha.UpdateData(password);
314  sha.Finalize();
315 
316  return ByteArrayToHexStr(sha.GetDigest(), sha.GetLength(), true);
317 }
Definition: SHA256.h:28
uint8 * GetDigest(void)
Definition: SHA256.h:44
void UpdateData(const uint8 *dta, int len)
Definition: SHA256.cpp:34
std::string ByteArrayToHexStr(uint8 const *bytes, uint32 arrayLen, bool reverse)
Definition: Util.cpp:509
void Finalize()
Definition: SHA256.cpp:64
int GetLength(void) const
Definition: SHA256.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void LoginRESTService::CleanupLoginTickets ( boost::system::error_code const error)
private
345 {
346  if (error)
347  return;
348 
349  time_t now = time(nullptr);
350 
351  {
352  std::unique_lock<std::mutex> lock(_loginTicketMutex);
353  for (auto itr = _validLoginTickets.begin(); itr != _validLoginTickets.end();)
354  {
355  if (itr->second.ExpiryTime < now)
356  itr = _validLoginTickets.erase(itr);
357  else
358  ++itr;
359  }
360  }
361 
363  _loginTicketCleanupTimer->async_wait(std::bind(&LoginRESTService::CleanupLoginTickets, this, std::placeholders::_1));
364 }
void CleanupLoginTickets(boost::system::error_code const &error)
Definition: LoginRESTService.cpp:344
std::mutex _loginTicketMutex
Definition: LoginRESTService.h:103
boost::asio::deadline_timer * _loginTicketCleanupTimer
Definition: LoginRESTService.h:105
float seconds()
Definition: units.h:97
std::unordered_map< std::string, LoginTicket > _validLoginTickets
Definition: LoginRESTService.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

boost::asio::ip::tcp::endpoint const & LoginRESTService::GetAddressForClient ( boost::asio::ip::address const address) const
116 {
117  if (address.is_loopback())
118  return _localAddress;
119  else if (_localAddress.address().is_loopback())
120  return _externalAddress;
121 
122  if (boost::asio::ip::address_v4::netmask(_localAddress.address().to_v4()).to_ulong() & address.to_v4().to_ulong())
123  return _localAddress;
124 
125  return _externalAddress;
126 }
boost::asio::ip::tcp::endpoint _localAddress
Definition: LoginRESTService.h:102
boost::asio::ip::tcp::endpoint _externalAddress
Definition: LoginRESTService.h:101
int32 LoginRESTService::HandleGet ( soap soapClient)
private
187 {
188  boost::asio::ip::address_v4 address(soapClient->ip);
189  std::string ip_address = address.to_string();
190 
191  TC_LOG_DEBUG("server.rest", "[%s:%d] Handling GET request path=\"%s\"", ip_address.c_str(), soapClient->port, soapClient->path);
192 
193  static std::string const expectedPath = "/bnetserver/login/";
194  if (strstr(soapClient->path, expectedPath.c_str()) != &soapClient->path[0])
195  return 404;
196 
197  return SendResponse(soapClient, _formInputs);
198 }
unsigned long ip
Definition: stdsoap2.h:2097
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
char path[SOAP_TAGLEN]
Definition: stdsoap2.h:2093
int port
Definition: stdsoap2.h:2098
Battlenet::JSON::Login::FormInputs _formInputs
Definition: LoginRESTService.h:98
int32 SendResponse(soap *soapClient, google::protobuf::Message const &response)
Definition: LoginRESTService.cpp:295

+ Here is the call graph for this function:

int32 LoginRESTService::HandlePost ( soap soapClient)
private
201 {
202  boost::asio::ip::address_v4 address(soapClient->ip);
203  std::string ip_address = address.to_string();
204 
205  TC_LOG_DEBUG("server.rest", "[%s:%d] Handling POST request path=\"%s\"", ip_address.c_str(), soapClient->port, soapClient->path);
206 
207  static std::string const expectedPath = "/bnetserver/login/";
208  if (strstr(soapClient->path, expectedPath.c_str()) != &soapClient->path[0])
209  return 404;
210 
211  char *buf;
212  size_t len;
213  soap_http_body(soapClient, &buf, &len);
214 
217  if (!JSON::Deserialize(buf, &loginForm))
218  {
219  if (soap_register_plugin_arg(soapClient, &ResponseCodePlugin::Init, nullptr) != SOAP_OK)
220  return 500;
221 
222  ResponseCodePlugin* responseCode = reinterpret_cast<ResponseCodePlugin*>(soap_lookup_plugin(soapClient, ResponseCodePlugin::PluginId));
223  ASSERT(responseCode);
224 
225  responseCode->ErrorCode = 400;
226 
228  loginResult.set_error_code("UNABLE_TO_DECODE");
229  loginResult.set_error_message("There was an internal error while connecting to Battle.net. Please try again later.");
230  return SendResponse(soapClient, loginResult);
231  }
232 
233  std::string login;
234  std::string password;
235 
236  for (int32 i = 0; i < loginForm.inputs_size(); ++i)
237  {
238  if (loginForm.inputs(i).input_id() == "account_name")
239  login = loginForm.inputs(i).value();
240  else if (loginForm.inputs(i).input_id() == "password")
241  password = loginForm.inputs(i).value();
242  }
243 
244  Utf8ToUpperOnlyLatin(login);
245  Utf8ToUpperOnlyLatin(password);
246 
248  stmt->setString(0, login);
249  stmt->setString(1, CalculateShaPassHash(login, std::move(password)));
250  if (PreparedQueryResult result = LoginDatabase.Query(stmt))
251  {
252  std::unique_ptr<Battlenet::Session::AccountInfo> accountInfo = Trinity::make_unique<Battlenet::Session::AccountInfo>();
253  accountInfo->LoadResult(result);
254 
256  stmt->setUInt32(0, accountInfo->Id);
257  if (PreparedQueryResult characterCountsResult = LoginDatabase.Query(stmt))
258  {
259  do
260  {
261  Field* fields = characterCountsResult->Fetch();
262  accountInfo->GameAccounts[fields[0].GetUInt32()]
263  .CharacterCounts[Battlenet::RealmHandle{ fields[3].GetUInt8(), fields[4].GetUInt8(), fields[2].GetUInt32() }.GetAddress()] = fields[1].GetUInt8();
264 
265  } while (characterCountsResult->NextRow());
266  }
267 
269  stmt->setUInt32(0, accountInfo->Id);
270  if (PreparedQueryResult lastPlayerCharactersResult = LoginDatabase.Query(stmt))
271  {
272  Field* fields = lastPlayerCharactersResult->Fetch();
273  Battlenet::RealmHandle realmId{ fields[1].GetUInt8(), fields[2].GetUInt8(), fields[3].GetUInt32() };
274  Battlenet::Session::LastPlayedCharacterInfo& lastPlayedCharacter = accountInfo->GameAccounts[fields[0].GetUInt32()]
275  .LastPlayedCharacters[realmId.GetSubRegionAddress()];
276 
277  lastPlayedCharacter.RealmId = realmId;
278  lastPlayedCharacter.CharacterName = fields[4].GetString();
279  lastPlayedCharacter.CharacterGUID = fields[5].GetUInt64();
280  lastPlayedCharacter.LastPlayedTime = fields[6].GetUInt32();
281  }
282 
283  BigNumber ticket;
284  ticket.SetRand(20 * 8);
285 
286  loginResult.set_login_ticket("TC-" + ByteArrayToHexStr(ticket.AsByteArray(20).get(), 20));
287 
288  AddLoginTicket(loginResult.login_ticket(), std::move(accountInfo));
289  }
290 
292  return SendResponse(soapClient, loginResult);
293 }
Definition: BigNumber.h:28
Definition: Login.pb.h:68
void set_error_message(const ::std::string &value)
Definition: Login.pb.h:1465
Definition: LoginDatabase.h:118
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
std::unordered_map< uint32, GameAccountInfo > GameAccounts
Definition: Session.h:120
unsigned long ip
Definition: stdsoap2.h:2097
void AddLoginTicket(std::string const &id, std::unique_ptr< Battlenet::Session::AccountInfo > accountInfo)
Definition: LoginRESTService.cpp:337
Class used to access individual fields of database query result.
Definition: Field.h:56
SOAP_FMAC1 int SOAP_FMAC2 soap_register_plugin_arg(struct soap *soap, int(*fcreate)(struct soap *, struct soap_plugin *, void *), void *arg)
Definition: stdsoap2.cpp:16908
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: Login.pb.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Battlenet::RealmHandle RealmId
Definition: Session.h:86
char path[SOAP_TAGLEN]
Definition: stdsoap2.h:2093
const ::std::string & value() const
Definition: Login.pb.h:1018
Definition: PreparedStatement.h:74
const ::std::string & input_id() const
Definition: Login.pb.h:942
SOAP_FMAC1 void *SOAP_FMAC2 soap_lookup_plugin(struct soap *soap, const char *id)
Definition: stdsoap2.cpp:16947
std::string CharacterName
Definition: Session.h:87
Definition: LoginDatabase.h:117
void set_error_code(const ::std::string &value)
Definition: Login.pb.h:1389
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
uint8 GetUInt8() const
Definition: Field.h:70
Definition: Login.pb.h:363
void set_login_ticket(const ::std::string &value)
Definition: Login.pb.h:1617
uint64 CharacterGUID
Definition: Session.h:88
int32_t int32
Definition: Define.h:146
TC_SHARED_API bool Deserialize(std::string json, google::protobuf::Message *message)
Definition: ProtobufJSON.cpp:445
const ::std::string & login_ticket() const
Definition: Login.pb.h:1613
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void SetRand(int32 numbits)
Definition: BigNumber.cpp:74
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
int inputs_size() const
Definition: Login.pb.h:1311
int port
Definition: stdsoap2.h:2098
void LoadResult(PreparedQueryResult result)
Definition: Session.cpp:29
std::string ByteArrayToHexStr(uint8 const *bytes, uint32 arrayLen, bool reverse)
Definition: Util.cpp:509
#define SOAP_OK
Definition: stdsoap2.h:1245
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
void set_authentication_state(::Battlenet::JSON::Login::AuthenticationState value)
Definition: Login.pb.h:1362
uint32 LastPlayedTime
Definition: Session.h:89
std::unique_ptr< uint8[]> AsByteArray(int32 minSize=0, bool littleEndian=true)
Definition: BigNumber.cpp:177
std::string CalculateShaPassHash(std::string const &name, std::string const &password)
Definition: LoginRESTService.cpp:304
uint32 GetUInt32() const
Definition: Field.h:146
Definition: Realm.h:44
Definition: LoginDatabase.h:113
Definition: Login.pb.h:477
#define ASSERT
Definition: Errors.h:55
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
static char const *const PluginId
Definition: LoginRESTService.h:76
const ::Battlenet::JSON::Login::FormInputValue & inputs(int index) const
Definition: Login.pb.h:1317
std::string GetString() const
Definition: Field.h:276
int32 SendResponse(soap *soapClient, google::protobuf::Message const &response)
Definition: LoginRESTService.cpp:295
static int32 Init(soap *s, soap_plugin *, void *)
Definition: LoginRESTService.cpp:391
uint32 Id
Definition: Session.h:111
int soap_http_body(struct soap *soap, char **buf, size_t *len)
Definition: httppost.cpp:258

+ Here is the call graph for this function:

LoginRESTService & LoginRESTService::Instance ( )
static
384 {
385  static LoginRESTService instance;
386  return instance;
387 }
Definition: LoginRESTService.h:35
void LoginRESTService::Run ( )
private
129 {
131 
132  // check every 3 seconds if world ended
133  soapServer.accept_timeout = 3;
134  soapServer.recv_timeout = 5;
135  soapServer.send_timeout = 5;
136  if (!soap_valid_socket(soap_bind(&soapServer, _bindIP.c_str(), _port, 100)))
137  {
138  TC_LOG_ERROR("server.rest", "Couldn't bind to %s:%d", _bindIP.c_str(), _port);
139  return;
140  }
141 
142  TC_LOG_INFO("server.rest", "Login service bound to http://%s:%d", _bindIP.c_str(), _port);
143 
144  http_post_handlers handlers[] =
145  {
146  { "application/json;charset=utf-8", handle_post_plugin },
147  { "application/json", handle_post_plugin },
148  { nullptr, nullptr }
149  };
150 
151  soap_register_plugin_arg(&soapServer, &http_get, (void*)&handle_get_plugin);
152  soap_register_plugin_arg(&soapServer, &http_post, handlers);
153  soap_register_plugin_arg(&soapServer, &ContentTypePlugin::Init, (void*)"application/json;charset=utf-8");
154 
155  // Use our already ready ssl context
156  soapServer.ctx = Battlenet::SslContext::instance().native_handle();
157  soapServer.ssl_flags = SOAP_SSL_RSA;
158 
159  while (!_stopped)
160  {
161  if (!soap_valid_socket(soap_accept(&soapServer)))
162  continue; // ran into an accept timeout
163 
164  std::shared_ptr<soap> soapClient = std::make_shared<soap>(soapServer);
165  boost::asio::ip::address_v4 address(soapClient->ip);
166  if (soap_ssl_accept(soapClient.get()) != SOAP_OK)
167  {
168  TC_LOG_DEBUG("server.rest", "Failed SSL handshake from IP=%s", address.to_string().c_str());
169  continue;
170  }
171 
172  TC_LOG_DEBUG("server.rest", "Accepted connection from IP=%s", address.to_string().c_str());
173 
174  std::thread([soapClient]
175  {
176  soap_serve(soapClient.get());
177  }).detach();
178  }
179 
180  // and release the context handle here - soap does not own it so it should not free it on exit
181  soapServer.ctx = nullptr;
182 
183  TC_LOG_INFO("server.rest", "Login service exiting...");
184 }
#define SOAP_C_UTFSTRING
Definition: stdsoap2.h:1375
#define soap_valid_socket(n)
Definition: stdsoap2.h:859
Definition: stdsoap2.h:1933
SOAP_FMAC1 SOAP_SOCKET SOAP_FMAC2 soap_accept(struct soap *soap)
Definition: stdsoap2.cpp:4971
SOAP_FMAC1 int SOAP_FMAC2 soap_register_plugin_arg(struct soap *soap, int(*fcreate)(struct soap *, struct soap_plugin *, void *), void *arg)
Definition: stdsoap2.cpp:16908
SOAP_FMAC1 SOAP_SOCKET SOAP_FMAC2 soap_bind(struct soap *soap, const char *host, int port, int backlog)
Definition: stdsoap2.cpp:4743
int32 _port
Definition: LoginRESTService.h:100
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::atomic< bool > _stopped
Definition: LoginRESTService.h:97
static int32 Init(soap *s, soap_plugin *p, void *)
Definition: LoginRESTService.cpp:419
std::string _bindIP
Definition: LoginRESTService.h:99
friend int32 handle_post_plugin(soap *soapClient)
Definition: LoginRESTService.cpp:39
int http_post(struct soap *soap, struct soap_plugin *p, void *arg)
Definition: httppost.cpp:156
int http_get(struct soap *soap, struct soap_plugin *p, void *arg)
Definition: httpget.cpp:154
#define SOAP_OK
Definition: stdsoap2.h:1245
Definition: httppost.h:66
SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_accept(struct soap *)
SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap)
Definition: soapServer.cpp:20
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
friend int32 handle_get_plugin(soap *soapClient)
Definition: LoginRESTService.cpp:34
static boost::asio::ssl::context & instance()
Definition: SslContext.cpp:41
#define SOAP_SSL_RSA
Definition: stdsoap2.h:1401

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 LoginRESTService::SendResponse ( soap soapClient,
google::protobuf::Message const response 
)
private
296 {
297  std::string jsonResponse = JSON::Serialize(response);
298 
299  soap_response(soapClient, SOAP_FILE);
300  soap_send_raw(soapClient, jsonResponse.c_str(), jsonResponse.length());
301  return soap_end_send(soapClient);
302 }
#define SOAP_FILE
Definition: stdsoap2.h:1311
SOAP_FMAC1 int SOAP_FMAC2 soap_end_send(struct soap *soap)
Definition: stdsoap2.cpp:8242
SOAP_FMAC1 int SOAP_FMAC2 soap_send_raw(struct soap *soap, const char *s, size_t n)
Definition: stdsoap2.cpp:730
TC_SHARED_API std::string Serialize(google::protobuf::Message const &message)
Definition: ProtobufJSON.cpp:438
SOAP_FMAC1 int SOAP_FMAC2 soap_response(struct soap *soap, int status)
Definition: stdsoap2.cpp:6119
size_t length
Definition: stdsoap2.h:2062

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool LoginRESTService::Start ( boost::asio::io_service &  ioService)
45 {
46  _bindIP = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
47  _port = sConfigMgr->GetIntDefault("LoginREST.Port", 8081);
48  if (_port < 0 || _port > 0xFFFF)
49  {
50  TC_LOG_ERROR("server.rest", "Specified login service port (%d) out of allowed range (1-65535), defaulting to 8081", _port);
51  _port = 8081;
52  }
53 
54  boost::system::error_code ec;
55  boost::asio::ip::tcp::resolver resolver(ioService);
56  boost::asio::ip::tcp::resolver::iterator end;
57 
58  std::string configuredAddress = sConfigMgr->GetStringDefault("LoginREST.ExternalAddress", "127.0.0.1");
59  boost::asio::ip::tcp::resolver::query externalAddressQuery(boost::asio::ip::tcp::v4(), configuredAddress, std::to_string(_port));
60  boost::asio::ip::tcp::resolver::iterator endPoint = resolver.resolve(externalAddressQuery, ec);
61  if (endPoint == end || ec)
62  {
63  TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.ExternalAddress %s", configuredAddress.c_str());
64  return false;
65  }
66 
67  _externalAddress = endPoint->endpoint();
68 
69  configuredAddress = sConfigMgr->GetStringDefault("LoginREST.LocalAddress", "127.0.0.1");
70  boost::asio::ip::tcp::resolver::query localAddressQuery(boost::asio::ip::tcp::v4(), configuredAddress, std::to_string(_port));
71  endPoint = resolver.resolve(localAddressQuery, ec);
72  if (endPoint == end || ec)
73  {
74  TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.ExternalAddress %s", configuredAddress.c_str());
75  return false;
76  }
77 
78  _localAddress = endPoint->endpoint();
79 
80  // set up form inputs
83  input = _formInputs.add_inputs();
84  input->set_input_id("account_name");
85  input->set_type("text");
86  input->set_label("E-mail");
87  input->set_max_length(320);
88 
89  input = _formInputs.add_inputs();
90  input->set_input_id("password");
91  input->set_type("password");
92  input->set_label("Password");
93  input->set_max_length(16);
94 
95  input = _formInputs.add_inputs();
96  input->set_input_id("log_in_submit");
97  input->set_type("submit");
98  input->set_label("Log In");
99 
100  _loginTicketCleanupTimer = new boost::asio::deadline_timer(ioService);
102  _loginTicketCleanupTimer->async_wait(std::bind(&LoginRESTService::CleanupLoginTickets, this, std::placeholders::_1));
103 
104  _thread = std::thread(std::bind(&LoginRESTService::Run, this));
105  return true;
106 }
void CleanupLoginTickets(boost::system::error_code const &error)
Definition: LoginRESTService.cpp:344
boost::asio::ip::tcp::endpoint _localAddress
Definition: LoginRESTService.h:102
boost::asio::deadline_timer * _loginTicketCleanupTimer
Definition: LoginRESTService.h:105
#define sConfigMgr
Definition: Config.h:61
std::thread _thread
Definition: LoginRESTService.h:96
void set_type(const ::std::string &value)
Definition: Login.pb.h:707
int32 _port
Definition: LoginRESTService.h:100
char * query(struct soap *soap)
Definition: httpget.cpp:244
float seconds()
Definition: units.h:97
Definition: Login.pb.h:47
inline::Battlenet::JSON::Login::FormInput * add_inputs()
Definition: Login.pb.h:907
std::string _bindIP
Definition: LoginRESTService.h:99
void set_label(const ::std::string &value)
Definition: Login.pb.h:783
#define input
Definition: wire_format_lite.h:242
void set_max_length(::google::protobuf::uint32 value)
Definition: Login.pb.h:857
void set_type(::Battlenet::JSON::Login::FormType value)
Definition: Login.pb.h:885
Definition: Login.pb.h:87
void set_input_id(const ::std::string &value)
Definition: Login.pb.h:631
void Run()
Definition: LoginRESTService.cpp:128
boost::asio::ip::tcp::endpoint _externalAddress
Definition: LoginRESTService.h:101
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Battlenet::JSON::Login::FormInputs _formInputs
Definition: LoginRESTService.h:98

+ Here is the call graph for this function:

void LoginRESTService::Stop ( )
109 {
110  _stopped = true;
111  _loginTicketCleanupTimer->cancel();
112  _thread.join();
113 }
boost::asio::deadline_timer * _loginTicketCleanupTimer
Definition: LoginRESTService.h:105
std::thread _thread
Definition: LoginRESTService.h:96
std::atomic< bool > _stopped
Definition: LoginRESTService.h:97
std::unique_ptr< Battlenet::Session::AccountInfo > LoginRESTService::VerifyLoginTicket ( std::string const id)
320 {
321  std::unique_lock<std::mutex> lock(_loginTicketMutex);
322 
323  auto itr = _validLoginTickets.find(id);
324  if (itr != _validLoginTickets.end())
325  {
326  if (itr->second.ExpiryTime > time(nullptr))
327  {
328  std::unique_ptr<Battlenet::Session::AccountInfo> accountInfo = std::move(itr->second.Account);
329  _validLoginTickets.erase(itr);
330  return accountInfo;
331  }
332  }
333 
334  return std::unique_ptr<Battlenet::Session::AccountInfo>();
335 }
std::mutex _loginTicketMutex
Definition: LoginRESTService.h:103
std::unordered_map< std::string, LoginTicket > _validLoginTickets
Definition: LoginRESTService.h:104

Friends And Related Function Documentation

int32 handle_get_plugin ( soap soapClient)
friend
35 {
36  return sLoginService.HandleGet(soapClient);
37 }
#define sLoginService
Definition: LoginRESTService.h:108
int32 handle_post_plugin ( soap soapClient)
friend
40 {
41  return sLoginService.HandlePost(soapClient);
42 }
#define sLoginService
Definition: LoginRESTService.h:108

Member Data Documentation

std::string LoginRESTService::_bindIP
private
boost::asio::ip::tcp::endpoint LoginRESTService::_externalAddress
private
Battlenet::JSON::Login::FormInputs LoginRESTService::_formInputs
private
boost::asio::ip::tcp::endpoint LoginRESTService::_localAddress
private
boost::asio::deadline_timer* LoginRESTService::_loginTicketCleanupTimer
private
std::mutex LoginRESTService::_loginTicketMutex
private
int32 LoginRESTService::_port
private
std::atomic<bool> LoginRESTService::_stopped
private
std::thread LoginRESTService::_thread
private
std::unordered_map<std::string, LoginTicket> LoginRESTService::_validLoginTickets
private

The documentation for this class was generated from the following files: