Index: remoting/host/security_key/security_key_auth_handler_win.cc |
diff --git a/remoting/host/security_key/gnubby_auth_handler_win.cc b/remoting/host/security_key/security_key_auth_handler_win.cc |
similarity index 67% |
rename from remoting/host/security_key/gnubby_auth_handler_win.cc |
rename to remoting/host/security_key/security_key_auth_handler_win.cc |
index 098f2f94bd03716e6f51374a0dd8c7412ac7d67e..bf023b8ee50765c1da5439b0181c568276ea50fc 100644 |
--- a/remoting/host/security_key/gnubby_auth_handler_win.cc |
+++ b/remoting/host/security_key/security_key_auth_handler_win.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "remoting/host/security_key/gnubby_auth_handler.h" |
+#include "remoting/host/security_key/security_key_auth_handler.h" |
#include <cstdint> |
#include <map> |
@@ -28,8 +28,8 @@ |
#include "remoting/host/chromoting_messages.h" |
#include "remoting/host/client_session_details.h" |
#include "remoting/host/ipc_util.h" |
-#include "remoting/host/security_key/remote_security_key_ipc_constants.h" |
-#include "remoting/host/security_key/remote_security_key_ipc_server.h" |
+#include "remoting/host/security_key/security_key_ipc_constants.h" |
+#include "remoting/host/security_key/security_key_ipc_server.h" |
namespace { |
@@ -37,9 +37,9 @@ namespace { |
// forgets to do so. This ensures the server channel is not blocked forever. |
const int kInitialRequestTimeoutSeconds = 5; |
-// This value represents the amount of time to wait for a gnubby request from |
-// the client before terminating the connection. |
-const int kGnubbyRequestTimeoutSeconds = 60; |
+// This value represents the amount of time to wait for a security key request |
+// from the client before terminating the connection. |
+const int kSecurityKeyRequestTimeoutSeconds = 60; |
} // namespace |
@@ -47,8 +47,8 @@ namespace remoting { |
// Creates an IPC server channel which services IPC clients that want to start |
// a security key forwarding session. Once an IPC Client connects to the |
-// server, the GnubbyAuthHandlerWin class will create a new |
-// RemoteSecurityKeyIpcServer instance that will service that request. The new |
+// server, the SecurityKeyAuthHandlerWin class will create a new |
+// SecurityKeyIpcServer instance that will service that request. The new |
// instance will exist for the lifetime of the security key request and will be |
// assigned a unique IPC channel name and connection id. The channel name is |
// sent to the client which should disconnect the IPC server channel and |
@@ -56,23 +56,24 @@ namespace remoting { |
// security key messages. The IPC server channel will then be reset so it can |
// can service the next client/request. This system allows multiple security |
// key forwarding sessions to occur concurrently. |
-// TODO(joedow): Update GnubbyAuthHandler impls to run on a separate IO thread |
-// instead of the thread it was created on: crbug.com/591739 |
-class GnubbyAuthHandlerWin : public GnubbyAuthHandler, public IPC::Listener { |
+// TODO(joedow): Update SecurityKeyAuthHandler impls to run on a separate IO |
+// thread instead of the thread it was created on: crbug.com/591739 |
+class SecurityKeyAuthHandlerWin : public SecurityKeyAuthHandler, |
+ public IPC::Listener { |
public: |
- explicit GnubbyAuthHandlerWin(ClientSessionDetails* client_session_details); |
- ~GnubbyAuthHandlerWin() override; |
+ explicit SecurityKeyAuthHandlerWin( |
+ ClientSessionDetails* client_session_details); |
+ ~SecurityKeyAuthHandlerWin() override; |
private: |
- typedef std::map<int, std::unique_ptr<RemoteSecurityKeyIpcServer>> |
- ActiveChannels; |
+ typedef std::map<int, std::unique_ptr<SecurityKeyIpcServer>> ActiveChannels; |
- // GnubbyAuthHandler interface. |
- void CreateGnubbyConnection() override; |
- bool IsValidConnectionId(int gnubby_connection_id) const override; |
- void SendClientResponse(int gnubby_connection_id, |
+ // SecurityKeyAuthHandler interface. |
+ void CreateSecurityKeyConnection() override; |
+ bool IsValidConnectionId(int security_key_connection_id) const override; |
+ void SendClientResponse(int security_key_connection_id, |
const std::string& response) override; |
- void SendErrorAndCloseConnection(int gnubby_connection_id) override; |
+ void SendErrorAndCloseConnection(int security_key_connection_id) override; |
void SetSendMessageCallback(const SendMessageCallback& callback) override; |
size_t GetActiveConnectionCountForTest() const override; |
void SetRequestTimeoutForTest(base::TimeDelta timeout) override; |
@@ -102,7 +103,7 @@ class GnubbyAuthHandlerWin : public GnubbyAuthHandler, public IPC::Listener { |
// Represents the last id assigned to a new security key request IPC channel. |
int last_connection_id_ = 0; |
- // Sends a gnubby extension messages to the remote client when called. |
+ // Sends a security key extension message to the client when called. |
SendMessageCallback send_message_callback_; |
// Interface which provides details about the client session. |
@@ -122,24 +123,24 @@ class GnubbyAuthHandlerWin : public GnubbyAuthHandler, public IPC::Listener { |
// channel to start a security key forwarding session on. |
std::unique_ptr<IPC::Channel> ipc_server_channel_; |
- // Ensures GnubbyAuthHandlerWin methods are called on the same thread. |
+ // Ensures SecurityKeyAuthHandlerWin methods are called on the same thread. |
base::ThreadChecker thread_checker_; |
- base::WeakPtrFactory<GnubbyAuthHandlerWin> weak_factory_; |
+ base::WeakPtrFactory<SecurityKeyAuthHandlerWin> weak_factory_; |
- DISALLOW_COPY_AND_ASSIGN(GnubbyAuthHandlerWin); |
+ DISALLOW_COPY_AND_ASSIGN(SecurityKeyAuthHandlerWin); |
}; |
-std::unique_ptr<GnubbyAuthHandler> GnubbyAuthHandler::Create( |
+std::unique_ptr<SecurityKeyAuthHandler> SecurityKeyAuthHandler::Create( |
ClientSessionDetails* client_session_details, |
const SendMessageCallback& send_message_callback) { |
- std::unique_ptr<GnubbyAuthHandler> auth_handler( |
- new GnubbyAuthHandlerWin(client_session_details)); |
+ std::unique_ptr<SecurityKeyAuthHandler> auth_handler( |
+ new SecurityKeyAuthHandlerWin(client_session_details)); |
auth_handler->SetSendMessageCallback(send_message_callback); |
return auth_handler; |
} |
-GnubbyAuthHandlerWin::GnubbyAuthHandlerWin( |
+SecurityKeyAuthHandlerWin::SecurityKeyAuthHandlerWin( |
ClientSessionDetails* client_session_details) |
: client_session_details_(client_session_details), |
disconnect_timeout_( |
@@ -148,19 +149,19 @@ GnubbyAuthHandlerWin::GnubbyAuthHandlerWin( |
DCHECK(client_session_details_); |
} |
-GnubbyAuthHandlerWin::~GnubbyAuthHandlerWin() {} |
+SecurityKeyAuthHandlerWin::~SecurityKeyAuthHandlerWin() {} |
-void GnubbyAuthHandlerWin::CreateGnubbyConnection() { |
+void SecurityKeyAuthHandlerWin::CreateSecurityKeyConnection() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
StartIpcServerChannel(); |
} |
-bool GnubbyAuthHandlerWin::IsValidConnectionId(int connection_id) const { |
+bool SecurityKeyAuthHandlerWin::IsValidConnectionId(int connection_id) const { |
DCHECK(thread_checker_.CalledOnValidThread()); |
return (GetChannelForConnectionId(connection_id) != active_channels_.end()); |
} |
-void GnubbyAuthHandlerWin::SendClientResponse( |
+void SecurityKeyAuthHandlerWin::SendClientResponse( |
int connection_id, |
const std::string& response_data) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
@@ -168,7 +169,8 @@ void GnubbyAuthHandlerWin::SendClientResponse( |
ActiveChannels::const_iterator iter = |
GetChannelForConnectionId(connection_id); |
if (iter == active_channels_.end()) { |
- HOST_LOG << "Invalid gnubby connection ID received: " << connection_id; |
+ HOST_LOG << "Invalid security key connection ID received: " |
+ << connection_id; |
return; |
} |
@@ -177,28 +179,29 @@ void GnubbyAuthHandlerWin::SendClientResponse( |
} |
} |
-void GnubbyAuthHandlerWin::SendErrorAndCloseConnection(int connection_id) { |
+void SecurityKeyAuthHandlerWin::SendErrorAndCloseConnection(int connection_id) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- SendClientResponse(connection_id, kRemoteSecurityKeyConnectionError); |
+ SendClientResponse(connection_id, kSecurityKeyConnectionError); |
CloseSecurityKeyRequestIpcChannel(connection_id); |
} |
-void GnubbyAuthHandlerWin::SetSendMessageCallback( |
+void SecurityKeyAuthHandlerWin::SetSendMessageCallback( |
const SendMessageCallback& callback) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
send_message_callback_ = callback; |
} |
-size_t GnubbyAuthHandlerWin::GetActiveConnectionCountForTest() const { |
+size_t SecurityKeyAuthHandlerWin::GetActiveConnectionCountForTest() const { |
return active_channels_.size(); |
} |
-void GnubbyAuthHandlerWin::SetRequestTimeoutForTest(base::TimeDelta timeout) { |
+void SecurityKeyAuthHandlerWin::SetRequestTimeoutForTest( |
+ base::TimeDelta timeout) { |
disconnect_timeout_ = timeout; |
} |
-void GnubbyAuthHandlerWin::StartIpcServerChannel() { |
+void SecurityKeyAuthHandlerWin::StartIpcServerChannel() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
// Create a named pipe owned by the current user (the LocalService account |
@@ -212,14 +215,14 @@ void GnubbyAuthHandlerWin::StartIpcServerChannel() { |
"O:%sG:%sD:(A;;GA;;;AU)", user_sid_utf8.c_str(), user_sid_utf8.c_str()); |
base::win::ScopedHandle pipe; |
- CHECK(CreateIpcChannel(remoting::GetRemoteSecurityKeyIpcChannelName(), |
+ CHECK(CreateIpcChannel(remoting::GetSecurityKeyIpcChannelName(), |
security_descriptor, &pipe)); |
ipc_server_channel_ = |
IPC::Channel::CreateNamedServer(IPC::ChannelHandle(pipe.Get()), this); |
CHECK(ipc_server_channel_->Connect()); |
} |
-void GnubbyAuthHandlerWin::RecreateIpcServerChannel() { |
+void SecurityKeyAuthHandlerWin::RecreateIpcServerChannel() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
timer_.Stop(); |
@@ -228,32 +231,32 @@ void GnubbyAuthHandlerWin::RecreateIpcServerChannel() { |
StartIpcServerChannel(); |
} |
-void GnubbyAuthHandlerWin::CloseSecurityKeyRequestIpcChannel( |
+void SecurityKeyAuthHandlerWin::CloseSecurityKeyRequestIpcChannel( |
int connection_id) { |
active_channels_.erase(connection_id); |
} |
-GnubbyAuthHandlerWin::ActiveChannels::const_iterator |
-GnubbyAuthHandlerWin::GetChannelForConnectionId(int connection_id) const { |
+SecurityKeyAuthHandlerWin::ActiveChannels::const_iterator |
+SecurityKeyAuthHandlerWin::GetChannelForConnectionId(int connection_id) const { |
return active_channels_.find(connection_id); |
} |
-std::string GnubbyAuthHandlerWin::GenerateUniqueChannelName() { |
- return GetRemoteSecurityKeyIpcChannelName() + "." + |
+std::string SecurityKeyAuthHandlerWin::GenerateUniqueChannelName() { |
+ return GetSecurityKeyIpcChannelName() + "." + |
IPC::Channel::GenerateUniqueRandomChannelID(); |
} |
-bool GnubbyAuthHandlerWin::OnMessageReceived(const IPC::Message& message) { |
+bool SecurityKeyAuthHandlerWin::OnMessageReceived(const IPC::Message& message) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
// This class does handle any IPC messages sent by the client. |
return false; |
} |
-void GnubbyAuthHandlerWin::OnChannelConnected(int32_t peer_pid) { |
+void SecurityKeyAuthHandlerWin::OnChannelConnected(int32_t peer_pid) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
timer_.Start(FROM_HERE, disconnect_timeout_, |
- base::Bind(&GnubbyAuthHandlerWin::OnChannelError, |
+ base::Bind(&SecurityKeyAuthHandlerWin::OnChannelError, |
base::Unretained(this))); |
// Verify the IPC connection attempt originated from the session we are |
@@ -270,23 +273,22 @@ void GnubbyAuthHandlerWin::OnChannelConnected(int32_t peer_pid) { |
} |
if (close_connection) { |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, base::Bind(&GnubbyAuthHandlerWin::OnChannelError, |
+ FROM_HERE, base::Bind(&SecurityKeyAuthHandlerWin::OnChannelError, |
weak_factory_.GetWeakPtr())); |
return; |
} |
int new_connection_id = ++last_connection_id_; |
- std::unique_ptr<RemoteSecurityKeyIpcServer> ipc_server( |
- RemoteSecurityKeyIpcServer::Create( |
- new_connection_id, peer_session_id, disconnect_timeout_, |
- send_message_callback_, |
- base::Bind(&GnubbyAuthHandlerWin::CloseSecurityKeyRequestIpcChannel, |
- base::Unretained(this), new_connection_id))); |
+ std::unique_ptr<SecurityKeyIpcServer> ipc_server(SecurityKeyIpcServer::Create( |
+ new_connection_id, peer_session_id, disconnect_timeout_, |
+ send_message_callback_, |
+ base::Bind(&SecurityKeyAuthHandlerWin::CloseSecurityKeyRequestIpcChannel, |
+ base::Unretained(this), new_connection_id))); |
std::string unique_channel_name = GenerateUniqueChannelName(); |
if (ipc_server->CreateChannel( |
unique_channel_name, |
- base::TimeDelta::FromSeconds(kGnubbyRequestTimeoutSeconds))) { |
+ base::TimeDelta::FromSeconds(kSecurityKeyRequestTimeoutSeconds))) { |
active_channels_[new_connection_id] = std::move(ipc_server); |
ipc_server_channel_->Send( |
new ChromotingNetworkToRemoteSecurityKeyMsg_ConnectionDetails( |
@@ -294,7 +296,7 @@ void GnubbyAuthHandlerWin::OnChannelConnected(int32_t peer_pid) { |
} |
} |
-void GnubbyAuthHandlerWin::OnChannelError() { |
+void SecurityKeyAuthHandlerWin::OnChannelError() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
// Could be an error, most likely the client disconnected though. Either way |