| Index: remoting/protocol/pairing_host_authenticator.cc
|
| diff --git a/remoting/protocol/pairing_host_authenticator.cc b/remoting/protocol/pairing_host_authenticator.cc
|
| index b00a5c76f4104408ba73c67fcd779d9b71b3ff26..72185309a65a3e444eaa5b2c199c11cd42df32f7 100644
|
| --- a/remoting/protocol/pairing_host_authenticator.cc
|
| +++ b/remoting/protocol/pairing_host_authenticator.cc
|
| @@ -22,6 +22,29 @@ PairingHostAuthenticator::PairingHostAuthenticator(
|
| pin_(pin),
|
| weak_factory_(this) {}
|
|
|
| +void PairingHostAuthenticator::Initialize(
|
| + const std::string& client_id,
|
| + Authenticator::State preferred_initial_state,
|
| + const base::Closure& resume_callback) {
|
| + DCHECK(!spake2_authenticator_);
|
| +
|
| + if (client_id.empty()) {
|
| + using_paired_secret_ = false;
|
| + error_message_ = "client-id-unknown";
|
| + spake2_authenticator_ =
|
| + create_base_authenticator_callback_.Run(pin_, MESSAGE_READY);
|
| + resume_callback.Run();
|
| + return;
|
| + }
|
| +
|
| + using_paired_secret_ = true;
|
| + waiting_for_paired_secret_ = true;
|
| + pairing_registry_->GetPairing(
|
| + client_id, base::Bind(&PairingHostAuthenticator::InitializeWithPairing,
|
| + weak_factory_.GetWeakPtr(), preferred_initial_state,
|
| + resume_callback));
|
| +}
|
| +
|
| PairingHostAuthenticator::~PairingHostAuthenticator() {}
|
|
|
| Authenticator::State PairingHostAuthenticator::state() const {
|
| @@ -29,8 +52,6 @@ Authenticator::State PairingHostAuthenticator::state() const {
|
| return REJECTED;
|
| } else if (waiting_for_paired_secret_) {
|
| return PROCESSING_MESSAGE;
|
| - } else if (!spake2_authenticator_) {
|
| - return WAITING_MESSAGE;
|
| }
|
| return PairingAuthenticatorBase::state();
|
| }
|
| @@ -51,63 +72,26 @@ void PairingHostAuthenticator::CreateSpakeAuthenticatorWithPin(
|
| resume_callback.Run();
|
| }
|
|
|
| -void PairingHostAuthenticator::ProcessMessage(
|
| - const buzz::XmlElement* message,
|
| - const base::Closure& resume_callback) {
|
| - if (!spake2_authenticator_) {
|
| - std::string client_id;
|
| -
|
| - const buzz::XmlElement* pairing_tag = message->FirstNamed(kPairingInfoTag);
|
| - if (pairing_tag) {
|
| - client_id = pairing_tag->Attr(kClientIdAttribute);
|
| - }
|
| -
|
| - if (client_id.empty()) {
|
| - LOG(ERROR) << "No client id specified.";
|
| - protocol_error_ = true;
|
| - return;
|
| - }
|
| -
|
| - 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);
|
| -}
|
| -
|
| -void PairingHostAuthenticator::AddPairingElements(buzz::XmlElement* message) {
|
| - // Nothing to do here
|
| -}
|
| -
|
| -void PairingHostAuthenticator::ProcessMessageWithPairing(
|
| - const buzz::XmlElement* message,
|
| +void PairingHostAuthenticator::InitializeWithPairing(
|
| + Authenticator::State preferred_initial_state,
|
| const base::Closure& resume_callback,
|
| PairingRegistry::Pairing pairing) {
|
| + DCHECK(waiting_for_paired_secret_);
|
| waiting_for_paired_secret_ = false;
|
| - std::string paired_secret = pairing.shared_secret();
|
| - if (paired_secret.empty()) {
|
| + std::string pairing_secret = pairing.shared_secret();
|
| + if (pairing_secret.empty()) {
|
| VLOG(0) << "Unknown client id";
|
| error_message_ = "unknown-client-id";
|
| - }
|
| -
|
| - using_paired_secret_ = !paired_secret.empty();
|
| - if (using_paired_secret_) {
|
| - spake2_authenticator_ =
|
| - create_base_authenticator_callback_.Run(paired_secret, WAITING_MESSAGE);
|
| - PairingAuthenticatorBase::ProcessMessage(message, resume_callback);
|
| - } else {
|
| + using_paired_secret_ = false;
|
| + // If pairing wasn't found then always start in the MESSAGE_READY state.
|
| 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();
|
| + } else {
|
| + using_paired_secret_ = true;
|
| + spake2_authenticator_ = create_base_authenticator_callback_.Run(
|
| + pairing_secret, preferred_initial_state);
|
| }
|
| + resume_callback.Run();
|
| }
|
|
|
| } // namespace protocol
|
|
|