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

Side by Side Diff: net/base/default_origin_bound_cert_store.cc

Issue 8662036: Support EC certs in OriginBoundCertService and OriginBoundCertStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/default_origin_bound_cert_store.h" 5 #include "net/base/default_origin_bound_cert_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 11 matching lines...) Expand all
22 base::AutoLock autolock(lock_); 22 base::AutoLock autolock(lock_);
23 23
24 if (initialized_ && store_) 24 if (initialized_ && store_)
25 store_->Flush(completion_task); 25 store_->Flush(completion_task);
26 else if (!completion_task.is_null()) 26 else if (!completion_task.is_null())
27 MessageLoop::current()->PostTask(FROM_HERE, completion_task); 27 MessageLoop::current()->PostTask(FROM_HERE, completion_task);
28 } 28 }
29 29
30 bool DefaultOriginBoundCertStore::GetOriginBoundCert( 30 bool DefaultOriginBoundCertStore::GetOriginBoundCert(
31 const std::string& origin, 31 const std::string& origin,
32 SSLClientCertType* type,
32 std::string* private_key_result, 33 std::string* private_key_result,
33 std::string* cert_result) { 34 std::string* cert_result) {
34 base::AutoLock autolock(lock_); 35 base::AutoLock autolock(lock_);
35 InitIfNecessary(); 36 InitIfNecessary();
36 37
37 OriginBoundCertMap::iterator it = origin_bound_certs_.find(origin); 38 OriginBoundCertMap::iterator it = origin_bound_certs_.find(origin);
38 39
39 if (it == origin_bound_certs_.end()) 40 if (it == origin_bound_certs_.end())
40 return false; 41 return false;
41 42
42 OriginBoundCert* cert = it->second; 43 OriginBoundCert* cert = it->second;
44 *type = cert->type();
43 *private_key_result = cert->private_key(); 45 *private_key_result = cert->private_key();
44 *cert_result = cert->cert(); 46 *cert_result = cert->cert();
45 47
46 return true; 48 return true;
47 } 49 }
48 50
49 void DefaultOriginBoundCertStore::SetOriginBoundCert( 51 void DefaultOriginBoundCertStore::SetOriginBoundCert(
50 const std::string& origin, 52 const std::string& origin,
53 SSLClientCertType type,
51 const std::string& private_key, 54 const std::string& private_key,
52 const std::string& cert) { 55 const std::string& cert) {
53 base::AutoLock autolock(lock_); 56 base::AutoLock autolock(lock_);
54 InitIfNecessary(); 57 InitIfNecessary();
55 58
56 InternalDeleteOriginBoundCert(origin); 59 InternalDeleteOriginBoundCert(origin);
57 InternalInsertOriginBoundCert(origin, 60 InternalInsertOriginBoundCert(
58 new OriginBoundCert(origin, private_key, cert)); 61 origin, new OriginBoundCert(origin, type, private_key, cert));
59 } 62 }
60 63
61 void DefaultOriginBoundCertStore::DeleteOriginBoundCert( 64 void DefaultOriginBoundCertStore::DeleteOriginBoundCert(
62 const std::string& origin) { 65 const std::string& origin) {
63 base::AutoLock autolock(lock_); 66 base::AutoLock autolock(lock_);
64 InitIfNecessary(); 67 InitIfNecessary();
65 InternalDeleteOriginBoundCert(origin); 68 InternalDeleteOriginBoundCert(origin);
66 } 69 }
67 70
68 void DefaultOriginBoundCertStore::DeleteAll() { 71 void DefaultOriginBoundCertStore::DeleteAll() {
69 base::AutoLock autolock(lock_); 72 base::AutoLock autolock(lock_);
70 InitIfNecessary(); 73 InitIfNecessary();
71 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); 74 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin();
72 it != origin_bound_certs_.end(); ++it) { 75 it != origin_bound_certs_.end(); ++it) {
73 OriginBoundCert* cert = it->second; 76 OriginBoundCert* cert = it->second;
74 if (store_) 77 if (store_)
75 store_->DeleteOriginBoundCert(*cert); 78 store_->DeleteOriginBoundCert(*cert);
76 delete cert; 79 delete cert;
77 } 80 }
78 origin_bound_certs_.clear(); 81 origin_bound_certs_.clear();
79 } 82 }
80 83
81 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts( 84 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts(
82 std::vector<OriginBoundCertInfo>* origin_bound_certs) { 85 std::vector<OriginBoundCert>* origin_bound_certs) {
83 base::AutoLock autolock(lock_); 86 base::AutoLock autolock(lock_);
84 InitIfNecessary(); 87 InitIfNecessary();
85 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); 88 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin();
86 it != origin_bound_certs_.end(); ++it) { 89 it != origin_bound_certs_.end(); ++it) {
87 OriginBoundCertInfo cert_info = { 90 origin_bound_certs->push_back(*it->second);
88 it->second->origin(),
89 it->second->private_key(),
90 it->second->cert()
91 };
92 // TODO(rkn): Make changes so we can simply write
93 // origin_bound_certs->push_back(*it->second). This is probably best done
94 // by unnesting the OriginBoundCert class.
95 origin_bound_certs->push_back(cert_info);
96 } 91 }
97 } 92 }
98 93
99 int DefaultOriginBoundCertStore::GetCertCount() { 94 int DefaultOriginBoundCertStore::GetCertCount() {
100 base::AutoLock autolock(lock_); 95 base::AutoLock autolock(lock_);
101 InitIfNecessary(); 96 InitIfNecessary();
102 97
103 return origin_bound_certs_.size(); 98 return origin_bound_certs_.size();
104 } 99 }
105 100
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void DefaultOriginBoundCertStore::InternalInsertOriginBoundCert( 148 void DefaultOriginBoundCertStore::InternalInsertOriginBoundCert(
154 const std::string& origin, 149 const std::string& origin,
155 OriginBoundCert* cert) { 150 OriginBoundCert* cert) {
156 lock_.AssertAcquired(); 151 lock_.AssertAcquired();
157 152
158 if (store_) 153 if (store_)
159 store_->AddOriginBoundCert(*cert); 154 store_->AddOriginBoundCert(*cert);
160 origin_bound_certs_[origin] = cert; 155 origin_bound_certs_[origin] = cert;
161 } 156 }
162 157
163 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert() {}
164
165 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert(
166 const std::string& origin,
167 const std::string& private_key,
168 const std::string& cert)
169 : origin_(origin),
170 private_key_(private_key),
171 cert_(cert) {}
172
173 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {} 158 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {}
174 159
175 } // namespace net 160 } // namespace net
OLDNEW
« no previous file with comments | « net/base/default_origin_bound_cert_store.h ('k') | net/base/default_origin_bound_cert_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698