Index: net/cert/internal/trust_store_static.h |
diff --git a/net/cert/internal/trust_store_static.h b/net/cert/internal/trust_store_static.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8fdb833c241b28bf2ef80d231c9c2e589747b0a2 |
--- /dev/null |
+++ b/net/cert/internal/trust_store_static.h |
@@ -0,0 +1,64 @@ |
+// Copyright 2016 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. |
+ |
+#ifndef NET_CERT_INTERNAL_TRUST_STORE_STATIC_H_ |
+#define NET_CERT_INTERNAL_TRUST_STORE_STATIC_H_ |
+ |
+#include <map> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/strings/string_piece.h" |
+#include "net/base/net_export.h" |
+#include "net/cert/internal/cert_issuer_source_static.h" |
+#include "net/cert/internal/parsed_certificate.h" |
+#include "net/cert/internal/trust_store.h" |
+ |
+namespace net { |
+ |
+namespace der { |
+class Input; |
+} |
+ |
+// A very simple implementation of a TrustStoreStatic, which contains a set of |
+// trusted certificates. |
+class NET_EXPORT TrustStoreStatic : public TrustStore { |
+ public: |
+ TrustStoreStatic(); |
+ ~TrustStoreStatic() override; |
+ |
+ // Adds a trusted certificate to the store. |
+ void AddTrustedCertificate(scoped_refptr<ParsedCertificate> anchor); |
+ |
+ // TrustStore implementation: |
+ void IsTrustedCertificate( |
+ scoped_refptr<ParsedCertificate> cert, |
+ const TrustCallback& callback, |
+ bool* out_trusted, |
+ std::unique_ptr<TrustStore::Request>* out_req) const override; |
+ |
+ // CertIssuerSource implementation: |
+ void SyncGetIssuersOf(const ParsedCertificate* cert, |
+ ParsedCertificateList* issuers) override; |
+ void AsyncGetIssuersOf( |
+ scoped_refptr<ParsedCertificate> cert, |
+ const IssuerCallback& callback, |
+ std::unique_ptr<CertIssuerSource::Request>* out_req) override; |
+ |
+ private: |
+ using Key = std::tuple<base::StringPiece, base::StringPiece>; |
+ |
+ static Key GetKey(const ParsedCertificate* cert); |
+ |
+ // TODO(mattm): use unordered_map. Requires making a hash function for Key. |
+ // Multimap from (normalized subject, SPKI) -> ParsedCertificate. |
+ std::map<Key, scoped_refptr<ParsedCertificate>> anchors_; |
+ |
+ CertIssuerSourceStatic cert_source_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TrustStoreStatic); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_CERT_INTERNAL_TRUST_STORE_STATIC_H_ |