| 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 #ifndef REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_BASE_H_ | 5 #ifndef REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_BASE_H_ |
| 6 #define REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_BASE_H_ | 6 #define REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_BASE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "remoting/protocol/authenticator.h" | 10 #include "remoting/protocol/authenticator.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 State state() const override; | 46 State state() const override; |
| 47 bool started() const override; | 47 bool started() const override; |
| 48 RejectionReason rejection_reason() const override; | 48 RejectionReason rejection_reason() const override; |
| 49 void ProcessMessage(const buzz::XmlElement* message, | 49 void ProcessMessage(const buzz::XmlElement* message, |
| 50 const base::Closure& resume_callback) override; | 50 const base::Closure& resume_callback) override; |
| 51 scoped_ptr<buzz::XmlElement> GetNextMessage() override; | 51 scoped_ptr<buzz::XmlElement> GetNextMessage() override; |
| 52 const std::string& GetAuthKey() const override; | 52 const std::string& GetAuthKey() const override; |
| 53 scoped_ptr<ChannelAuthenticator> CreateChannelAuthenticator() const override; | 53 scoped_ptr<ChannelAuthenticator> CreateChannelAuthenticator() const override; |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 typedef base::Callback<void(scoped_ptr<Authenticator> authenticator)> | |
| 57 SetAuthenticatorCallback; | |
| 58 | |
| 59 static const buzz::StaticQName kPairingInfoTag; | 56 static const buzz::StaticQName kPairingInfoTag; |
| 60 static const buzz::StaticQName kClientIdAttribute; | 57 static const buzz::StaticQName kClientIdAttribute; |
| 61 | 58 |
| 62 // Create a V2 authenticator in the specified state, prompting the user for | 59 // Create a Spake2 authenticator in the specified state, prompting the user |
| 63 // the PIN first if necessary. | 60 // for the PIN first if necessary. |
| 64 virtual void CreateV2AuthenticatorWithPIN( | 61 virtual void CreateSpakeAuthenticatorWithPin( |
| 65 State initial_state, | 62 State initial_state, |
| 66 const SetAuthenticatorCallback& callback) = 0; | 63 const base::Closure& resume_callback) = 0; |
| 67 | 64 |
| 68 // Amend an authenticator message, for example to add client- or host-specific | 65 // Amend an authenticator message, for example to add client- or host-specific |
| 69 // elements to it. | 66 // elements to it. |
| 70 virtual void AddPairingElements(buzz::XmlElement* message) = 0; | 67 virtual void AddPairingElements(buzz::XmlElement* message) = 0; |
| 71 | 68 |
| 72 // A non-fatal error message that derived classes should set in order to | 69 // A non-fatal error message that derived classes should set in order to |
| 73 // cause the peer to be notified that pairing has failed and that it should | 70 // cause the peer to be notified that pairing has failed and that it should |
| 74 // fall back on PIN authentication. This string need not be human-readable, | 71 // fall back on PIN authentication. This string need not be human-readable, |
| 75 // nor is it currently used other than being logged. | 72 // nor is it currently used other than being logged. |
| 76 std::string error_message_; | 73 std::string error_message_; |
| 77 | 74 |
| 78 // The underlying V2 authenticator, created with either the PIN or the | 75 // The underlying SPAKE2 authenticator, created with either the PIN or the |
| 79 // Paired Secret by the derived class. | 76 // Paired Secret by the derived class. |
| 80 scoped_ptr<Authenticator> v2_authenticator_; | 77 scoped_ptr<Authenticator> spake2_authenticator_; |
| 81 | 78 |
| 82 // Derived classes must set this to True if the underlying authenticator is | 79 // Derived classes must set this to True if the underlying authenticator is |
| 83 // using the Paired Secret. | 80 // using the Paired Secret. |
| 84 bool using_paired_secret_; | 81 bool using_paired_secret_ = false; |
| 85 | 82 |
| 86 private: | 83 private: |
| 87 // Helper methods for ProcessMessage and GetNextMessage | 84 // Helper methods for ProcessMessage and GetNextMessage |
| 88 void MaybeAddErrorMessage(buzz::XmlElement* message); | 85 void MaybeAddErrorMessage(buzz::XmlElement* message); |
| 89 bool HasErrorMessage(const buzz::XmlElement* message) const; | 86 bool HasErrorMessage(const buzz::XmlElement* message) const; |
| 90 void CheckForFailedSpakeExchange(const base::Closure& resume_callback); | 87 void CheckForFailedSpakeExchange(const base::Closure& resume_callback); |
| 91 void SetAuthenticatorAndProcessMessage( | |
| 92 const buzz::XmlElement* message, | |
| 93 const base::Closure& resume_callback, | |
| 94 scoped_ptr<Authenticator> authenticator); | |
| 95 | |
| 96 // Set to true if a PIN-based authenticator has been requested but has not | |
| 97 // yet been set. | |
| 98 bool waiting_for_authenticator_; | |
| 99 | 88 |
| 100 base::WeakPtrFactory<PairingAuthenticatorBase> weak_factory_; | 89 base::WeakPtrFactory<PairingAuthenticatorBase> weak_factory_; |
| 101 | 90 |
| 102 DISALLOW_COPY_AND_ASSIGN(PairingAuthenticatorBase); | 91 DISALLOW_COPY_AND_ASSIGN(PairingAuthenticatorBase); |
| 103 }; | 92 }; |
| 104 | 93 |
| 105 } // namespace protocol | 94 } // namespace protocol |
| 106 } // namespace remoting | 95 } // namespace remoting |
| 107 | 96 |
| 108 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ | 97 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ |
| OLD | NEW |