| 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_THIRD_PARTY_HOST_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 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 "remoting/protocol/third_party_authenticator_base.h" | 13 #include "remoting/protocol/third_party_authenticator_base.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | |
| 17 class RsaKeyPair; | |
| 18 | |
| 19 namespace protocol { | 16 namespace protocol { |
| 20 | 17 |
| 21 class TokenValidator; | 18 class TokenValidator; |
| 22 | 19 |
| 23 // Implements the host side of the third party authentication mechanism. | 20 // Implements the host side of the third party authentication mechanism. |
| 24 // The host authenticator sends the |token_url| and |scope| obtained from the | 21 // The host authenticator sends the |token_url| and |scope| obtained from the |
| 25 // |TokenValidator| to the client, and expects a |token| in response. | 22 // |TokenValidator| to the client, and expects a |token| in response. |
| 26 // Once that token is received, it calls |TokenValidator| asynchronously to | 23 // Once that token is received, it calls |TokenValidator| asynchronously to |
| 27 // validate it, and exchange it for a |shared_secret|. Once the |TokenValidator| | 24 // validate it, and exchange it for a |shared_secret|. Once the |TokenValidator| |
| 28 // returns, the host uses the |shared_secret| to create an underlying | 25 // returns, the host uses the |shared_secret| to create an underlying |
| 29 // |V2Authenticator|, which is used to establish the encrypted connection. | 26 // SPAKE2 authenticator, which is used to establish the encrypted connection. |
| 30 class ThirdPartyHostAuthenticator : public ThirdPartyAuthenticatorBase { | 27 class ThirdPartyHostAuthenticator : public ThirdPartyAuthenticatorBase { |
| 31 public: | 28 public: |
| 32 // Creates a third-party host authenticator. |local_cert| and |key_pair| are | 29 // Creates a third-party host authenticator. |
| 33 // used by the underlying V2Authenticator to create the SSL channels. | 30 // |create_base_authenticator_callback| is used to create the base |
| 34 // |token_validator| contains the token parameters to be sent to the client | 31 // authenticator. |token_validator| contains the token parameters to be sent |
| 35 // and is used to obtain the shared secret. | 32 // to the client and is used to obtain the shared secret. |
| 36 ThirdPartyHostAuthenticator(const std::string& local_cert, | 33 ThirdPartyHostAuthenticator( |
| 37 scoped_refptr<RsaKeyPair> key_pair, | 34 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
| 38 scoped_ptr<TokenValidator> token_validator); | 35 scoped_ptr<TokenValidator> token_validator); |
| 39 ~ThirdPartyHostAuthenticator() override; | 36 ~ThirdPartyHostAuthenticator() override; |
| 40 | 37 |
| 41 protected: | 38 protected: |
| 42 // ThirdPartyAuthenticator implementation. | 39 // ThirdPartyAuthenticator implementation. |
| 43 void ProcessTokenMessage(const buzz::XmlElement* message, | 40 void ProcessTokenMessage(const buzz::XmlElement* message, |
| 44 const base::Closure& resume_callback) override; | 41 const base::Closure& resume_callback) override; |
| 45 void AddTokenElements(buzz::XmlElement* message) override; | 42 void AddTokenElements(buzz::XmlElement* message) override; |
| 46 | 43 |
| 47 private: | 44 private: |
| 48 void OnThirdPartyTokenValidated(const buzz::XmlElement* message, | 45 void OnThirdPartyTokenValidated(const buzz::XmlElement* message, |
| 49 const base::Closure& resume_callback, | 46 const base::Closure& resume_callback, |
| 50 const std::string& shared_secret); | 47 const std::string& shared_secret); |
| 51 | 48 |
| 52 std::string local_cert_; | 49 CreateBaseAuthenticatorCallback create_base_authenticator_callback_; |
| 53 scoped_refptr<RsaKeyPair> key_pair_; | |
| 54 scoped_ptr<TokenValidator> token_validator_; | 50 scoped_ptr<TokenValidator> token_validator_; |
| 55 | 51 |
| 56 DISALLOW_COPY_AND_ASSIGN(ThirdPartyHostAuthenticator); | 52 DISALLOW_COPY_AND_ASSIGN(ThirdPartyHostAuthenticator); |
| 57 }; | 53 }; |
| 58 | 54 |
| 59 } // namespace protocol | 55 } // namespace protocol |
| 60 } // namespace remoting | 56 } // namespace remoting |
| 61 | 57 |
| 62 #endif // REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ | 58 #endif // REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
| OLD | NEW |