[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ |
| 6 | #define REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/callback.h" |
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 12 | #include "base/memory/scoped_ptr.h" |
| 13 | #include "base/memory/weak_ptr.h" |
sergeyu | 64adc27 | 2016-03-12 09:12:43 | [diff] [blame^] | 14 | #include "remoting/protocol/client_authentication_config.h" |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 15 | #include "remoting/protocol/third_party_authenticator_base.h" |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 16 | |
| 17 | namespace remoting { |
| 18 | namespace protocol { |
| 19 | |
| 20 | // Implements the client side of the third party authentication mechanism. |
| 21 | // The client authenticator expects a |token_url| and |scope| in the first |
| 22 | // message from the host, then calls the |TokenFetcher| asynchronously to |
| 23 | // request a |token| and |shared_secret| from that url. If the server requires |
| 24 | // interactive authentication, the |TokenFetcher| implementation will show the |
| 25 | // appropriate UI. Once the |TokenFetcher| returns, the client sends the |token| |
| 26 | // to the host, and uses the |shared_secret| to create an underlying |
| 27 | // |V2Authenticator|, which is used to establish the encrypted connection. |
| 28 | class ThirdPartyClientAuthenticator : public ThirdPartyAuthenticatorBase { |
| 29 | public: |
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 30 | // Creates a third-party client authenticator. |
| 31 | // |create_base_authenticator_callback| is used to create the base |
| 32 | // authenticator. |token_fetcher| is used to get the authentication token. |
| 33 | ThirdPartyClientAuthenticator( |
| 34 | const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
sergeyu | 1acf67ba | 2016-03-10 02:59:14 | [diff] [blame] | 35 | const FetchThirdPartyTokenCallback& fetch_token_callback); |
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 36 | ~ThirdPartyClientAuthenticator() override; |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 37 | |
| 38 | protected: |
| 39 | // ThirdPartyAuthenticator implementation. |
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 40 | void ProcessTokenMessage(const buzz::XmlElement* message, |
| 41 | const base::Closure& resume_callback) override; |
| 42 | void AddTokenElements(buzz::XmlElement* message) override; |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 43 | |
| 44 | private: |
| 45 | void OnThirdPartyTokenFetched(const base::Closure& resume_callback, |
| 46 | const std::string& third_party_token, |
| 47 | const std::string& shared_secret); |
| 48 | |
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 49 | CreateBaseAuthenticatorCallback create_base_authenticator_callback_; |
sergeyu | 1acf67ba | 2016-03-10 02:59:14 | [diff] [blame] | 50 | FetchThirdPartyTokenCallback fetch_token_callback_; |
sergeyu | 12e320a | 2016-03-08 18:10:28 | [diff] [blame] | 51 | std::string token_; |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 52 | |
sergeyu | 1acf67ba | 2016-03-10 02:59:14 | [diff] [blame] | 53 | base::WeakPtrFactory<ThirdPartyClientAuthenticator> weak_factory_; |
| 54 | |
[email protected] | 9a6361d0 | 2013-03-23 16:27:52 | [diff] [blame] | 55 | DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator); |
| 56 | }; |
| 57 | |
| 58 | |
| 59 | } // namespace protocol |
| 60 | } // namespace remoting |
| 61 | |
| 62 | #endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ |