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_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ |
6 #define REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
15 #include "remoting/protocol/negotiating_authenticator_base.h" | 15 #include "remoting/protocol/negotiating_authenticator_base.h" |
16 #include "remoting/protocol/third_party_client_authenticator.h" | 16 #include "remoting/protocol/third_party_client_authenticator.h" |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 namespace protocol { | 19 namespace protocol { |
20 | 20 |
21 struct ClientAuthenticationConfig { | |
22 ClientAuthenticationConfig(); | |
23 ~ClientAuthenticationConfig(); | |
24 | |
25 // Used for all authenticators. | |
26 std::string host_id; | |
27 | |
28 // Used for pairing authenticators | |
29 std::string pairing_client_id; | |
30 std::string pairing_secret; | |
31 | |
32 // Used for shared secret authenticators. | |
33 FetchSecretCallback fetch_secret_callback; | |
34 | |
35 // Used for third party authenticators. | |
36 FetchThirdPartyTokenCallback fetch_third_party_token_callback; | |
37 }; | |
38 | |
39 // Client-side implementation of NegotiatingAuthenticatorBase. | 21 // Client-side implementation of NegotiatingAuthenticatorBase. |
40 // See comments in negotiating_authenticator_base.h for a general explanation. | 22 // See comments in negotiating_authenticator_base.h for a general explanation. |
41 class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { | 23 class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { |
42 public: | 24 public: |
43 explicit NegotiatingClientAuthenticator( | 25 // TODO(jamiewalch): Pass ClientConfig instead of separate parameters. |
44 const ClientAuthenticationConfig& config); | 26 NegotiatingClientAuthenticator( |
| 27 const std::string& client_pairing_id, |
| 28 const std::string& shared_secret, |
| 29 const std::string& authentication_tag, |
| 30 const FetchSecretCallback& fetch_secret_callback, |
| 31 const FetchThirdPartyTokenCallback& fetch_third_party_token_callback); |
| 32 |
45 ~NegotiatingClientAuthenticator() override; | 33 ~NegotiatingClientAuthenticator() override; |
46 | 34 |
47 // Overriden from Authenticator. | 35 // Overriden from Authenticator. |
48 void ProcessMessage(const buzz::XmlElement* message, | 36 void ProcessMessage(const buzz::XmlElement* message, |
49 const base::Closure& resume_callback) override; | 37 const base::Closure& resume_callback) override; |
50 scoped_ptr<buzz::XmlElement> GetNextMessage() override; | 38 scoped_ptr<buzz::XmlElement> GetNextMessage() override; |
51 | 39 |
52 private: | 40 private: |
53 // (Asynchronously) creates an authenticator, and stores it in | 41 // (Asynchronously) creates an authenticator, and stores it in |
54 // |current_authenticator_|. Authenticators that can be started in either | 42 // |current_authenticator_|. Authenticators that can be started in either |
(...skipping 14 matching lines...) Expand all Loading... |
69 // message. | 57 // message. |
70 void CreatePreferredAuthenticator(); | 58 void CreatePreferredAuthenticator(); |
71 | 59 |
72 // Creates a V2Authenticator in state |initial_state| with the given | 60 // Creates a V2Authenticator in state |initial_state| with the given |
73 // |shared_secret|, then runs |resume_callback|. | 61 // |shared_secret|, then runs |resume_callback|. |
74 void CreateV2AuthenticatorWithSecret( | 62 void CreateV2AuthenticatorWithSecret( |
75 Authenticator::State initial_state, | 63 Authenticator::State initial_state, |
76 const base::Closure& resume_callback, | 64 const base::Closure& resume_callback, |
77 const std::string& shared_secret); | 65 const std::string& shared_secret); |
78 | 66 |
79 ClientAuthenticationConfig config_; | 67 // Used for pairing authenticators |
| 68 std::string client_pairing_id_; |
| 69 std::string shared_secret_; |
| 70 |
| 71 // Used for all authenticators. |
| 72 std::string authentication_tag_; |
| 73 |
| 74 // Used for shared secret authenticators. |
| 75 FetchSecretCallback fetch_secret_callback_; |
| 76 |
| 77 // Used for third party authenticators. |
| 78 FetchThirdPartyTokenCallback fetch_third_party_token_callback_; |
80 | 79 |
81 // Internal NegotiatingClientAuthenticator data. | 80 // Internal NegotiatingClientAuthenticator data. |
82 bool method_set_by_host_ = false; | 81 bool method_set_by_host_ = false; |
83 base::WeakPtrFactory<NegotiatingClientAuthenticator> weak_factory_; | 82 base::WeakPtrFactory<NegotiatingClientAuthenticator> weak_factory_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(NegotiatingClientAuthenticator); | 84 DISALLOW_COPY_AND_ASSIGN(NegotiatingClientAuthenticator); |
86 }; | 85 }; |
87 | 86 |
88 } // namespace protocol | 87 } // namespace protocol |
89 } // namespace remoting | 88 } // namespace remoting |
90 | 89 |
91 #endif // REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ | 90 #endif // REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ |
OLD | NEW |