Chromium Code Reviews| Index: remoting/protocol/pairing_host_authenticator.cc |
| diff --git a/remoting/protocol/pairing_host_authenticator.cc b/remoting/protocol/pairing_host_authenticator.cc |
| index 5418dd314625c3a7997c78d1e935f8d29940aba8..b00a5c76f4104408ba73c67fcd779d9b71b3ff26 100644 |
| --- a/remoting/protocol/pairing_host_authenticator.cc |
| +++ b/remoting/protocol/pairing_host_authenticator.cc |
| @@ -7,9 +7,7 @@ |
| #include "base/bind.h" |
| #include "base/logging.h" |
| #include "remoting/base/constants.h" |
| -#include "remoting/base/rsa_key_pair.h" |
| #include "remoting/protocol/channel_authenticator.h" |
| -#include "remoting/protocol/v2_authenticator.h" |
| #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| namespace remoting { |
| @@ -17,27 +15,21 @@ namespace protocol { |
| PairingHostAuthenticator::PairingHostAuthenticator( |
| scoped_refptr<PairingRegistry> pairing_registry, |
| - const std::string& local_cert, |
| - scoped_refptr<RsaKeyPair> key_pair, |
| + const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
| const std::string& pin) |
| : pairing_registry_(pairing_registry), |
| - local_cert_(local_cert), |
| - key_pair_(key_pair), |
| + create_base_authenticator_callback_(create_base_authenticator_callback), |
| pin_(pin), |
| - protocol_error_(false), |
| - waiting_for_paired_secret_(false), |
| - weak_factory_(this) { |
| -} |
| + weak_factory_(this) {} |
| -PairingHostAuthenticator::~PairingHostAuthenticator() { |
| -} |
| +PairingHostAuthenticator::~PairingHostAuthenticator() {} |
| Authenticator::State PairingHostAuthenticator::state() const { |
| if (protocol_error_) { |
| return REJECTED; |
| } else if (waiting_for_paired_secret_) { |
| return PROCESSING_MESSAGE; |
| - } else if (!v2_authenticator_) { |
| + } else if (!spake2_authenticator_) { |
| return WAITING_MESSAGE; |
| } |
| return PairingAuthenticatorBase::state(); |
| @@ -51,17 +43,18 @@ PairingHostAuthenticator::rejection_reason() const { |
| return PairingAuthenticatorBase::rejection_reason(); |
| } |
| -void PairingHostAuthenticator::CreateV2AuthenticatorWithPIN( |
| +void PairingHostAuthenticator::CreateSpakeAuthenticatorWithPin( |
| State initial_state, |
| - const SetAuthenticatorCallback& callback) { |
| - callback.Run(V2Authenticator::CreateForHost( |
| - local_cert_, key_pair_, pin_, initial_state)); |
| + const base::Closure& resume_callback) { |
| + spake2_authenticator_ = |
| + create_base_authenticator_callback_.Run(pin_, initial_state); |
| + resume_callback.Run(); |
| } |
| void PairingHostAuthenticator::ProcessMessage( |
| const buzz::XmlElement* message, |
| const base::Closure& resume_callback) { |
| - if (!v2_authenticator_) { |
| + if (!spake2_authenticator_) { |
| std::string client_id; |
| const buzz::XmlElement* pairing_tag = message->FirstNamed(kPairingInfoTag); |
| @@ -72,16 +65,17 @@ void PairingHostAuthenticator::ProcessMessage( |
| if (client_id.empty()) { |
| LOG(ERROR) << "No client id specified."; |
| protocol_error_ = true; |
| - } else { |
| - waiting_for_paired_secret_ = true; |
| - pairing_registry_->GetPairing( |
| - client_id, |
| - base::Bind(&PairingHostAuthenticator::ProcessMessageWithPairing, |
| - weak_factory_.GetWeakPtr(), |
| - base::Owned(new buzz::XmlElement(*message)), |
| - resume_callback)); |
| return; |
|
Jamie
2016/03/07 21:40:19
This is a change in semantics: if there is no clie
Sergey Ulanov
2016/03/07 22:45:05
Yes, it's intentional. It doesn't make sense to ca
|
| } |
| + |
| + waiting_for_paired_secret_ = true; |
| + pairing_registry_->GetPairing( |
| + client_id, |
| + base::Bind(&PairingHostAuthenticator::ProcessMessageWithPairing, |
| + weak_factory_.GetWeakPtr(), |
| + base::Owned(new buzz::XmlElement(*message)), |
| + resume_callback)); |
| + return; |
| } |
| PairingAuthenticatorBase::ProcessMessage(message, resume_callback); |
| @@ -104,12 +98,12 @@ void PairingHostAuthenticator::ProcessMessageWithPairing( |
| using_paired_secret_ = !paired_secret.empty(); |
| if (using_paired_secret_) { |
| - v2_authenticator_ = V2Authenticator::CreateForHost( |
| - local_cert_, key_pair_, paired_secret, WAITING_MESSAGE); |
| + spake2_authenticator_ = |
| + create_base_authenticator_callback_.Run(paired_secret, WAITING_MESSAGE); |
| PairingAuthenticatorBase::ProcessMessage(message, resume_callback); |
| } else { |
| - v2_authenticator_ = V2Authenticator::CreateForHost( |
| - local_cert_, key_pair_, pin_, MESSAGE_READY); |
| + spake2_authenticator_ = |
| + create_base_authenticator_callback_.Run(pin_, MESSAGE_READY); |
| // The client's optimistic SPAKE message is using a Paired Secret to |
| // which the host doesn't have access, so don't bother processing it. |
| resume_callback.Run(); |