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 // Start() handles both cases when pairing exists and when it doesn't. |
| 26 // StartPaired() can only be used when pairing exists (i.e. client_id and |
| 27 // pairing_secret are set in the |client_auth_config|). It is used to |
| 28 // initialize the authenticator synchronously in |
| 29 // NegotiatingClientAuthentitcator, while Start() may be executed |
| 30 // asynchronously to fetch the PIN. |
| 31 void Start(State initial_state, const base::Closure& resume_callback); |
| 32 void StartPaired(State initial_state); |
| 33 |
24 // Authenticator interface. | 34 // Authenticator interface. |
25 State state() const override; | 35 State state() const override; |
26 | 36 |
27 private: | 37 private: |
28 // PairingAuthenticatorBase overrides. | 38 // PairingAuthenticatorBase overrides. |
29 void CreateSpakeAuthenticatorWithPin( | 39 void CreateSpakeAuthenticatorWithPin( |
30 State initial_state, | 40 State initial_state, |
31 const base::Closure& resume_callback) override; | 41 const base::Closure& resume_callback) override; |
32 void AddPairingElements(buzz::XmlElement* message) override; | |
33 | 42 |
34 void OnPinFetched(State initial_state, | 43 void OnPinFetched(State initial_state, |
35 const base::Closure& resume_callback, | 44 const base::Closure& resume_callback, |
36 const std::string& pin); | 45 const std::string& pin); |
37 | 46 |
38 ClientAuthenticationConfig client_auth_config_; | 47 ClientAuthenticationConfig client_auth_config_; |
39 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; | 48 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; |
40 | 49 |
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 | 50 // Set to true if a PIN-based authenticator has been requested but has not |
45 // yet been set. | 51 // yet been set. |
46 bool waiting_for_pin_ = false; | 52 bool waiting_for_pin_ = false; |
47 | 53 |
48 base::WeakPtrFactory<PairingClientAuthenticator> weak_factory_; | 54 base::WeakPtrFactory<PairingClientAuthenticator> weak_factory_; |
49 | 55 |
50 DISALLOW_COPY_AND_ASSIGN(PairingClientAuthenticator); | 56 DISALLOW_COPY_AND_ASSIGN(PairingClientAuthenticator); |
51 }; | 57 }; |
52 | 58 |
53 } // namespace protocol | 59 } // namespace protocol |
54 } // namespace remoting | 60 } // namespace remoting |
55 | 61 |
56 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ | 62 #endif // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_ |
OLD | NEW |