Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: remoting/protocol/third_party_client_authenticator.h

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: REviewer comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "remoting/protocol/third_party_authenticator_base.h"
14
15 class GURL;
16
17 namespace remoting {
18 namespace protocol {
19
20 // Implements the client side of the third party authentication mechanism.
21 // The client authenticator expects a |token_url| and |scope| in the first
22 // message from the host, then calls the |TokenFetcher| asynchronously to
23 // request a |token| and |shared_secret| from that url. If the server requires
24 // interactive authentication, the |TokenFetcher| implementation will show the
25 // appropriate UI. Once the |TokenFetcher| returns, the client sends the |token|
26 // to the host, and uses the |shared_secret| to create an underlying
27 // |V2Authenticator|, which is used to establish the encrypted connection.
28 class ThirdPartyClientAuthenticator : public ThirdPartyAuthenticatorBase {
29 public:
30 class TokenFetcher {
31 public:
32 // Callback passed to |FetchThirdPartyToken|, and called once the client
33 // authentication finishes. |token| is an opaque string that should be sent
34 // directly to the host. |shared_secret| should be used by the client to
35 // create a V2Authenticator. In case of failure, the callback is called with
36 // an empty |token| and |shared_secret|.
37 typedef base::Callback<void(
38 const std::string& token,
39 const std::string& shared_secret)> TokenFetchedCallback;
40
41 virtual ~TokenFetcher() {}
42
43 // 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 // with a space-separated list of attributes for this connection (e.g.
46 // "hostjid:abc@example.com/123 clientjid:def@example.org/456".
47 // |token_fetched_callback| is called when the client authentication ends,
48 // in the same thread |FetchThirdPartyToken| was originally called.
49 // The request is canceled if the TokenFetcher is destroyed.
50 virtual void FetchThirdPartyToken(
51 const GURL& token_url,
52 const std::string& host_public_key,
53 const std::string& scope,
54 const TokenFetchedCallback& token_fetched_callback) = 0;
55 };
56
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.
59 ThirdPartyClientAuthenticator(const std::string& host_public_key,
60 scoped_ptr<TokenFetcher> token_fetcher);
61 virtual ~ThirdPartyClientAuthenticator();
62
63 protected:
64 // ThirdPartyAuthenticator implementation.
65 virtual void ProcessTokenMessage(
66 const buzz::XmlElement* message,
67 const base::Closure& resume_callback) OVERRIDE;
68 virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE;
69
70 private:
71 void OnThirdPartyTokenFetched(const base::Closure& resume_callback,
72 const std::string& third_party_token,
73 const std::string& shared_secret);
74
75 std::string host_public_key_;
76 std::string token_;
77 scoped_ptr<TokenFetcher> token_fetcher_;
78
79 DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator);
80 };
81
82
83 } // namespace protocol
84 } // namespace remoting
85
86 #endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_
OLDNEW
« no previous file with comments | « remoting/protocol/third_party_authenticator_unittest.cc ('k') | remoting/protocol/third_party_client_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698