Compute can_use_lcd_text using property trees.
[chromium-blink-merge.git] / remoting / host / token_validator_base.h
blobc59d15d6ffb73e784fd9cb731a4325d6e1ff33c5
1 // Copyright 2014 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.
5 #ifndef REMOTING_HOST_TOKEN_VALIDATOR_BASE_H_
6 #define REMOTING_HOST_TOKEN_VALIDATOR_BASE_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "net/url_request/url_request.h"
11 #include "net/url_request/url_request_context_getter.h"
12 #include "remoting/host/third_party_auth_config.h"
13 #include "remoting/protocol/token_validator.h"
14 #include "url/gurl.h"
16 namespace net {
17 class ClientCertStore;
18 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList;
21 namespace remoting {
23 class TokenValidatorBase
24 : public net::URLRequest::Delegate,
25 public protocol::TokenValidator {
26 public:
27 TokenValidatorBase(
28 const ThirdPartyAuthConfig& third_party_auth_config,
29 const std::string& token_scope,
30 scoped_refptr<net::URLRequestContextGetter> request_context_getter);
31 ~TokenValidatorBase() override;
33 // TokenValidator interface.
34 void ValidateThirdPartyToken(
35 const std::string& token,
36 const base::Callback<void(const std::string& shared_secret)>&
37 on_token_validated) override;
39 const GURL& token_url() const override;
40 const std::string& token_scope() const override;
42 // URLRequest::Delegate interface.
43 void OnResponseStarted(net::URLRequest* source) override;
44 void OnReadCompleted(net::URLRequest* source, int bytes_read) override;
45 void OnCertificateRequested(
46 net::URLRequest* source,
47 net::SSLCertRequestInfo* cert_request_info) override;
49 protected:
50 void OnCertificatesSelected(net::CertificateList* selected_certs,
51 net::ClientCertStore* unused);
53 virtual void StartValidateRequest(const std::string& token) = 0;
54 virtual bool IsValidScope(const std::string& token_scope);
55 std::string ProcessResponse();
57 // Constructor parameters.
58 ThirdPartyAuthConfig third_party_auth_config_;
59 std::string token_scope_;
60 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
62 // URLRequest related fields.
63 scoped_ptr<net::URLRequest> request_;
64 scoped_refptr<net::IOBuffer> buffer_;
65 std::string data_;
67 base::Callback<void(const std::string& shared_secret)> on_token_validated_;
69 base::WeakPtrFactory<TokenValidatorBase> weak_factory_;
71 DISALLOW_COPY_AND_ASSIGN(TokenValidatorBase);
74 } // namespace remoting
76 #endif // REMOTING_HOST_TOKEN_VALIDATOR_BASE_H