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_CLIENT_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ |
6 #define REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "googleurl/src/gurl.h" |
13 #include "remoting/protocol/third_party_authenticator_base.h" | 14 #include "remoting/protocol/third_party_authenticator_base.h" |
14 | 15 |
15 class GURL; | 16 class GURL; |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 namespace protocol { | 19 namespace protocol { |
19 | 20 |
20 // Implements the client side of the third party authentication mechanism. | 21 // Implements the client side of the third party authentication mechanism. |
21 // The client authenticator expects a |token_url| and |scope| in the first | 22 // The client authenticator expects a |token_url| and |scope| in the first |
22 // message from the host, then calls the |TokenFetcher| asynchronously to | 23 // message from the host, then calls the |TokenFetcher| asynchronously to |
(...skipping 19 matching lines...) Expand all Loading... |
42 | 43 |
43 // Fetches a third party token from |token_url|. |host_public_key| is sent | 44 // Fetches a third party token from |token_url|. |host_public_key| is sent |
44 // to the server so it can later authenticate the host. |scope| is a string | 45 // to the server so it can later authenticate the host. |scope| is a string |
45 // with a space-separated list of attributes for this connection (e.g. | 46 // with a space-separated list of attributes for this connection (e.g. |
46 // "hostjid:abc@example.com/123 clientjid:def@example.org/456". | 47 // "hostjid:abc@example.com/123 clientjid:def@example.org/456". |
47 // |token_fetched_callback| is called when the client authentication ends, | 48 // |token_fetched_callback| is called when the client authentication ends, |
48 // in the same thread |FetchThirdPartyToken| was originally called. | 49 // in the same thread |FetchThirdPartyToken| was originally called. |
49 // The request is canceled if the TokenFetcher is destroyed. | 50 // The request is canceled if the TokenFetcher is destroyed. |
50 virtual void FetchThirdPartyToken( | 51 virtual void FetchThirdPartyToken( |
51 const GURL& token_url, | 52 const GURL& token_url, |
52 const std::string& host_public_key, | |
53 const std::string& scope, | 53 const std::string& scope, |
54 const TokenFetchedCallback& token_fetched_callback) = 0; | 54 const TokenFetchedCallback& token_fetched_callback) = 0; |
55 }; | 55 }; |
56 | 56 |
57 // Creates a third-party client authenticator for the host with the given | 57 // Creates a third-party client authenticator for the host with the given |
58 // |host_public_key|. |token_fetcher| is used to get the authentication token. | 58 // |host_public_key|. |token_fetcher| is used to get the authentication token. |
59 ThirdPartyClientAuthenticator(const std::string& host_public_key, | 59 explicit ThirdPartyClientAuthenticator( |
60 scoped_ptr<TokenFetcher> token_fetcher); | 60 scoped_ptr<TokenFetcher> token_fetcher); |
61 virtual ~ThirdPartyClientAuthenticator(); | 61 virtual ~ThirdPartyClientAuthenticator(); |
62 | 62 |
63 protected: | 63 protected: |
64 // ThirdPartyAuthenticator implementation. | 64 // ThirdPartyAuthenticator implementation. |
65 virtual void ProcessTokenMessage( | 65 virtual void ProcessTokenMessage( |
66 const buzz::XmlElement* message, | 66 const buzz::XmlElement* message, |
67 const base::Closure& resume_callback) OVERRIDE; | 67 const base::Closure& resume_callback) OVERRIDE; |
68 virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE; | 68 virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE; |
69 | 69 |
70 private: | 70 private: |
71 void OnThirdPartyTokenFetched(const base::Closure& resume_callback, | 71 void OnThirdPartyTokenFetched(const base::Closure& resume_callback, |
72 const std::string& third_party_token, | 72 const std::string& third_party_token, |
73 const std::string& shared_secret); | 73 const std::string& shared_secret); |
74 | 74 |
75 std::string host_public_key_; | |
76 std::string token_; | 75 std::string token_; |
77 scoped_ptr<TokenFetcher> token_fetcher_; | 76 scoped_ptr<TokenFetcher> token_fetcher_; |
78 | 77 |
79 DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator); | 78 DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator); |
80 }; | 79 }; |
81 | 80 |
82 | 81 |
83 } // namespace protocol | 82 } // namespace protocol |
84 } // namespace remoting | 83 } // namespace remoting |
85 | 84 |
86 #endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ | 85 #endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ |
OLD | NEW |