OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #include "remoting/host/client_session.h" |
| 6 |
| 7 #include "base/scoped_ptr.h" |
| 8 #include "base/task.h" |
| 9 #include "remoting/host/user_authenticator.h" |
| 10 #include "remoting/proto/auth.pb.h" |
| 11 |
| 12 namespace remoting { |
| 13 |
| 14 ClientSession::ClientSession( |
| 15 EventHandler* event_handler, |
| 16 scoped_refptr<protocol::ConnectionToClient> connection) |
| 17 : event_handler_(event_handler), |
| 18 connection_(connection) { |
| 19 } |
| 20 |
| 21 ClientSession::~ClientSession() { |
| 22 } |
| 23 |
| 24 void ClientSession::SuggestResolution( |
| 25 const protocol::SuggestResolutionRequest* msg, Task* done) { |
| 26 done->Run(); |
| 27 delete done; |
| 28 } |
| 29 |
| 30 void ClientSession::BeginSessionRequest( |
| 31 const protocol::LocalLoginCredentials* credentials, Task* done) { |
| 32 DCHECK(event_handler_); |
| 33 |
| 34 bool success = false; |
| 35 scoped_ptr<UserAuthenticator> authenticator(UserAuthenticator::Create()); |
| 36 switch (credentials->type()) { |
| 37 case protocol::PASSWORD: |
| 38 success = authenticator->Authenticate(credentials->username(), |
| 39 credentials->credential()); |
| 40 break; |
| 41 |
| 42 default: |
| 43 LOG(ERROR) << "Invalid credentials type " << credentials->type(); |
| 44 break; |
| 45 } |
| 46 |
| 47 if (success) { |
| 48 event_handler_->LocalLoginSucceeded(connection_.get()); |
| 49 } else { |
| 50 LOG(WARNING) << "Login failed for user " << credentials->username(); |
| 51 event_handler_->LocalLoginFailed(connection_.get()); |
| 52 } |
| 53 |
| 54 done->Run(); |
| 55 delete done; |
| 56 } |
| 57 |
| 58 void ClientSession::Disconnect() { |
| 59 connection_->Disconnect(); |
| 60 } |
| 61 |
| 62 protocol::ConnectionToClient* ClientSession::connection() { |
| 63 return connection_.get(); |
| 64 } |
| 65 |
| 66 } // namespace remoting |
OLD | NEW |