OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/ref_counted.h" | 5 #include "base/ref_counted.h" |
6 #include "net/base/io_buffer.h" | 6 #include "net/base/io_buffer.h" |
7 #include "remoting/proto/control.pb.h" | 7 #include "remoting/proto/control.pb.h" |
8 #include "remoting/proto/event.pb.h" | 8 #include "remoting/proto/event.pb.h" |
9 #include "remoting/proto/internal.pb.h" | 9 #include "remoting/proto/internal.pb.h" |
10 #include "remoting/protocol/client_message_dispatcher.h" | 10 #include "remoting/protocol/client_message_dispatcher.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 client_stub_ = client_stub; | 32 client_stub_ = client_stub; |
33 | 33 |
34 control_message_reader_->Init( | 34 control_message_reader_->Init( |
35 session->control_channel(), | 35 session->control_channel(), |
36 NewCallback(this, &ClientMessageDispatcher::OnControlMessageReceived)); | 36 NewCallback(this, &ClientMessageDispatcher::OnControlMessageReceived)); |
37 return; | 37 return; |
38 } | 38 } |
39 | 39 |
40 void ClientMessageDispatcher::OnControlMessageReceived( | 40 void ClientMessageDispatcher::OnControlMessageReceived( |
41 ControlMessage* message, Task* done_task) { | 41 ControlMessage* message, Task* done_task) { |
42 // TODO(sergeyu): Add message validation. | 42 if (!client_stub_->authenticated()) { |
43 if (message->has_notify_resolution()) { | 43 // When the client has not authenticated with the host, we restrict the |
44 client_stub_->NotifyResolution( | 44 // control messages that we support. |
45 &message->notify_resolution(), done_task); | 45 if (message->has_begin_session_response()) { |
46 } else if (message->has_begin_session_response()) { | 46 client_stub_->BeginSessionResponse( |
47 client_stub_->BeginSessionResponse( | 47 &message->begin_session_response().login_status(), done_task); |
48 &message->begin_session_response().login_status(), done_task); | 48 return; |
| 49 } else { |
| 50 LOG(WARNING) << "Invalid control message received " |
| 51 << "(client not authenticated)."; |
| 52 } |
49 } else { | 53 } else { |
50 LOG(WARNING) << "Invalid control message received."; | 54 // TODO(sergeyu): Add message validation. |
51 done_task->Run(); | 55 if (message->has_notify_resolution()) { |
52 delete done_task; | 56 client_stub_->NotifyResolution( |
| 57 &message->notify_resolution(), done_task); |
| 58 return; |
| 59 } else if (message->has_begin_session_response()) { |
| 60 LOG(WARNING) << "BeginSessionResponse sent after client already " |
| 61 << "authorized."; |
| 62 } else { |
| 63 LOG(WARNING) << "Invalid control message received."; |
| 64 } |
53 } | 65 } |
| 66 done_task->Run(); |
| 67 delete done_task; |
54 } | 68 } |
55 | 69 |
56 } // namespace protocol | 70 } // namespace protocol |
57 } // namespace remoting | 71 } // namespace remoting |
OLD | NEW |