Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / remoting / protocol / pairing_host_authenticator.h
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   ~PairingHostAuthenticator() override;
28
29   // Authenticator interface.
30   State state() const override;
31   RejectionReason rejection_reason() const override;
32   void ProcessMessage(const buzz::XmlElement* message,
33                       const base::Closure& resume_callback) override;
34
35  private:
36   // PairingAuthenticatorBase interface.
37   void CreateV2AuthenticatorWithPIN(
38       State initial_state,
39       const SetAuthenticatorCallback& callback) override;
40   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_