| OLD | NEW |
| 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 Loading... |
| 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() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 } | 82 } |
| 80 | 83 |
| 81 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts( | 84 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts( |
| 82 std::vector<OriginBoundCertInfo>* origin_bound_certs) { | 85 std::vector<OriginBoundCertInfo>* 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 OriginBoundCertInfo cert_info = { |
| 88 it->second->origin(), | 91 it->second->origin(), |
| 92 it->second->type(), |
| 89 it->second->private_key(), | 93 it->second->private_key(), |
| 90 it->second->cert() | 94 it->second->cert() |
| 91 }; | 95 }; |
| 92 // TODO(rkn): Make changes so we can simply write | 96 // TODO(rkn): Make changes so we can simply write |
| 93 // origin_bound_certs->push_back(*it->second). This is probably best done | 97 // origin_bound_certs->push_back(*it->second). This is probably best done |
| 94 // by unnesting the OriginBoundCert class. | 98 // by unnesting the OriginBoundCert class. |
| 95 origin_bound_certs->push_back(cert_info); | 99 origin_bound_certs->push_back(cert_info); |
| 96 } | 100 } |
| 97 } | 101 } |
| 98 | 102 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 161 |
| 158 if (store_) | 162 if (store_) |
| 159 store_->AddOriginBoundCert(*cert); | 163 store_->AddOriginBoundCert(*cert); |
| 160 origin_bound_certs_[origin] = cert; | 164 origin_bound_certs_[origin] = cert; |
| 161 } | 165 } |
| 162 | 166 |
| 163 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert() {} | 167 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert() {} |
| 164 | 168 |
| 165 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert( | 169 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert( |
| 166 const std::string& origin, | 170 const std::string& origin, |
| 171 SSLClientCertType type, |
| 167 const std::string& private_key, | 172 const std::string& private_key, |
| 168 const std::string& cert) | 173 const std::string& cert) |
| 169 : origin_(origin), | 174 : origin_(origin), |
| 175 type_(type), |
| 170 private_key_(private_key), | 176 private_key_(private_key), |
| 171 cert_(cert) {} | 177 cert_(cert) {} |
| 172 | 178 |
| 173 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {} | 179 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {} |
| 174 | 180 |
| 175 } // namespace net | 181 } // namespace net |
| OLD | NEW |