| 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_SECURITY_KEY_AUTH_HANDLER_H_ | |
| 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_IPC_SECURITY_KEY_AUTH_HANDLER_H_ | |
| 7 | |
| 8 #include "remoting/host/security_key/security_key_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 SecurityKeyAuthHandler class used | |
| 24 // for testing. | |
| 25 class FakeIpcSecurityKeyAuthHandler : public SecurityKeyAuthHandler, | |
| 26 public IPC::Listener { | |
| 27 public: | |
| 28 FakeIpcSecurityKeyAuthHandler(); | |
| 29 ~FakeIpcSecurityKeyAuthHandler() override; | |
| 30 | |
| 31 // SecurityKeyAuthHandler interface. | |
| 32 void CreateSecurityKeyConnection() override; | |
| 33 bool IsValidConnectionId(int security_key_connection_id) const override; | |
| 34 void SendClientResponse(int security_key_connection_id, | |
| 35 const std::string& response) override; | |
| 36 void SendErrorAndCloseConnection(int security_key_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(FakeIpcSecurityKeyAuthHandler); | |
| 68 }; | |
| 69 | |
| 70 } // namespace remoting | |
| 71 | |
| 72 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_IPC_SECURITY_KEY_AUTH_HANDLER_H_ | |
| OLD | NEW |