| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/protocol/third_party_host_authenticator.h" | 5 #include "remoting/protocol/third_party_host_authenticator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 14 #include "remoting/base/rsa_key_pair.h" | |
| 15 #include "remoting/protocol/token_validator.h" | 14 #include "remoting/protocol/token_validator.h" |
| 16 #include "remoting/protocol/v2_authenticator.h" | |
| 17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 18 | 16 |
| 19 namespace remoting { | 17 namespace remoting { |
| 20 namespace protocol { | 18 namespace protocol { |
| 21 | 19 |
| 22 ThirdPartyHostAuthenticator::ThirdPartyHostAuthenticator( | 20 ThirdPartyHostAuthenticator::ThirdPartyHostAuthenticator( |
| 23 const std::string& local_cert, | 21 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
| 24 scoped_refptr<RsaKeyPair> key_pair, | |
| 25 scoped_ptr<TokenValidator> token_validator) | 22 scoped_ptr<TokenValidator> token_validator) |
| 26 : ThirdPartyAuthenticatorBase(MESSAGE_READY), | 23 : ThirdPartyAuthenticatorBase(MESSAGE_READY), |
| 27 local_cert_(local_cert), | 24 create_base_authenticator_callback_(create_base_authenticator_callback), |
| 28 key_pair_(key_pair), | 25 token_validator_(std::move(token_validator)) {} |
| 29 token_validator_(std::move(token_validator)) { | |
| 30 } | |
| 31 | 26 |
| 32 ThirdPartyHostAuthenticator::~ThirdPartyHostAuthenticator() { | 27 ThirdPartyHostAuthenticator::~ThirdPartyHostAuthenticator() {} |
| 33 } | |
| 34 | 28 |
| 35 void ThirdPartyHostAuthenticator::ProcessTokenMessage( | 29 void ThirdPartyHostAuthenticator::ProcessTokenMessage( |
| 36 const buzz::XmlElement* message, | 30 const buzz::XmlElement* message, |
| 37 const base::Closure& resume_callback) { | 31 const base::Closure& resume_callback) { |
| 38 // Host has already sent the URL and expects a token from the client. | 32 // Host has already sent the URL and expects a token from the client. |
| 39 std::string token = message->TextNamed(kTokenTag); | 33 std::string token = message->TextNamed(kTokenTag); |
| 40 if (token.empty()) { | 34 if (token.empty()) { |
| 41 LOG(ERROR) << "Third-party authentication protocol error: missing token."; | 35 LOG(ERROR) << "Third-party authentication protocol error: missing token."; |
| 42 token_state_ = REJECTED; | 36 token_state_ = REJECTED; |
| 43 rejection_reason_ = PROTOCOL_ERROR; | 37 rejection_reason_ = PROTOCOL_ERROR; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const std::string& shared_secret) { | 75 const std::string& shared_secret) { |
| 82 if (shared_secret.empty()) { | 76 if (shared_secret.empty()) { |
| 83 token_state_ = REJECTED; | 77 token_state_ = REJECTED; |
| 84 rejection_reason_ = INVALID_CREDENTIALS; | 78 rejection_reason_ = INVALID_CREDENTIALS; |
| 85 resume_callback.Run(); | 79 resume_callback.Run(); |
| 86 return; | 80 return; |
| 87 } | 81 } |
| 88 | 82 |
| 89 // The other side already started the SPAKE authentication. | 83 // The other side already started the SPAKE authentication. |
| 90 token_state_ = ACCEPTED; | 84 token_state_ = ACCEPTED; |
| 91 underlying_ = V2Authenticator::CreateForHost( | 85 underlying_ = |
| 92 local_cert_, key_pair_, shared_secret, WAITING_MESSAGE); | 86 create_base_authenticator_callback_.Run(shared_secret, WAITING_MESSAGE); |
| 93 underlying_->ProcessMessage(message, resume_callback); | 87 underlying_->ProcessMessage(message, resume_callback); |
| 94 } | 88 } |
| 95 | 89 |
| 96 } // namespace protocol | 90 } // namespace protocol |
| 97 } // namespace remoting | 91 } // namespace remoting |
| OLD | NEW |