blob: b7a20c5cfbde79f61d662e9090665bd8d1d5996b [file] [log] [blame]
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_CERT_PKI_CERT_ISSUER_SOURCE_STATIC_H_
#define NET_CERT_PKI_CERT_ISSUER_SOURCE_STATIC_H_
#include <unordered_map>
#include "net/base/net_export.h"
#include "net/cert/pki/cert_issuer_source.h"
namespace net {
// Synchronously returns issuers from a pre-supplied set.
class NET_EXPORT CertIssuerSourceStatic : public CertIssuerSource {
public:
CertIssuerSourceStatic();
CertIssuerSourceStatic(const CertIssuerSourceStatic&) = delete;
CertIssuerSourceStatic& operator=(const CertIssuerSourceStatic&) = delete;
~CertIssuerSourceStatic() override;
// Adds |cert| to the set of certificates that this CertIssuerSource will
// provide.
void AddCert(std::shared_ptr<const ParsedCertificate> cert);
// Clears the set of certificates.
void Clear();
size_t size() const { return intermediates_.size(); }
// CertIssuerSource implementation:
void SyncGetIssuersOf(const ParsedCertificate* cert,
ParsedCertificateList* issuers) override;
void AsyncGetIssuersOf(const ParsedCertificate* cert,
std::unique_ptr<Request>* out_req) override;
private:
// The certificates that the CertIssuerSourceStatic can return, keyed on the
// normalized subject value.
std::unordered_multimap<std::string_view,
std::shared_ptr<const ParsedCertificate>>
intermediates_;
};
} // namespace net
#endif // NET_CERT_PKI_CERT_ISSUER_SOURCE_STATIC_H_