| 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/pairing_authenticator_base.h" | 5 #include "remoting/protocol/pairing_authenticator_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| 11 #include "remoting/protocol/channel_authenticator.h" | 11 #include "remoting/protocol/channel_authenticator.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 namespace protocol { | 14 namespace protocol { |
| 15 | 15 |
| 16 const buzz::StaticQName PairingAuthenticatorBase::kPairingInfoTag = | |
| 17 { kChromotingXmlNamespace, "pairing-info" }; | |
| 18 const buzz::StaticQName PairingAuthenticatorBase::kClientIdAttribute = | |
| 19 { "", "client-id" }; | |
| 20 | |
| 21 namespace { | 16 namespace { |
| 22 const buzz::StaticQName kPairingFailedTag = | 17 const buzz::StaticQName kPairingFailedTag = |
| 23 { kChromotingXmlNamespace, "pairing-failed" }; | 18 { kChromotingXmlNamespace, "pairing-failed" }; |
| 24 const buzz::StaticQName kPairingErrorAttribute = { "", "error" }; | 19 const buzz::StaticQName kPairingErrorAttribute = { "", "error" }; |
| 25 } // namespace | 20 } // namespace |
| 26 | 21 |
| 27 PairingAuthenticatorBase::PairingAuthenticatorBase() : weak_factory_(this) {} | 22 PairingAuthenticatorBase::PairingAuthenticatorBase() : weak_factory_(this) {} |
| 28 PairingAuthenticatorBase::~PairingAuthenticatorBase() {} | 23 PairingAuthenticatorBase::~PairingAuthenticatorBase() {} |
| 29 | 24 |
| 30 Authenticator::State PairingAuthenticatorBase::state() const { | 25 Authenticator::State PairingAuthenticatorBase::state() const { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // to the peer and retrying with the PIN. | 70 // to the peer and retrying with the PIN. |
| 76 spake2_authenticator_->ProcessMessage( | 71 spake2_authenticator_->ProcessMessage( |
| 77 message, | 72 message, |
| 78 base::Bind(&PairingAuthenticatorBase::CheckForFailedSpakeExchange, | 73 base::Bind(&PairingAuthenticatorBase::CheckForFailedSpakeExchange, |
| 79 weak_factory_.GetWeakPtr(), resume_callback)); | 74 weak_factory_.GetWeakPtr(), resume_callback)); |
| 80 } | 75 } |
| 81 | 76 |
| 82 scoped_ptr<buzz::XmlElement> PairingAuthenticatorBase::GetNextMessage() { | 77 scoped_ptr<buzz::XmlElement> PairingAuthenticatorBase::GetNextMessage() { |
| 83 DCHECK_EQ(state(), MESSAGE_READY); | 78 DCHECK_EQ(state(), MESSAGE_READY); |
| 84 scoped_ptr<buzz::XmlElement> result = spake2_authenticator_->GetNextMessage(); | 79 scoped_ptr<buzz::XmlElement> result = spake2_authenticator_->GetNextMessage(); |
| 85 AddPairingElements(result.get()); | |
| 86 MaybeAddErrorMessage(result.get()); | 80 MaybeAddErrorMessage(result.get()); |
| 87 return result; | 81 return result; |
| 88 } | 82 } |
| 89 | 83 |
| 90 const std::string& PairingAuthenticatorBase::GetAuthKey() const { | 84 const std::string& PairingAuthenticatorBase::GetAuthKey() const { |
| 91 return spake2_authenticator_->GetAuthKey(); | 85 return spake2_authenticator_->GetAuthKey(); |
| 92 } | 86 } |
| 93 | 87 |
| 94 scoped_ptr<ChannelAuthenticator> | 88 scoped_ptr<ChannelAuthenticator> |
| 95 PairingAuthenticatorBase::CreateChannelAuthenticator() const { | 89 PairingAuthenticatorBase::CreateChannelAuthenticator() const { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 spake2_authenticator_.reset(); | 124 spake2_authenticator_.reset(); |
| 131 CreateSpakeAuthenticatorWithPin(MESSAGE_READY, resume_callback); | 125 CreateSpakeAuthenticatorWithPin(MESSAGE_READY, resume_callback); |
| 132 return; | 126 return; |
| 133 } | 127 } |
| 134 | 128 |
| 135 resume_callback.Run(); | 129 resume_callback.Run(); |
| 136 } | 130 } |
| 137 | 131 |
| 138 } // namespace protocol | 132 } // namespace protocol |
| 139 } // namespace remoting | 133 } // namespace remoting |
| OLD | NEW |