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; | |
Wez
2013/03/22 06:17:01
nit: blank line between this and comment
rmsousa
2013/03/22 21:19:05
Done.
| |
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 virtual ~ThirdPartyHostAuthenticator(); | |
57 | |
58 protected: | |
59 // ThirdPartyAuthenticator implementation. | |
60 virtual void ProcessTokenMessage( | |
61 const buzz::XmlElement* message, | |
62 const base::Closure& resume_callback) OVERRIDE; | |
63 virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE; | |
64 | |
65 private: | |
66 void OnThirdPartyTokenValidated(const buzz::XmlElement* message, | |
67 const base::Closure& resume_callback, | |
68 const std::string& shared_secret); | |
69 | |
70 std::string local_cert_; | |
71 scoped_refptr<RsaKeyPair> key_pair_; | |
72 scoped_ptr<TokenValidator> token_validator_; | |
73 }; | |
74 | |
75 } // namespace protocol | |
76 } // namespace remoting | |
77 | |
78 #endif // REMOTING_PROTOCOL_THIRD_PARTY_HOST_AUTHENTICATOR_H_ | |
OLD | NEW |