OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_SECURITY_KEY_FAKE_IPC_GNUBBY_AUTH_HANDLER_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_IPC_GNUBBY_AUTH_HANDLER_H_ |
| 7 |
| 8 #include "remoting/host/security_key/gnubby_auth_handler.h" |
| 9 |
| 10 #include <memory> |
| 11 #include <string> |
| 12 |
| 13 #include "base/time/time.h" |
| 14 #include "ipc/ipc_listener.h" |
| 15 |
| 16 namespace IPC { |
| 17 class Channel; |
| 18 class Message; |
| 19 } // IPC |
| 20 |
| 21 namespace remoting { |
| 22 |
| 23 // Simplified implementation of an IPC based GnubbyAuthHandler class used for |
| 24 // testing. |
| 25 class FakeIpcGnubbyAuthHandler : public GnubbyAuthHandler, |
| 26 public IPC::Listener { |
| 27 public: |
| 28 FakeIpcGnubbyAuthHandler(); |
| 29 ~FakeIpcGnubbyAuthHandler() override; |
| 30 |
| 31 // GnubbyAuthHandler interface. |
| 32 void CreateGnubbyConnection() override; |
| 33 bool IsValidConnectionId(int gnubby_connection_id) const override; |
| 34 void SendClientResponse(int gnubby_connection_id, |
| 35 const std::string& response) override; |
| 36 void SendErrorAndCloseConnection(int gnubby_connection_id) override; |
| 37 void SetSendMessageCallback(const SendMessageCallback& callback) override; |
| 38 size_t GetActiveConnectionCountForTest() const override; |
| 39 void SetRequestTimeoutForTest(base::TimeDelta timeout) override; |
| 40 |
| 41 void set_ipc_security_key_channel_name( |
| 42 const std::string& ipc_security_key_channel_name) { |
| 43 ipc_security_key_channel_name_ = ipc_security_key_channel_name; |
| 44 } |
| 45 |
| 46 void set_ipc_server_channel_name(const std::string& ipc_server_channel_name) { |
| 47 ipc_server_channel_name_ = ipc_server_channel_name; |
| 48 } |
| 49 |
| 50 private: |
| 51 // IPC::Listener implementation. |
| 52 bool OnMessageReceived(const IPC::Message& message) override; |
| 53 void OnChannelConnected(int32_t peer_pid) override; |
| 54 void OnChannelError() override; |
| 55 |
| 56 // The name used when creating the well-known IPC Server channel. |
| 57 std::string ipc_server_channel_name_; |
| 58 |
| 59 // The channel name returned in the test connection details message and used |
| 60 // to exchange security key messages over IPC. |
| 61 std::string ipc_security_key_channel_name_; |
| 62 |
| 63 // IPC Clients connect to this channel first to receive their own unique IPC |
| 64 // channel to start a security key forwarding session on. |
| 65 std::unique_ptr<IPC::Channel> ipc_server_channel_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(FakeIpcGnubbyAuthHandler); |
| 68 }; |
| 69 |
| 70 } // namespace remoting |
| 71 |
| 72 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_IPC_GNUBBY_AUTH_HANDLER_H_ |
OLD | NEW |