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_CLIENT_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_PAIRING_CLIENT_AUTHENTICATOR_H_ |
6 #define REMOTING_PROTOCOL_PAIRING_CLIENT_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_PAIRING_CLIENT_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/client_authentication_config.h" | 10 #include "remoting/protocol/client_authentication_config.h" |
11 #include "remoting/protocol/pairing_authenticator_base.h" | 11 #include "remoting/protocol/pairing_authenticator_base.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 namespace protocol { | 14 namespace protocol { |
15 | 15 |
16 class PairingClientAuthenticator : public PairingAuthenticatorBase { | 16 class PairingClientAuthenticator : public PairingAuthenticatorBase { |
17 public: | 17 public: |
18 PairingClientAuthenticator( | 18 PairingClientAuthenticator( |
19 const ClientAuthenticationConfig& client_auth_config, | 19 const ClientAuthenticationConfig& client_auth_config, |
20 const CreateBaseAuthenticatorCallback& | 20 const CreateBaseAuthenticatorCallback& |
21 create_base_authenticator_callback); | 21 create_base_authenticator_callback); |
22 ~PairingClientAuthenticator() override; | 22 ~PairingClientAuthenticator() override; |
23 | 23 |
24 // Start() or StartPaired() must be called after the authenticator is created. | |
25 // StartPaired() can only be used when pairing exists (i.e. client_id and | |
26 // pairing_secret are set in the |client_auth_config|). Start() handles both | |
27 // cases. | |
Jamie
2016/03/17 00:36:22
Make it clear why both are needed/useful; ie. "Sta
Sergey Ulanov
2016/03/17 00:49:21
Done.
| |
28 void Start(State initial_state, const base::Closure& resume_callback); | |
29 void StartPaired(State initial_state); | |
30 | |
24 // Authenticator interface. | 31 // Authenticator interface. |
25 State state() const override; | 32 State state() const override; |
26 | 33 |
27 private: | 34 private: |
28 // PairingAuthenticatorBase overrides. | 35 // PairingAuthenticatorBase overrides. |
29 void CreateSpakeAuthenticatorWithPin( | 36 void CreateSpakeAuthenticatorWithPin( |
30 State initial_state, | 37 State initial_state, |
31 const base::Closure& resume_callback) override; | 38 const base::Closure& resume_callback) override; |
32 void AddPairingElements(buzz::XmlElement* message) override; | |
33 | 39 |
34 void OnPinFetched(State initial_state, | 40 void OnPinFetched(State initial_state, |
35 const base::Closure& resume_callback, | 41 const base::Closure& resume_callback, |
36 const std::string& pin); | 42 const std::string& pin); |
37 | 43 |
38 ClientAuthenticationConfig client_auth_config_; | 44 ClientAuthenticationConfig client_auth_config_; |
39 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; | 45 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; |
40 | 46 |
41 // Set to true after client_id is sent to the host. | |
42 bool sent_client_id_ = false; | |
43 | |
44 // Set to true if a PIN-based authenticator has been requested but has not | 47 // Set to true if a PIN-based authenticator has been requested but has not |
45 // yet been set. | 48 // yet been set. |
46 bool waiting_for_pin_ = false; | 49 bool waiting_for_pin_ = false; |
47 | 50 |
48 base::WeakPtrFactory<PairingClientAuthenticator> weak_factory_; | 51 base::WeakPtrFactory<PairingClientAuthenticator> weak_factory_; |
49 | 52 |
50 DISALLOW_COPY_AND_ASSIGN(PairingClientAuthenticator); | 53 DISALLOW_COPY_AND_ASSIGN(PairingClientAuthenticator); |
51 }; | 54 }; |
52 | 55 |
53 } // namespace protocol | 56 } // namespace protocol |
54 } // namespace remoting | 57 } // namespace remoting |
55 | 58 |
56 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ | 59 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ |
OLD | NEW |