pairing_host_authenticator.h 2.2 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_HOST_AUTHENTICATOR_H_
  5. #define REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_H_
  6. #include "base/memory/weak_ptr.h"
  7. #include "remoting/protocol/pairing_authenticator_base.h"
  8. #include "remoting/protocol/pairing_registry.h"
  9. namespace remoting {
  10. namespace protocol {
  11. class PairingRegistry;
  12. class PairingHostAuthenticator : public PairingAuthenticatorBase {
  13. public:
  14. PairingHostAuthenticator(
  15. scoped_refptr<PairingRegistry> pairing_registry,
  16. const CreateBaseAuthenticatorCallback& create_base_authenticator_callback,
  17. const std::string& pin);
  18. PairingHostAuthenticator(const PairingHostAuthenticator&) = delete;
  19. PairingHostAuthenticator& operator=(const PairingHostAuthenticator&) = delete;
  20. ~PairingHostAuthenticator() override;
  21. // Initialize the authenticator with the given |client_id| in
  22. // |preferred_initial_state|.
  23. void Initialize(const std::string& client_id,
  24. Authenticator::State preferred_initial_state,
  25. base::OnceClosure resume_callback);
  26. // Authenticator interface.
  27. State state() const override;
  28. RejectionReason rejection_reason() const override;
  29. private:
  30. // PairingAuthenticatorBase overrides.
  31. void CreateSpakeAuthenticatorWithPin(
  32. State initial_state,
  33. base::OnceClosure resume_callback) override;
  34. // Continue initializing once the pairing information for the client id has
  35. // been received.
  36. void InitializeWithPairing(Authenticator::State preferred_initial_state,
  37. base::OnceClosure resume_callback,
  38. PairingRegistry::Pairing pairing);
  39. // Protocol state.
  40. scoped_refptr<PairingRegistry> pairing_registry_;
  41. CreateBaseAuthenticatorCallback create_base_authenticator_callback_;
  42. std::string pin_;
  43. bool protocol_error_ = false;
  44. bool waiting_for_paired_secret_ = false;
  45. base::WeakPtrFactory<PairingHostAuthenticator> weak_factory_{this};
  46. };
  47. } // namespace protocol
  48. } // namespace remoting
  49. #endif // REMOTING_PROTOCOL_PAIRING_HOST_AUTHENTICATOR_H_