pairing_client_authenticator.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef REMOTING_PROTOCOL_PAIRING_CLIENT_AUTHENTICATOR_H_
  5. #define REMOTING_PROTOCOL_PAIRING_CLIENT_AUTHENTICATOR_H_
  6. #include "base/memory/weak_ptr.h"
  7. #include "remoting/protocol/client_authentication_config.h"
  8. #include "remoting/protocol/pairing_authenticator_base.h"
  9. namespace remoting {
  10. namespace protocol {
  11. class PairingClientAuthenticator : public PairingAuthenticatorBase {
  12. public:
  13. PairingClientAuthenticator(
  14. const ClientAuthenticationConfig& client_auth_config,
  15. const CreateBaseAuthenticatorCallback&
  16. create_base_authenticator_callback);
  17. PairingClientAuthenticator(const PairingClientAuthenticator&) = delete;
  18. PairingClientAuthenticator& operator=(const PairingClientAuthenticator&) =
  19. delete;
  20. ~PairingClientAuthenticator() override;
  21. // Start() or StartPaired() must be called after the authenticator is created.
  22. // Start() handles both cases when pairing exists and when it doesn't.
  23. // StartPaired() can only be used when pairing exists (i.e. client_id and
  24. // pairing_secret are set in the |client_auth_config|). It is used to
  25. // initialize the authenticator synchronously in
  26. // NegotiatingClientAuthenticator, while Start() may be executed
  27. // asynchronously to fetch the PIN.
  28. void Start(State initial_state, base::OnceClosure resume_callback);
  29. void StartPaired(State initial_state);
  30. // Authenticator interface.
  31. State state() const override;
  32. private:
  33. // PairingAuthenticatorBase overrides.
  34. void CreateSpakeAuthenticatorWithPin(
  35. State initial_state,
  36. base::OnceClosure resume_callback) override;
  37. void OnPinFetched(State initial_state,
  38. base::OnceClosure resume_callback,
  39. const std::string& pin);
  40. ClientAuthenticationConfig client_auth_config_;
  41. CreateBaseAuthenticatorCallback create_base_authenticator_callback_;
  42. // Set to true if a PIN-based authenticator has been requested but has not
  43. // yet been set.
  44. bool waiting_for_pin_ = false;
  45. base::WeakPtrFactory<PairingClientAuthenticator> weak_factory_{this};
  46. };
  47. } // namespace protocol
  48. } // namespace remoting
  49. #endif // REMOTING_PROTOCOL_PAIRING_CLIENT_AUTHENTICATOR_H_