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_HOST_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_H_ |
6 #define REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_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/pairing_authenticator_base.h" | 10 #include "remoting/protocol/pairing_authenticator_base.h" |
11 #include "remoting/protocol/pairing_registry.h" | 11 #include "remoting/protocol/pairing_registry.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 namespace protocol { | 14 namespace protocol { |
15 | 15 |
16 class PairingRegistry; | 16 class PairingRegistry; |
17 | 17 |
18 class PairingHostAuthenticator : public PairingAuthenticatorBase { | 18 class PairingHostAuthenticator : public PairingAuthenticatorBase { |
19 public: | 19 public: |
20 PairingHostAuthenticator( | 20 PairingHostAuthenticator( |
21 scoped_refptr<PairingRegistry> pairing_registry, | 21 scoped_refptr<PairingRegistry> pairing_registry, |
22 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, | 22 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
23 const std::string& pin); | 23 const std::string& pin); |
24 ~PairingHostAuthenticator() override; | 24 ~PairingHostAuthenticator() override; |
25 | 25 |
| 26 // Initialize the authenticator with the given |client_id| in |
| 27 // |preferred_initial_state|. |
| 28 void Initialize(const std::string& client_id, |
| 29 Authenticator::State preferred_initial_state, |
| 30 const base::Closure& resume_callback); |
| 31 |
26 // Authenticator interface. | 32 // Authenticator interface. |
27 State state() const override; | 33 State state() const override; |
28 RejectionReason rejection_reason() const override; | 34 RejectionReason rejection_reason() const override; |
29 void ProcessMessage(const buzz::XmlElement* message, | |
30 const base::Closure& resume_callback) override; | |
31 | 35 |
32 private: | 36 private: |
33 // PairingAuthenticatorBase overrides. | 37 // PairingAuthenticatorBase overrides. |
34 void CreateSpakeAuthenticatorWithPin( | 38 void CreateSpakeAuthenticatorWithPin( |
35 State initial_state, | 39 State initial_state, |
36 const base::Closure& resume_callback) override; | 40 const base::Closure& resume_callback) override; |
37 void AddPairingElements(buzz::XmlElement* message) override; | |
38 | 41 |
39 // Continue processing a protocol message once the pairing information for | 42 // Continue initializing once the pairing information for the client id has |
40 // the client id has been received. | 43 // been received. |
41 void ProcessMessageWithPairing(const buzz::XmlElement* message, | 44 void InitializeWithPairing(Authenticator::State preferred_initial_state, |
42 const base::Closure& resume_callback, | 45 const base::Closure& resume_callback, |
43 PairingRegistry::Pairing pairing); | 46 PairingRegistry::Pairing pairing); |
44 | 47 |
45 // Protocol state. | 48 // Protocol state. |
46 scoped_refptr<PairingRegistry> pairing_registry_; | 49 scoped_refptr<PairingRegistry> pairing_registry_; |
47 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; | 50 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; |
48 std::string pin_; | 51 std::string pin_; |
49 bool protocol_error_ = false; | 52 bool protocol_error_ = false; |
50 bool waiting_for_paired_secret_ = false; | 53 bool waiting_for_paired_secret_ = false; |
51 | 54 |
52 base::WeakPtrFactory<PairingHostAuthenticator> weak_factory_; | 55 base::WeakPtrFactory<PairingHostAuthenticator> weak_factory_; |
53 | 56 |
54 DISALLOW_COPY_AND_ASSIGN(PairingHostAuthenticator); | 57 DISALLOW_COPY_AND_ASSIGN(PairingHostAuthenticator); |
55 }; | 58 }; |
56 | 59 |
57 } // namespace protocol | 60 } // namespace protocol |
58 } // namespace remoting | 61 } // namespace remoting |
59 | 62 |
60 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ | 63 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ |
OLD | NEW |