[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_H_ | ||||
6 | #define REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_H_ | ||||
7 | |||||
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 8 | #include "base/macros.h" |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 9 | #include "base/memory/weak_ptr.h" |
10 | #include "remoting/protocol/pairing_authenticator_base.h" | ||||
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 11 | #include "remoting/protocol/pairing_registry.h" |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 12 | |
13 | namespace remoting { | ||||
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 14 | namespace protocol { |
15 | |||||
16 | class PairingRegistry; | ||||
17 | |||||
18 | class PairingHostAuthenticator : public PairingAuthenticatorBase { | ||||
19 | public: | ||||
20 | PairingHostAuthenticator( | ||||
21 | scoped_refptr<PairingRegistry> pairing_registry, | ||||
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 22 | const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 23 | const std::string& pin); |
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 24 | ~PairingHostAuthenticator() override; |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 25 | |
sergeyu | 843ef12 | 2016-03-17 01:44:17 | [diff] [blame] | 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 | |||||
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 32 | // Authenticator interface. |
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 33 | State state() const override; |
34 | RejectionReason rejection_reason() const override; | ||||
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 35 | |
36 | private: | ||||
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 37 | // PairingAuthenticatorBase overrides. |
38 | void CreateSpakeAuthenticatorWithPin( | ||||
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 39 | State initial_state, |
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 40 | const base::Closure& resume_callback) override; |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 41 | |
sergeyu | 843ef12 | 2016-03-17 01:44:17 | [diff] [blame] | 42 | // Continue initializing once the pairing information for the client id has |
43 | // been received. | ||||
44 | void InitializeWithPairing(Authenticator::State preferred_initial_state, | ||||
45 | const base::Closure& resume_callback, | ||||
46 | PairingRegistry::Pairing pairing); | ||||
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 47 | |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 48 | // Protocol state. |
49 | scoped_refptr<PairingRegistry> pairing_registry_; | ||||
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 50 | CreateBaseAuthenticatorCallback create_base_authenticator_callback_; |
51 | std::string pin_; | ||||
52 | bool protocol_error_ = false; | ||||
53 | bool waiting_for_paired_secret_ = false; | ||||
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 54 | |
55 | base::WeakPtrFactory<PairingHostAuthenticator> weak_factory_; | ||||
56 | |||||
57 | DISALLOW_COPY_AND_ASSIGN(PairingHostAuthenticator); | ||||
58 | }; | ||||
59 | |||||
60 | } // namespace protocol | ||||
61 | } // namespace remoting | ||||
62 | |||||
63 | #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ |