| 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 #ifndef NET_BASE_DEFAULT_ORIGIN_BOUND_CERT_STORE_H_ | 5 #ifndef NET_BASE_DEFAULT_ORIGIN_BOUND_CERT_STORE_H_ |
| 6 #define NET_BASE_DEFAULT_ORIGIN_BOUND_CERT_STORE_H_ | 6 #define NET_BASE_DEFAULT_ORIGIN_BOUND_CERT_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "net/base/net_api.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/base/origin_bound_cert_store.h" | 17 #include "net/base/origin_bound_cert_store.h" |
| 18 | 18 |
| 19 class Task; | 19 class Task; |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 // This class is the system for storing and retrieving origin bound certs. | 23 // This class is the system for storing and retrieving origin bound certs. |
| 24 // Modelled after the CookieMonster class, it has an in-memory cert store, | 24 // Modelled after the CookieMonster class, it has an in-memory cert store, |
| 25 // and synchronizes origin bound certs to an optional permanent storage that | 25 // and synchronizes origin bound certs to an optional permanent storage that |
| 26 // implements the PersistentStore interface. The use case is described in | 26 // implements the PersistentStore interface. The use case is described in |
| 27 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html | 27 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html |
| 28 // | 28 // |
| 29 // This class can be accessed by multiple threads. For example, it can be used | 29 // This class can be accessed by multiple threads. For example, it can be used |
| 30 // by IO and origin bound cert management UI. | 30 // by IO and origin bound cert management UI. |
| 31 class NET_API DefaultOriginBoundCertStore : public OriginBoundCertStore { | 31 class NET_EXPORT DefaultOriginBoundCertStore : public OriginBoundCertStore { |
| 32 public: | 32 public: |
| 33 class OriginBoundCert; | 33 class OriginBoundCert; |
| 34 class PersistentStore; | 34 class PersistentStore; |
| 35 | 35 |
| 36 // The key for each OriginBoundCert* in OriginBoundCertMap is the | 36 // The key for each OriginBoundCert* in OriginBoundCertMap is the |
| 37 // corresponding origin. | 37 // corresponding origin. |
| 38 typedef std::map<std::string, OriginBoundCert*> OriginBoundCertMap; | 38 typedef std::map<std::string, OriginBoundCert*> OriginBoundCertMap; |
| 39 | 39 |
| 40 // The store passed in should not have had Init() called on it yet. This | 40 // The store passed in should not have had Init() called on it yet. This |
| 41 // class will take care of initializing it. The backing store is NOT owned by | 41 // class will take care of initializing it. The backing store is NOT owned by |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 OriginBoundCertMap origin_bound_certs_; | 103 OriginBoundCertMap origin_bound_certs_; |
| 104 | 104 |
| 105 // Lock for thread-safety | 105 // Lock for thread-safety |
| 106 base::Lock lock_; | 106 base::Lock lock_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(DefaultOriginBoundCertStore); | 108 DISALLOW_COPY_AND_ASSIGN(DefaultOriginBoundCertStore); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 // The OriginBoundCert class contains a private key in addition to the origin | 111 // The OriginBoundCert class contains a private key in addition to the origin |
| 112 // and the cert. | 112 // and the cert. |
| 113 class NET_API DefaultOriginBoundCertStore::OriginBoundCert { | 113 class NET_EXPORT DefaultOriginBoundCertStore::OriginBoundCert { |
| 114 public: | 114 public: |
| 115 OriginBoundCert(); | 115 OriginBoundCert(); |
| 116 OriginBoundCert(const std::string& origin, | 116 OriginBoundCert(const std::string& origin, |
| 117 const std::string& privatekey, | 117 const std::string& privatekey, |
| 118 const std::string& cert); | 118 const std::string& cert); |
| 119 | 119 |
| 120 const std::string& origin() const { return origin_; } | 120 const std::string& origin() const { return origin_; } |
| 121 const std::string& private_key() const { return private_key_; } | 121 const std::string& private_key() const { return private_key_; } |
| 122 const std::string& cert() const { return cert_; } | 122 const std::string& cert() const { return cert_; } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 std::string origin_; | 125 std::string origin_; |
| 126 std::string private_key_; | 126 std::string private_key_; |
| 127 std::string cert_; | 127 std::string cert_; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 typedef base::RefCountedThreadSafe<DefaultOriginBoundCertStore::PersistentStore> | 130 typedef base::RefCountedThreadSafe<DefaultOriginBoundCertStore::PersistentStore> |
| 131 RefcountedPersistentStore; | 131 RefcountedPersistentStore; |
| 132 | 132 |
| 133 class NET_API DefaultOriginBoundCertStore::PersistentStore | 133 class NET_EXPORT DefaultOriginBoundCertStore::PersistentStore |
| 134 : public RefcountedPersistentStore { | 134 : public RefcountedPersistentStore { |
| 135 public: | 135 public: |
| 136 virtual ~PersistentStore() {} | 136 virtual ~PersistentStore() {} |
| 137 | 137 |
| 138 // Initializes the store and retrieves the existing certs. This will be | 138 // Initializes the store and retrieves the existing certs. This will be |
| 139 // called only once at startup. Note that the certs are individually allocated | 139 // called only once at startup. Note that the certs are individually allocated |
| 140 // and that ownership is transferred to the caller upon return. | 140 // and that ownership is transferred to the caller upon return. |
| 141 virtual bool Load( | 141 virtual bool Load( |
| 142 std::vector<DefaultOriginBoundCertStore::OriginBoundCert*>* certs) = 0; | 142 std::vector<DefaultOriginBoundCertStore::OriginBoundCert*>* certs) = 0; |
| 143 | 143 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 155 protected: | 155 protected: |
| 156 PersistentStore(); | 156 PersistentStore(); |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 DISALLOW_COPY_AND_ASSIGN(PersistentStore); | 159 DISALLOW_COPY_AND_ASSIGN(PersistentStore); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 } // namespace net | 162 } // namespace net |
| 163 | 163 |
| 164 #endif // NET_DEFAULT_ORIGIN_BOUND_CERT_STORE_H_ | 164 #endif // NET_DEFAULT_ORIGIN_BOUND_CERT_STORE_H_ |
| OLD | NEW |