OLD | NEW |
(Empty) | |
| 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_HOST_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "googleurl/src/gurl.h" |
| 13 #include "remoting/protocol/third_party_authenticator_base.h" |
| 14 |
| 15 namespace remoting { |
| 16 |
| 17 class RsaKeyPair; |
| 18 |
| 19 namespace protocol { |
| 20 |
| 21 class ThirdPartyHostAuthenticator : public ThirdPartyAuthenticatorBase { |
| 22 public: |
| 23 class TokenValidator { |
| 24 public: |
| 25 // Callback passed to |ValidateThirdPartyToken|, and called once the host |
| 26 // authentication finishes. |shared_secret| should be used by the host to |
| 27 // create a V2Authenticator. In case of failure, the callback is called with |
| 28 // an empty |shared_secret|. |
| 29 typedef base::Callback<void( |
| 30 const std::string& shared_secret)> TokenValidatedCallback; |
| 31 |
| 32 virtual ~TokenValidator() {} |
| 33 |
| 34 // Validates |token| with the server and exchanges it for a |shared_secret|. |
| 35 // |token_validated_callback| is called when the host authentication ends, |
| 36 // in the same thread |ValidateThirdPartyToken| was originally called. |
| 37 // The request is canceled if this object is destroyed. |
| 38 virtual void ValidateThirdPartyToken( |
| 39 const std::string& token, |
| 40 const TokenValidatedCallback& token_validated_callback) = 0; |
| 41 |
| 42 // URL sent to the client, to be used by its |TokenFetcher| to get a token. |
| 43 virtual const GURL& token_url() const = 0; |
| 44 // Space-separated list of connection attributes the host must send to the |
| 45 // client, and require the token received in response to match. |
| 46 virtual const std::string& token_scope() const = 0; |
| 47 }; |
| 48 |
| 49 // Creates a third-party host authenticator. |local_cert| and |key_pair| are |
| 50 // used by the underlying V2Authenticator to create the SSL channels. |
| 51 // |token_validator| contains the token parameters to be sent to the client |
| 52 // and is used to obtain the shared secret. |
| 53 ThirdPartyHostAuthenticator(const std::string& local_cert, |
| 54 scoped_refptr<RsaKeyPair> key_pair, |
| 55 scoped_ptr<TokenValidator> token_validator, |
| 56 Authenticator::State initial_state); |
| 57 virtual ~ThirdPartyHostAuthenticator(); |
| 58 |
| 59 protected: |
| 60 // ThirdPartyAuthenticator implementation. |
| 61 virtual void ProcessMessageInternal( |
| 62 const buzz::XmlElement* message, |
| 63 const base::Closure& resume_callback) OVERRIDE; |
| 64 virtual void GetNextMessageInternal(buzz::XmlElement* message) OVERRIDE; |
| 65 |
| 66 private: |
| 67 void OnThirdPartyTokenValidated(const buzz::XmlElement* message, |
| 68 const base::Closure& resume_callback, |
| 69 const std::string& shared_secret); |
| 70 bool has_sent_urls_; |
| 71 std::string local_cert_; |
| 72 scoped_refptr<RsaKeyPair> key_pair_; |
| 73 scoped_ptr<TokenValidator> token_validator_; |
| 74 }; |
| 75 |
| 76 } // namespace protocol |
| 77 } // namespace remoting |
| 78 |
| 79 #endif // REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
OLD | NEW |