Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: net/cert/internal/trust_store.cc

Issue 2252933002: Make TrustStore into an interface, move impl to TrustStoreInMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update cast_cert_validator_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cert/internal/trust_store.h ('k') | net/cert/internal/trust_store_in_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/internal/trust_store.h" 5 #include "net/cert/internal/trust_store.h"
6 6
7 #include "base/memory/ptr_util.h"
8
9 namespace net { 7 namespace net {
10 8
11 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateNoConstraints( 9 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateNoConstraints(
12 scoped_refptr<ParsedCertificate> cert) { 10 scoped_refptr<ParsedCertificate> cert) {
13 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), false)); 11 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), false));
14 } 12 }
15 13
16 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateWithConstraints( 14 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateWithConstraints(
17 scoped_refptr<ParsedCertificate> cert) { 15 scoped_refptr<ParsedCertificate> cert) {
18 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), true)); 16 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), true));
(...skipping 10 matching lines...) Expand all
29 const scoped_refptr<ParsedCertificate>& TrustAnchor::cert() const { 27 const scoped_refptr<ParsedCertificate>& TrustAnchor::cert() const {
30 return cert_; 28 return cert_;
31 } 29 }
32 30
33 TrustAnchor::TrustAnchor(scoped_refptr<ParsedCertificate> cert, 31 TrustAnchor::TrustAnchor(scoped_refptr<ParsedCertificate> cert,
34 bool enforces_constraints) 32 bool enforces_constraints)
35 : cert_(std::move(cert)), enforces_constraints_(enforces_constraints) { 33 : cert_(std::move(cert)), enforces_constraints_(enforces_constraints) {
36 DCHECK(cert_); 34 DCHECK(cert_);
37 } 35 }
38 36
39 TrustAnchor::~TrustAnchor() {} 37 TrustAnchor::~TrustAnchor() = default;
40 38
41 TrustStore::TrustStore() {} 39 TrustStore::TrustStore() = default;
42 TrustStore::~TrustStore() {} 40 TrustStore::~TrustStore() = default;
43
44 void TrustStore::Clear() {
45 anchors_.clear();
46 }
47
48 void TrustStore::AddTrustAnchor(scoped_refptr<TrustAnchor> anchor) {
49 // TODO(mattm): should this check for duplicate anchors?
50 anchors_.insert(std::make_pair(anchor->normalized_subject().AsStringPiece(),
51 std::move(anchor)));
52 }
53
54 void TrustStore::FindTrustAnchorsByNormalizedName(
55 const der::Input& normalized_name,
56 TrustAnchors* matches) const {
57 auto range = anchors_.equal_range(normalized_name.AsStringPiece());
58 for (auto it = range.first; it != range.second; ++it)
59 matches->push_back(it->second);
60 }
61 41
62 } // namespace net 42 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/trust_store.h ('k') | net/cert/internal/trust_store_in_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698