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