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 30 matching lines...) Expand all Loading... |
41 public: | 41 public: |
42 PairingAuthenticatorBase(); | 42 PairingAuthenticatorBase(); |
43 ~PairingAuthenticatorBase() override; | 43 ~PairingAuthenticatorBase() override; |
44 | 44 |
45 // Authenticator interface. | 45 // Authenticator interface. |
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 std::unique_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 std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator() |
| 54 const override; |
54 | 55 |
55 protected: | 56 protected: |
56 // Create a Spake2 authenticator in the specified state, prompting the user | 57 // Create a Spake2 authenticator in the specified state, prompting the user |
57 // for the PIN first if necessary. | 58 // for the PIN first if necessary. |
58 virtual void CreateSpakeAuthenticatorWithPin( | 59 virtual void CreateSpakeAuthenticatorWithPin( |
59 State initial_state, | 60 State initial_state, |
60 const base::Closure& resume_callback) = 0; | 61 const base::Closure& resume_callback) = 0; |
61 | 62 |
62 // A non-fatal error message that derived classes should set in order to | 63 // A non-fatal error message that derived classes should set in order to |
63 // cause the peer to be notified that pairing has failed and that it should | 64 // cause the peer to be notified that pairing has failed and that it should |
64 // fall back on PIN authentication. This string need not be human-readable, | 65 // fall back on PIN authentication. This string need not be human-readable, |
65 // nor is it currently used other than being logged. | 66 // nor is it currently used other than being logged. |
66 std::string error_message_; | 67 std::string error_message_; |
67 | 68 |
68 // The underlying SPAKE2 authenticator, created with either the PIN or the | 69 // The underlying SPAKE2 authenticator, created with either the PIN or the |
69 // Paired Secret by the derived class. | 70 // Paired Secret by the derived class. |
70 scoped_ptr<Authenticator> spake2_authenticator_; | 71 std::unique_ptr<Authenticator> spake2_authenticator_; |
71 | 72 |
72 // Derived classes must set this to True if the underlying authenticator is | 73 // Derived classes must set this to True if the underlying authenticator is |
73 // using the Paired Secret. | 74 // using the Paired Secret. |
74 bool using_paired_secret_ = false; | 75 bool using_paired_secret_ = false; |
75 | 76 |
76 private: | 77 private: |
77 // Helper methods for ProcessMessage() and GetNextMessage(). | 78 // Helper methods for ProcessMessage() and GetNextMessage(). |
78 void MaybeAddErrorMessage(buzz::XmlElement* message); | 79 void MaybeAddErrorMessage(buzz::XmlElement* message); |
79 bool HasErrorMessage(const buzz::XmlElement* message) const; | 80 bool HasErrorMessage(const buzz::XmlElement* message) const; |
80 void CheckForFailedSpakeExchange(const base::Closure& resume_callback); | 81 void CheckForFailedSpakeExchange(const base::Closure& resume_callback); |
81 | 82 |
82 base::WeakPtrFactory<PairingAuthenticatorBase> weak_factory_; | 83 base::WeakPtrFactory<PairingAuthenticatorBase> weak_factory_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(PairingAuthenticatorBase); | 85 DISALLOW_COPY_AND_ASSIGN(PairingAuthenticatorBase); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace protocol | 88 } // namespace protocol |
88 } // namespace remoting | 89 } // namespace remoting |
89 | 90 |
90 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ | 91 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ |
OLD | NEW |