| 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_HOST_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_NEGOTIATING_HOST_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_NEGOTIATING_HOST_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_NEGOTIATING_HOST_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/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "remoting/protocol/authentication_method.h" | |
| 15 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
| 16 #include "remoting/protocol/negotiating_authenticator_base.h" | 15 #include "remoting/protocol/negotiating_authenticator_base.h" |
| 17 #include "remoting/protocol/pairing_registry.h" | 16 #include "remoting/protocol/pairing_registry.h" |
| 18 #include "remoting/protocol/third_party_host_authenticator.h" | 17 #include "remoting/protocol/third_party_host_authenticator.h" |
| 19 | 18 |
| 20 namespace remoting { | 19 namespace remoting { |
| 21 | 20 |
| 22 class RsaKeyPair; | 21 class RsaKeyPair; |
| 23 | 22 |
| 24 namespace protocol { | 23 namespace protocol { |
| 25 | 24 |
| 26 // Host-side implementation of NegotiatingAuthenticatorBase. | 25 // Host-side implementation of NegotiatingAuthenticatorBase. |
| 27 // See comments in negotiating_authenticator_base.h for a general explanation. | 26 // See comments in negotiating_authenticator_base.h for a general explanation. |
| 28 class NegotiatingHostAuthenticator : public NegotiatingAuthenticatorBase { | 27 class NegotiatingHostAuthenticator : public NegotiatingAuthenticatorBase { |
| 29 public: | 28 public: |
| 30 ~NegotiatingHostAuthenticator() override; | 29 ~NegotiatingHostAuthenticator() override; |
| 31 | 30 |
| 32 // Creates a host authenticator for It2Me host. | 31 // Creates a host authenticator for It2Me host. |
| 33 static scoped_ptr<Authenticator> CreateForIt2Me( | 32 static scoped_ptr<Authenticator> CreateForIt2Me( |
| 34 const std::string& local_cert, | 33 const std::string& local_cert, |
| 35 scoped_refptr<RsaKeyPair> key_pair, | 34 scoped_refptr<RsaKeyPair> key_pair, |
| 36 const std::string& access_code); | 35 const std::string& access_code); |
| 37 | 36 |
| 38 // Creates a host authenticator, using a fixed PIN. | 37 // Creates a host authenticator, using a fixed PIN. If |pairing_registry| is |
| 39 // If |pairing_registry| is non-nullptr then the spake2_pair method will | 38 // non-nullptr then the paired methods will be offered, supporting |
| 40 // be offered, supporting PIN-less authentication. | 39 // PIN-less authentication. |
| 41 static scoped_ptr<Authenticator> CreateWithPin( | 40 static scoped_ptr<Authenticator> CreateWithPin( |
| 42 const std::string& local_cert, | 41 const std::string& local_cert, |
| 43 scoped_refptr<RsaKeyPair> key_pair, | 42 scoped_refptr<RsaKeyPair> key_pair, |
| 44 const std::string& pin_hash, | 43 const std::string& pin_hash, |
| 45 scoped_refptr<PairingRegistry> pairing_registry); | 44 scoped_refptr<PairingRegistry> pairing_registry); |
| 46 | 45 |
| 47 // Creates a host authenticator, using third party authentication. | 46 // Creates a host authenticator, using third party authentication. |
| 48 static scoped_ptr<Authenticator> CreateWithThirdPartyAuth( | 47 static scoped_ptr<Authenticator> CreateWithThirdPartyAuth( |
| 49 const std::string& local_cert, | 48 const std::string& local_cert, |
| 50 scoped_refptr<RsaKeyPair> key_pair, | 49 scoped_refptr<RsaKeyPair> key_pair, |
| 51 scoped_ptr<TokenValidator> token_validator); | 50 scoped_ptr<TokenValidator> token_validator); |
| 52 | 51 |
| 53 // Overriden from Authenticator. | 52 // Overriden from Authenticator. |
| 54 void ProcessMessage(const buzz::XmlElement* message, | 53 void ProcessMessage(const buzz::XmlElement* message, |
| 55 const base::Closure& resume_callback) override; | 54 const base::Closure& resume_callback) override; |
| 56 scoped_ptr<buzz::XmlElement> GetNextMessage() override; | 55 scoped_ptr<buzz::XmlElement> GetNextMessage() override; |
| 57 | 56 |
| 58 private: | 57 private: |
| 59 NegotiatingHostAuthenticator( | 58 NegotiatingHostAuthenticator(const std::string& local_cert, |
| 60 const std::string& local_cert, | 59 scoped_refptr<RsaKeyPair> key_pair); |
| 61 scoped_refptr<RsaKeyPair> key_pair); | |
| 62 | 60 |
| 63 // (Asynchronously) creates an authenticator, and stores it in | 61 // (Asynchronously) creates an authenticator, and stores it in |
| 64 // |current_authenticator_|. Authenticators that can be started in either | 62 // |current_authenticator_|. Authenticators that can be started in either |
| 65 // state will be created in |preferred_initial_state|. | 63 // state will be created in |preferred_initial_state|. |
| 66 // |resume_callback| is called after |current_authenticator_| is set. | 64 // |resume_callback| is called after |current_authenticator_| is set. |
| 67 void CreateAuthenticator(Authenticator::State preferred_initial_state, | 65 void CreateAuthenticator(Authenticator::State preferred_initial_state, |
| 68 const base::Closure& resume_callback); | 66 const base::Closure& resume_callback); |
| 69 | 67 |
| 70 std::string local_cert_; | 68 std::string local_cert_; |
| 71 scoped_refptr<RsaKeyPair> local_key_pair_; | 69 scoped_refptr<RsaKeyPair> local_key_pair_; |
| 72 | 70 |
| 73 // Used only for shared secret host authenticators. | 71 // Used only for shared secret host authenticators. |
| 74 std::string shared_secret_hash_; | 72 std::string shared_secret_hash_; |
| 75 | 73 |
| 76 // Used only for third party host authenticators. | 74 // Used only for third party host authenticators. |
| 77 scoped_ptr<TokenValidator> token_validator_; | 75 scoped_ptr<TokenValidator> token_validator_; |
| 78 | 76 |
| 79 // Used only for pairing authenticators. | 77 // Used only for pairing authenticators. |
| 80 scoped_refptr<PairingRegistry> pairing_registry_; | 78 scoped_refptr<PairingRegistry> pairing_registry_; |
| 81 | 79 |
| 82 DISALLOW_COPY_AND_ASSIGN(NegotiatingHostAuthenticator); | 80 DISALLOW_COPY_AND_ASSIGN(NegotiatingHostAuthenticator); |
| 83 }; | 81 }; |
| 84 | 82 |
| 85 } // namespace protocol | 83 } // namespace protocol |
| 86 } // namespace remoting | 84 } // namespace remoting |
| 87 | 85 |
| 88 #endif // REMOTING_PROTOCOL_NEGOTIATING_HOST_AUTHENTICATOR_H_ | 86 #endif // REMOTING_PROTOCOL_NEGOTIATING_HOST_AUTHENTICATOR_H_ |
| OLD | NEW |