• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
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 NET_CERT_PKI_CERT_ISSUER_SOURCE_STATIC_H_
6 #define NET_CERT_PKI_CERT_ISSUER_SOURCE_STATIC_H_
7 
8 #include <unordered_map>
9 
10 #include "net/base/net_export.h"
11 #include "net/cert/pki/cert_issuer_source.h"
12 
13 namespace net {
14 
15 // Synchronously returns issuers from a pre-supplied set.
16 class NET_EXPORT CertIssuerSourceStatic : public CertIssuerSource {
17  public:
18   CertIssuerSourceStatic();
19 
20   CertIssuerSourceStatic(const CertIssuerSourceStatic&) = delete;
21   CertIssuerSourceStatic& operator=(const CertIssuerSourceStatic&) = delete;
22 
23   ~CertIssuerSourceStatic() override;
24 
25   // Adds |cert| to the set of certificates that this CertIssuerSource will
26   // provide.
27   void AddCert(std::shared_ptr<const ParsedCertificate> cert);
28 
29   // Clears the set of certificates.
30   void Clear();
31 
size()32   size_t size() const { return intermediates_.size(); }
33 
34   // CertIssuerSource implementation:
35   void SyncGetIssuersOf(const ParsedCertificate* cert,
36                         ParsedCertificateList* issuers) override;
37   void AsyncGetIssuersOf(const ParsedCertificate* cert,
38                          std::unique_ptr<Request>* out_req) override;
39 
40  private:
41   // The certificates that the CertIssuerSourceStatic can return, keyed on the
42   // normalized subject value.
43   std::unordered_multimap<std::string_view,
44                           std::shared_ptr<const ParsedCertificate>>
45       intermediates_;
46 };
47 
48 }  // namespace net
49 
50 #endif  // NET_CERT_PKI_CERT_ISSUER_SOURCE_STATIC_H_
51