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/basictypes.h" | 11 #include "base/basictypes.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/authentication_method.h" | 14 #include "remoting/protocol/authentication_method.h" |
15 #include "remoting/protocol/authenticator.h" | 15 #include "remoting/protocol/authenticator.h" |
16 #include "remoting/protocol/negotiating_authenticator_base.h" | 16 #include "remoting/protocol/negotiating_authenticator_base.h" |
17 #include "remoting/protocol/third_party_client_authenticator.h" | 17 #include "remoting/protocol/third_party_client_authenticator.h" |
18 | 18 |
19 namespace remoting { | 19 namespace remoting { |
20 namespace protocol { | 20 namespace protocol { |
21 | 21 |
22 typedef base::Callback<void(const std::string& secret)> SecretFetchedCallback; | 22 typedef base::Callback<void(const std::string& secret)> SecretFetchedCallback; |
23 typedef base::Callback<void( | 23 typedef base::Callback<void( |
24 const SecretFetchedCallback& secret_fetched_callback)> FetchSecretCallback; | 24 const SecretFetchedCallback& secret_fetched_callback)> FetchSecretCallback; |
25 | 25 |
26 // Client-side implementation of NegotiatingAuthenticatorBase. | 26 // Client-side implementation of NegotiatingAuthenticatorBase. |
27 // See comments in negotiating_authenticator_base.h for a general explanation. | 27 // See comments in negotiating_authenticator_base.h for a general explanation. |
28 class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { | 28 class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { |
29 public: | 29 public: |
30 // TODO(jamiewalch): Pass ClientConfig instead of separate parameters. | |
Wez
2013/05/18 20:08:36
nit: SGTM but let's split out the auth-related mem
Jamie
2013/05/21 01:24:34
SGTM.
| |
30 NegotiatingClientAuthenticator( | 31 NegotiatingClientAuthenticator( |
32 const std::string& client_pairing_id, | |
33 const std::string& shared_secret, | |
31 const std::string& authentication_tag, | 34 const std::string& authentication_tag, |
32 const FetchSecretCallback& fetch_secret_callback, | 35 const FetchSecretCallback& fetch_secret_callback, |
33 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> token_fetcher_, | 36 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> token_fetcher_, |
34 const std::vector<AuthenticationMethod>& methods); | 37 const std::vector<AuthenticationMethod>& methods); |
35 | 38 |
36 virtual ~NegotiatingClientAuthenticator(); | 39 virtual ~NegotiatingClientAuthenticator(); |
37 | 40 |
38 // Overriden from Authenticator. | 41 // Overriden from Authenticator. |
39 virtual void ProcessMessage(const buzz::XmlElement* message, | 42 virtual void ProcessMessage(const buzz::XmlElement* message, |
40 const base::Closure& resume_callback) OVERRIDE; | 43 const base::Closure& resume_callback) OVERRIDE; |
41 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; | 44 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; |
42 | 45 |
43 private: | 46 private: |
44 // (Asynchronously) creates an authenticator, and stores it in | 47 // (Asynchronously) creates an authenticator, and stores it in |
45 // |current_authenticator_|. Authenticators that can be started in either | 48 // |current_authenticator_|. Authenticators that can be started in either |
46 // state will be created in |preferred_initial_state|. | 49 // state will be created in |preferred_initial_state|. |
47 // |resume_callback| is called after |current_authenticator_| is set. | 50 // |resume_callback| is called after |current_authenticator_| is set. |
48 void CreateAuthenticatorForCurrentMethod( | 51 void CreateAuthenticatorForCurrentMethod( |
49 Authenticator::State preferred_initial_state, | 52 Authenticator::State preferred_initial_state, |
50 const base::Closure& resume_callback); | 53 const base::Closure& resume_callback); |
51 | 54 |
52 // If possible, create a preferred authenticator ready to send an | 55 // If possible, create a preferred authenticator ready to send an |
53 // initial message optimistically to the host. The host is free to | 56 // initial message optimistically to the host. The host is free to |
54 // ignore the client's preferred authenticator and initial message | 57 // ignore the client's preferred authenticator and initial message |
55 // and to instead reply with an alternative method. See the comments | 58 // and to instead reply with an alternative method. See the comments |
56 // in negotiating_authenticator_base.h for more details. | 59 // in negotiating_authenticator_base.h for more details. |
57 // | 60 // |
58 // Returns the preferred authenticator if possible, or NULL otherwise. | 61 // Sets |current_authenticator_| and |current_method_| iff the client |
Wez
2013/05/18 20:08:36
Would it make more sense to add a getter to Authen
Jamie
2013/05/21 01:24:34
Maybe, but I don't think it needs to be done as pa
| |
59 scoped_ptr<Authenticator> CreatePreferredAuthenticator(); | 62 // has a preferred authenticator that can optimistically send an initial |
60 | 63 // message. |
64 void CreatePreferredAuthenticator(); | |
61 | 65 |
62 // Creates a V2Authenticator in state |initial_state| with the given | 66 // Creates a V2Authenticator in state |initial_state| with the given |
63 // |shared_secret|, then runs |resume_callback|. | 67 // |shared_secret|, then runs |resume_callback|. |
64 void CreateV2AuthenticatorWithSecret( | 68 void CreateV2AuthenticatorWithSecret( |
65 Authenticator::State initial_state, | 69 Authenticator::State initial_state, |
66 const base::Closure& resume_callback, | 70 const base::Closure& resume_callback, |
67 const std::string& shared_secret); | 71 const std::string& shared_secret); |
68 | 72 |
73 // Used for pairing authenticators | |
74 std::string client_pairing_id_; | |
75 std::string shared_secret_; | |
76 | |
69 // Used for both authenticators. | 77 // Used for both authenticators. |
Wez
2013/05/18 20:08:36
nit: This probably needs updating, since there are
Jamie
2013/05/21 01:24:34
Updated.
| |
70 std::string authentication_tag_; | 78 std::string authentication_tag_; |
71 | 79 |
72 // Used for shared secret authenticators. | 80 // Used for shared secret authenticators. |
73 FetchSecretCallback fetch_secret_callback_; | 81 FetchSecretCallback fetch_secret_callback_; |
74 | 82 |
75 // Used for third party authenticators. | 83 // Used for third party authenticators. |
76 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> token_fetcher_; | 84 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> token_fetcher_; |
77 | 85 |
78 // Internal NegotiatingClientAuthenticator data. | 86 // Internal NegotiatingClientAuthenticator data. |
79 bool method_set_by_host_; | 87 bool method_set_by_host_; |
80 base::WeakPtrFactory<NegotiatingClientAuthenticator> weak_factory_; | 88 base::WeakPtrFactory<NegotiatingClientAuthenticator> weak_factory_; |
81 | 89 |
82 DISALLOW_COPY_AND_ASSIGN(NegotiatingClientAuthenticator); | 90 DISALLOW_COPY_AND_ASSIGN(NegotiatingClientAuthenticator); |
83 }; | 91 }; |
84 | 92 |
85 } // namespace protocol | 93 } // namespace protocol |
86 } // namespace remoting | 94 } // namespace remoting |
87 | 95 |
88 #endif // REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ | 96 #endif // REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ |
OLD | NEW |