Index: remoting/protocol/third_party_host_authenticator.h |
diff --git a/remoting/protocol/third_party_host_authenticator.h b/remoting/protocol/third_party_host_authenticator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b0a0ffb35d3d07876a2157f29a73e63c7d667369 |
--- /dev/null |
+++ b/remoting/protocol/third_party_host_authenticator.h |
@@ -0,0 +1,78 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
+#define REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |
+ |
+#include <string> |
+ |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "googleurl/src/gurl.h" |
+#include "remoting/protocol/third_party_authenticator_base.h" |
+ |
+namespace remoting { |
+ |
+class RsaKeyPair; |
+ |
+namespace protocol { |
+ |
+class ThirdPartyHostAuthenticator : public ThirdPartyAuthenticatorBase { |
+ public: |
+ class TokenValidator { |
+ public: |
+ // Callback passed to |ValidateThirdPartyToken|, and called once the host |
+ // authentication finishes. |shared_secret| should be used by the host to |
+ // create a V2Authenticator. In case of failure, the callback is called with |
+ // an empty |shared_secret|. |
+ typedef base::Callback<void( |
+ const std::string& shared_secret)> TokenValidatedCallback; |
+ |
+ virtual ~TokenValidator() {} |
+ |
+ // Validates |token| with the server and exchanges it for a |shared_secret|. |
+ // |token_validated_callback| is called when the host authentication ends, |
+ // in the same thread |ValidateThirdPartyToken| was originally called. |
+ // The request is canceled if this object is destroyed. |
+ virtual void ValidateThirdPartyToken( |
+ const std::string& token, |
+ const TokenValidatedCallback& token_validated_callback) = 0; |
+ |
+ // URL sent to the client, to be used by its |TokenFetcher| to get a token. |
+ virtual const GURL& token_url() const = 0; |
Wez
2013/03/22 06:17:01
nit: blank line between this and comment
rmsousa
2013/03/22 21:19:05
Done.
|
+ // Space-separated list of connection attributes the host must send to the |
+ // client, and require the token received in response to match. |
+ virtual const std::string& token_scope() const = 0; |
+ }; |
+ |
+ // Creates a third-party host authenticator. |local_cert| and |key_pair| are |
+ // used by the underlying V2Authenticator to create the SSL channels. |
+ // |token_validator| contains the token parameters to be sent to the client |
+ // and is used to obtain the shared secret. |
+ ThirdPartyHostAuthenticator(const std::string& local_cert, |
+ scoped_refptr<RsaKeyPair> key_pair, |
+ scoped_ptr<TokenValidator> token_validator); |
+ virtual ~ThirdPartyHostAuthenticator(); |
+ |
+ protected: |
+ // ThirdPartyAuthenticator implementation. |
+ virtual void ProcessTokenMessage( |
+ const buzz::XmlElement* message, |
+ const base::Closure& resume_callback) OVERRIDE; |
+ virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE; |
+ |
+ private: |
+ void OnThirdPartyTokenValidated(const buzz::XmlElement* message, |
+ const base::Closure& resume_callback, |
+ const std::string& shared_secret); |
+ |
+ std::string local_cert_; |
+ scoped_refptr<RsaKeyPair> key_pair_; |
+ scoped_ptr<TokenValidator> token_validator_; |
+}; |
+ |
+} // namespace protocol |
+} // namespace remoting |
+ |
+#endif // REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ |