| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Used for third party authenticators. | 35 // Used for third party authenticators. |
| 36 FetchThirdPartyTokenCallback fetch_third_party_token_callback; | 36 FetchThirdPartyTokenCallback fetch_third_party_token_callback; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // Client-side implementation of NegotiatingAuthenticatorBase. | 39 // Client-side implementation of NegotiatingAuthenticatorBase. |
| 40 // See comments in negotiating_authenticator_base.h for a general explanation. | 40 // See comments in negotiating_authenticator_base.h for a general explanation. |
| 41 class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { | 41 class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { |
| 42 public: | 42 public: |
| 43 explicit NegotiatingClientAuthenticator( | 43 explicit NegotiatingClientAuthenticator( |
| 44 const std::string& local_id, |
| 45 const std::string& remote_id, |
| 44 const ClientAuthenticationConfig& config); | 46 const ClientAuthenticationConfig& config); |
| 45 ~NegotiatingClientAuthenticator() override; | 47 ~NegotiatingClientAuthenticator() override; |
| 46 | 48 |
| 47 // Overriden from Authenticator. | 49 // Overriden from Authenticator. |
| 48 void ProcessMessage(const buzz::XmlElement* message, | 50 void ProcessMessage(const buzz::XmlElement* message, |
| 49 const base::Closure& resume_callback) override; | 51 const base::Closure& resume_callback) override; |
| 50 scoped_ptr<buzz::XmlElement> GetNextMessage() override; | 52 scoped_ptr<buzz::XmlElement> GetNextMessage() override; |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 // (Asynchronously) creates an authenticator, and stores it in | 55 // (Asynchronously) creates an authenticator, and stores it in |
| 54 // |current_authenticator_|. Authenticators that can be started in either | 56 // |current_authenticator_|. Authenticators that can be started in either |
| 55 // state will be created in |preferred_initial_state|. | 57 // state will be created in |preferred_initial_state|. |
| 56 // |resume_callback| is called after |current_authenticator_| is set. | 58 // |resume_callback| is called after |current_authenticator_| is set. |
| 57 void CreateAuthenticatorForCurrentMethod( | 59 void CreateAuthenticatorForCurrentMethod( |
| 58 Authenticator::State preferred_initial_state, | 60 Authenticator::State preferred_initial_state, |
| 59 const base::Closure& resume_callback); | 61 const base::Closure& resume_callback); |
| 60 | 62 |
| 61 // If possible, create a preferred authenticator ready to send an | 63 // If possible, create a preferred authenticator ready to send an |
| 62 // initial message optimistically to the host. The host is free to | 64 // initial message optimistically to the host. The host is free to |
| 63 // ignore the client's preferred authenticator and initial message | 65 // ignore the client's preferred authenticator and initial message |
| 64 // and to instead reply with an alternative method. See the comments | 66 // and to instead reply with an alternative method. See the comments |
| 65 // in negotiating_authenticator_base.h for more details. | 67 // in negotiating_authenticator_base.h for more details. |
| 66 // | 68 // |
| 67 // Sets |current_authenticator_| and |current_method_| iff the client | 69 // Sets |current_authenticator_| and |current_method_| iff the client |
| 68 // has a preferred authenticator that can optimistically send an initial | 70 // has a preferred authenticator that can optimistically send an initial |
| 69 // message. | 71 // message. |
| 70 void CreatePreferredAuthenticator(); | 72 void CreatePreferredAuthenticator(); |
| 71 | 73 |
| 72 // Creates a V2Authenticator in state |initial_state| with the given | 74 // Creates a shared-secret authenticator in state |initial_state| with the |
| 73 // |shared_secret|, then runs |resume_callback|. | 75 // given |shared_secret|, then runs |resume_callback|. |
| 74 void CreateV2AuthenticatorWithSecret( | 76 void CreateSharedSecretAuthenticator(Authenticator::State initial_state, |
| 75 Authenticator::State initial_state, | 77 const base::Closure& resume_callback, |
| 76 const base::Closure& resume_callback, | 78 const std::string& shared_secret); |
| 77 const std::string& shared_secret); | 79 |
| 80 std::string local_id_; |
| 81 std::string remote_id_; |
| 78 | 82 |
| 79 ClientAuthenticationConfig config_; | 83 ClientAuthenticationConfig config_; |
| 80 | 84 |
| 81 // Internal NegotiatingClientAuthenticator data. | 85 // Internal NegotiatingClientAuthenticator data. |
| 82 bool method_set_by_host_ = false; | 86 bool method_set_by_host_ = false; |
| 83 base::WeakPtrFactory<NegotiatingClientAuthenticator> weak_factory_; | 87 base::WeakPtrFactory<NegotiatingClientAuthenticator> weak_factory_; |
| 84 | 88 |
| 85 DISALLOW_COPY_AND_ASSIGN(NegotiatingClientAuthenticator); | 89 DISALLOW_COPY_AND_ASSIGN(NegotiatingClientAuthenticator); |
| 86 }; | 90 }; |
| 87 | 91 |
| 88 } // namespace protocol | 92 } // namespace protocol |
| 89 } // namespace remoting | 93 } // namespace remoting |
| 90 | 94 |
| 91 #endif // REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ | 95 #endif // REMOTING_PROTOCOL_NEGOTIATING_CLIENT_AUTHENTICATOR_H_ |
| OLD | NEW |