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_CLIENT_AUTHENTICATOR_H_ | |
6 #define REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "googleurl/src/gurl.h" | |
Sergey Ulanov
2013/03/20 07:24:12
Can forward-declare GURL
rmsousa
2013/03/21 01:23:25
Done.
| |
14 #include "remoting/protocol/third_party_authenticator_base.h" | |
15 | |
16 namespace remoting { | |
17 namespace protocol { | |
18 | |
19 // Callback passed to |FetchTokenCallback|, and called once the client | |
20 // authentication finishes. |token| is an opaque string that should be sent | |
21 // directly to the host. |shared_secret| should be used by the client to | |
22 // create a V2Authenticator. In case of failure, the callback is called with | |
23 // an empty |token| and |shared_secret|. | |
24 typedef base::Callback<void( | |
25 const std::string& token, | |
26 const std::string& shared_secret)> TokenFetchedCallback; | |
27 | |
28 // Fetches a third party token from |token_url|. |host_public_key| is sent | |
29 // to the server so it can later authenticate the host. |scope| is a string | |
30 // with a space-separated list of attributes for this connection (e.g. | |
31 // "hostjid:abc@example.com/123 clientjid:def@example.org/456". | |
32 // |token_fetched_callback| is called when the client authentication ends, | |
33 // in the same thread |FetchTokenCallback| was originally called. | |
34 typedef base::Callback<void( | |
35 const GURL& token_url, | |
36 const std::string& host_public_key, | |
37 const std::string& scope, | |
38 const TokenFetchedCallback& token_fetched_callback)> FetchTokenCallback; | |
Sergey Ulanov
2013/03/20 07:24:12
The fetcher will be fetching information from remo
rmsousa
2013/03/21 01:23:25
The way it works, it's not really cancellable in t
| |
39 | |
40 // Implements an authentication method that relies on a third party server for | |
41 // authentication of both client and host. | |
42 // When third party authentication is being used, the client must request both a | |
43 // token and a shared secret from a third-party server (which may require the | |
44 // user to authenticate themselves). The client then sends only the token to the | |
45 // host. The host signs the token, then contacts the third-party server to | |
46 // exchange the token for the shared secret. Once both client and host have the | |
47 // shared secret, they use an underlying |V2Authenticator| (SPAKE2) to negotiate | |
48 // an authentication key, which is used to establish the connection. | |
49 class ThirdPartyClientAuthenticator : public ThirdPartyAuthenticatorBase { | |
50 public: | |
51 // Creates a third-party client authenticator, for the host with the given | |
52 // |host_public_key|. | |
53 ThirdPartyClientAuthenticator(const std::string& host_public_key, | |
54 const FetchTokenCallback& fetch_token_callback); | |
55 virtual ~ThirdPartyClientAuthenticator(); | |
56 | |
57 protected: | |
58 // ThirdPartyAuthenticator implementation. | |
59 virtual void ProcessTokenMessage( | |
60 const buzz::XmlElement* message, | |
61 const base::Closure& resume_callback) OVERRIDE; | |
62 virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE; | |
63 | |
64 private: | |
65 void OnThirdPartyTokenFetched(const base::Closure& resume_callback, | |
66 const std::string& third_party_token, | |
67 const std::string& shared_secret); | |
68 | |
69 std::string host_public_key_; | |
70 std::string token_; | |
71 FetchTokenCallback fetch_token_callback_; | |
72 | |
73 base::WeakPtrFactory<ThirdPartyClientAuthenticator> weak_factory_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator); | |
76 }; | |
77 | |
78 | |
79 } // namespace protocol | |
80 } // namespace remoting | |
81 | |
82 #endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_ | |
OLD | NEW |