OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_HOST_GNUBBY_AUTH_HANDLER_POSIX_H_ |
| 6 #define REMOTING_HOST_GNUBBY_AUTH_HANDLER_POSIX_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "net/socket/stream_listen_socket.h" |
| 15 #include "remoting/host/gnubby_auth_handler.h" |
| 16 |
| 17 namespace remoting { |
| 18 |
| 19 namespace protocol { |
| 20 class ClientStub; |
| 21 } // namespace protocol |
| 22 |
| 23 class GnubbyAuthHandlerPosix : public GnubbyAuthHandler, |
| 24 public base::NonThreadSafe, |
| 25 public net::StreamListenSocket::Delegate { |
| 26 public: |
| 27 explicit GnubbyAuthHandlerPosix(protocol::ClientStub* client_stub); |
| 28 virtual ~GnubbyAuthHandlerPosix(); |
| 29 |
| 30 bool HasActiveSocketForTesting(net::StreamListenSocket* socket) const; |
| 31 |
| 32 private: |
| 33 // GnubbyAuthHandler interface. |
| 34 virtual void DeliverClientMessage(const std::string& message) OVERRIDE; |
| 35 virtual void DeliverHostDataMessage(int connection_id, |
| 36 const std::string& data) const OVERRIDE; |
| 37 |
| 38 // StreamListenSocket::Delegate interface. |
| 39 virtual void DidAccept(net::StreamListenSocket* server, |
| 40 scoped_ptr<net::StreamListenSocket> socket) OVERRIDE; |
| 41 virtual void DidRead(net::StreamListenSocket* socket, |
| 42 const char* data, |
| 43 int len) OVERRIDE; |
| 44 virtual void DidClose(net::StreamListenSocket* socket) OVERRIDE; |
| 45 |
| 46 // Create socket for authorization. |
| 47 void CreateAuthorizationSocket(); |
| 48 |
| 49 // Process a gnubby request. |
| 50 void ProcessGnubbyRequest(int connection_id, const char* data, int data_len); |
| 51 |
| 52 // Interface through which communication with the client occurs. |
| 53 protocol::ClientStub* client_stub_; |
| 54 |
| 55 // Socket used to listen for authorization requests. |
| 56 scoped_ptr<net::StreamListenSocket> auth_socket_; |
| 57 |
| 58 // The last assigned gnubby connection id. |
| 59 int last_connection_id_; |
| 60 |
| 61 // Sockets by connection id used to process gnubbyd requests. |
| 62 typedef std::map<int, net::StreamListenSocket*> ActiveSockets; |
| 63 ActiveSockets active_sockets_; |
| 64 |
| 65 // Partial gnubbyd request data by connection id. |
| 66 typedef std::map<int, std::vector<char> > ActiveRequests; |
| 67 ActiveRequests active_requests_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(GnubbyAuthHandlerPosix); |
| 70 }; |
| 71 |
| 72 } // namespace remoting |
| 73 |
| 74 #endif // REMOTING_HOST_GNUBBY_AUTH_HANDLER_POSIX_H_ |
OLD | NEW |