blob: fa8b883d1bcbaf069d0a1fb60e76151b760568d6 [file] [log] [blame]
[email protected]9a6361d02013-03-23 16:27:521// 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"
avi5a080f012015-12-22 23:15:4311#include "base/macros.h"
[email protected]9a6361d02013-03-23 16:27:5212#include "base/memory/scoped_ptr.h"
13#include "base/memory/weak_ptr.h"
sergeyu64adc272016-03-12 09:12:4314#include "remoting/protocol/client_authentication_config.h"
[email protected]9a6361d02013-03-23 16:27:5215#include "remoting/protocol/third_party_authenticator_base.h"
[email protected]9a6361d02013-03-23 16:27:5216
17namespace remoting {
18namespace 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.
28class ThirdPartyClientAuthenticator : public ThirdPartyAuthenticatorBase {
29 public:
sergeyu12e320a2016-03-08 18:10:2830 // Creates a third-party client authenticator.
31 // |create_base_authenticator_callback| is used to create the base
32 // authenticator. |token_fetcher| is used to get the authentication token.
33 ThirdPartyClientAuthenticator(
34 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback,
sergeyu1acf67ba2016-03-10 02:59:1435 const FetchThirdPartyTokenCallback& fetch_token_callback);
dcheng562aba52014-10-21 12:30:1436 ~ThirdPartyClientAuthenticator() override;
[email protected]9a6361d02013-03-23 16:27:5237
38 protected:
39 // ThirdPartyAuthenticator implementation.
dcheng562aba52014-10-21 12:30:1440 void ProcessTokenMessage(const buzz::XmlElement* message,
41 const base::Closure& resume_callback) override;
42 void AddTokenElements(buzz::XmlElement* message) override;
[email protected]9a6361d02013-03-23 16:27:5243
44 private:
45 void OnThirdPartyTokenFetched(const base::Closure& resume_callback,
46 const std::string& third_party_token,
47 const std::string& shared_secret);
48
sergeyu12e320a2016-03-08 18:10:2849 CreateBaseAuthenticatorCallback create_base_authenticator_callback_;
sergeyu1acf67ba2016-03-10 02:59:1450 FetchThirdPartyTokenCallback fetch_token_callback_;
sergeyu12e320a2016-03-08 18:10:2851 std::string token_;
[email protected]9a6361d02013-03-23 16:27:5252
sergeyu1acf67ba2016-03-10 02:59:1453 base::WeakPtrFactory<ThirdPartyClientAuthenticator> weak_factory_;
54
[email protected]9a6361d02013-03-23 16:27:5255 DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator);
56};
57
58
59} // namespace protocol
60} // namespace remoting
61
62#endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_