blob: aa8deb94ff2e4f921923d0934cf36cb7d28a544d [file] [log] [blame]
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <list>
#include <map>
#include <string>
#include "base/macros.h"
#include "chromeos/attestation/attestation_flow.h"
#include "chromeos/dbus/constants/attestation_constants.h"
namespace network {
class SimpleURLLoader;
namespace mojom {
class NetworkContext;
} // namespace mojom
} // namespace network
namespace ash {
namespace attestation {
// This class is a ServerProxy implementation for the Chrome OS attestation
// flow. It sends all requests to an Attestation CA via HTTPS.
class AttestationCAClient : public ServerProxy {
~AttestationCAClient() override;
// chromeos::attestation::ServerProxy:
void SendEnrollRequest(const std::string& request,
DataCallback on_response) override;
void SendCertificateRequest(const std::string& request,
DataCallback on_response) override;
void OnURLLoadComplete(
std::list<std::unique_ptr<network::SimpleURLLoader>>::iterator it,
DataCallback on_response,
std::unique_ptr<std::string> response_body);
PrivacyCAType GetType() override;
void CheckIfAnyProxyPresent(ProxyPresenceCallback callback) override;
void set_network_context_for_testing(
network::mojom::NetworkContext* network_context) {
network_context_for_testing_ = network_context;
PrivacyCAType pca_type_;
// POSTs |request| data to |url| and calls |on_response| with the response
// data when the fetch is complete.
void FetchURL(const std::string& url,
const std::string& request,
DataCallback on_response);
// Loaders used for the processing the requests. Invalidated after completion.
std::list<std::unique_ptr<network::SimpleURLLoader>> url_loaders_;
network::mojom::NetworkContext* network_context_for_testing_ = nullptr;
} // namespace attestation
} // namespace ash