| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2016 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. | 
|  | 4 | 
|  | 5 #ifndef NET_CERT_INTERNAL_TRUST_STORE_STATIC_H_ | 
|  | 6 #define NET_CERT_INTERNAL_TRUST_STORE_STATIC_H_ | 
|  | 7 | 
|  | 8 #include <map> | 
|  | 9 | 
|  | 10 #include "base/memory/ref_counted.h" | 
|  | 11 #include "base/strings/string_piece.h" | 
|  | 12 #include "net/base/net_export.h" | 
|  | 13 #include "net/cert/internal/cert_issuer_source_static.h" | 
|  | 14 #include "net/cert/internal/parsed_certificate.h" | 
|  | 15 #include "net/cert/internal/trust_store.h" | 
|  | 16 | 
|  | 17 namespace net { | 
|  | 18 | 
|  | 19 namespace der { | 
|  | 20 class Input; | 
|  | 21 } | 
|  | 22 | 
|  | 23 // A very simple implementation of a TrustStoreStatic, which contains a set of | 
|  | 24 // trusted certificates. | 
|  | 25 class NET_EXPORT TrustStoreStatic : public TrustStore { | 
|  | 26  public: | 
|  | 27   TrustStoreStatic(); | 
|  | 28   ~TrustStoreStatic() override; | 
|  | 29 | 
|  | 30   // Adds a trusted certificate to the store. | 
|  | 31   void AddTrustedCertificate(scoped_refptr<ParsedCertificate> anchor); | 
|  | 32 | 
|  | 33   // TrustStore implementation: | 
|  | 34   void IsTrustedCertificate( | 
|  | 35       scoped_refptr<ParsedCertificate> cert, | 
|  | 36       const TrustCallback& callback, | 
|  | 37       bool* out_trusted, | 
|  | 38       std::unique_ptr<TrustStore::Request>* out_req) const override; | 
|  | 39 | 
|  | 40   // CertIssuerSource implementation: | 
|  | 41   void SyncGetIssuersOf(const ParsedCertificate* cert, | 
|  | 42                         ParsedCertificateList* issuers) override; | 
|  | 43   void AsyncGetIssuersOf( | 
|  | 44       scoped_refptr<ParsedCertificate> cert, | 
|  | 45       const IssuerCallback& callback, | 
|  | 46       std::unique_ptr<CertIssuerSource::Request>* out_req) override; | 
|  | 47 | 
|  | 48  private: | 
|  | 49   using Key = std::tuple<base::StringPiece, base::StringPiece>; | 
|  | 50 | 
|  | 51   static Key GetKey(const ParsedCertificate* cert); | 
|  | 52 | 
|  | 53   // TODO(mattm): use unordered_map. Requires making a hash function for Key. | 
|  | 54   // Multimap from (normalized subject, SPKI) -> ParsedCertificate. | 
|  | 55   std::map<Key, scoped_refptr<ParsedCertificate>> anchors_; | 
|  | 56 | 
|  | 57   CertIssuerSourceStatic cert_source_; | 
|  | 58 | 
|  | 59   DISALLOW_COPY_AND_ASSIGN(TrustStoreStatic); | 
|  | 60 }; | 
|  | 61 | 
|  | 62 }  // namespace net | 
|  | 63 | 
|  | 64 #endif  // NET_CERT_INTERNAL_TRUST_STORE_STATIC_H_ | 
| OLD | NEW | 
|---|