Index: remoting/protocol/pairing_client_authenticator.cc |
diff --git a/remoting/protocol/pairing_client_authenticator.cc b/remoting/protocol/pairing_client_authenticator.cc |
index b70e0c6a06fbf41effee5a641011185e9256f8db..5fe0200eb222f803153c7bac92103776696499d2 100644 |
--- a/remoting/protocol/pairing_client_authenticator.cc |
+++ b/remoting/protocol/pairing_client_authenticator.cc |
@@ -19,14 +19,32 @@ PairingClientAuthenticator::PairingClientAuthenticator( |
const CreateBaseAuthenticatorCallback& create_base_authenticator_callback) |
: client_auth_config_(client_auth_config), |
create_base_authenticator_callback_(create_base_authenticator_callback), |
- weak_factory_(this) { |
- spake2_authenticator_ = create_base_authenticator_callback_.Run( |
- client_auth_config.pairing_secret, MESSAGE_READY); |
- using_paired_secret_ = true; |
-} |
+ weak_factory_(this) {} |
PairingClientAuthenticator::~PairingClientAuthenticator() {} |
+void PairingClientAuthenticator::Start(State initial_state, |
+ const base::Closure& resume_callback) { |
+ if (client_auth_config_.pairing_client_id.empty() || |
+ client_auth_config_.pairing_secret.empty()) { |
+ error_message_ = "not-paired"; |
Jamie
2016/03/17 00:36:22
It's not obvious why this needs to be set here (ie
Sergey Ulanov
2016/03/17 00:49:21
Done.
|
+ using_paired_secret_ = false; |
+ CreateSpakeAuthenticatorWithPin(initial_state, resume_callback); |
+ } else { |
+ StartPaired(initial_state); |
+ resume_callback.Run(); |
+ } |
+} |
+ |
+void PairingClientAuthenticator::StartPaired(State initial_state) { |
+ DCHECK(!client_auth_config_.pairing_client_id.empty()); |
+ DCHECK(!client_auth_config_.pairing_secret.empty()); |
+ |
+ using_paired_secret_ = true; |
+ spake2_authenticator_ = create_base_authenticator_callback_.Run( |
+ client_auth_config_.pairing_secret, initial_state); |
+} |
+ |
Authenticator::State PairingClientAuthenticator::state() const { |
if (waiting_for_pin_) |
return PROCESSING_MESSAGE; |
@@ -44,20 +62,6 @@ void PairingClientAuthenticator::CreateSpakeAuthenticatorWithPin( |
weak_factory_.GetWeakPtr(), initial_state, resume_callback)); |
} |
-void PairingClientAuthenticator::AddPairingElements(buzz::XmlElement* message) { |
- // If the client id and secret have not yet been sent, do so now. Note that |
- // in this case the V2Authenticator is being used optimistically to send the |
- // first message of the SPAKE exchange since we don't yet know whether or not |
- // the host will accept the client id or request that we fall back to the PIN. |
- if (!sent_client_id_) { |
- buzz::XmlElement* pairing_tag = new buzz::XmlElement(kPairingInfoTag); |
- pairing_tag->AddAttr(kClientIdAttribute, |
- client_auth_config_.pairing_client_id); |
- message->AddElement(pairing_tag); |
- sent_client_id_ = true; |
- } |
-} |
- |
void PairingClientAuthenticator::OnPinFetched( |
State initial_state, |
const base::Closure& resume_callback, |