• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #include "base/memory/weak_ptr.h"
9 #include "remoting/protocol/pairing_authenticator_base.h"
10 #include "remoting/protocol/pairing_registry.h"
11 
12 namespace remoting {
13 
14 class RsaKeyPair;
15 
16 namespace protocol {
17 
18 class PairingRegistry;
19 
20 class PairingHostAuthenticator : public PairingAuthenticatorBase {
21  public:
22   PairingHostAuthenticator(
23       scoped_refptr<PairingRegistry> pairing_registry,
24       const std::string& local_cert,
25       scoped_refptr<RsaKeyPair> key_pair,
26       const std::string& pin);
27   virtual ~PairingHostAuthenticator();
28 
29   // Authenticator interface.
30   virtual State state() const OVERRIDE;
31   virtual RejectionReason rejection_reason() const OVERRIDE;
32   virtual void ProcessMessage(const buzz::XmlElement* message,
33                               const base::Closure& resume_callback) OVERRIDE;
34 
35  private:
36   // PairingAuthenticatorBase interface.
37   virtual void CreateV2AuthenticatorWithPIN(
38       State initial_state,
39       const SetAuthenticatorCallback& callback) OVERRIDE;
40   virtual void AddPairingElements(buzz::XmlElement* message) OVERRIDE;
41 
42   // Continue processing a protocol message once the pairing information for
43   // the client id has been received.
44   void ProcessMessageWithPairing(const buzz::XmlElement* message,
45                                  const base::Closure& resume_callback,
46                                  PairingRegistry::Pairing pairing);
47 
48   // Protocol state.
49   scoped_refptr<PairingRegistry> pairing_registry_;
50   std::string local_cert_;
51   scoped_refptr<RsaKeyPair> key_pair_;
52   const std::string& pin_;
53   bool protocol_error_;
54   bool waiting_for_paired_secret_;
55 
56   base::WeakPtrFactory<PairingHostAuthenticator> weak_factory_;
57 
58   DISALLOW_COPY_AND_ASSIGN(PairingHostAuthenticator);
59 };
60 
61 }  // namespace protocol
62 }  // namespace remoting
63 
64 #endif  // REMOTING_PROTOCOL_PAIRING_AUTHENTICATOR_H_
65