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_ORIGIN_BOUND_CERT_SERVICE_H_ | 5 #ifndef NET_BASE_ORIGIN_BOUND_CERT_SERVICE_H_ |
6 #define NET_BASE_ORIGIN_BOUND_CERT_SERVICE_H_ | 6 #define NET_BASE_ORIGIN_BOUND_CERT_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "net/base/net_api.h" | 13 #include "net/base/net_export.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class OriginBoundCertStore; | 17 class OriginBoundCertStore; |
18 | 18 |
19 // A class for creating and fetching origin bound certs. | 19 // A class for creating and fetching origin bound certs. |
20 class NET_API OriginBoundCertService | 20 class NET_EXPORT OriginBoundCertService |
21 : public base::RefCountedThreadSafe<OriginBoundCertService> { | 21 : public base::RefCountedThreadSafe<OriginBoundCertService> { |
22 public: | 22 public: |
23 // This object owns origin_bound_cert_store. | 23 // This object owns origin_bound_cert_store. |
24 explicit OriginBoundCertService( | 24 explicit OriginBoundCertService( |
25 OriginBoundCertStore* origin_bound_cert_store); | 25 OriginBoundCertStore* origin_bound_cert_store); |
26 | 26 |
27 ~OriginBoundCertService(); | 27 ~OriginBoundCertService(); |
28 | 28 |
29 // TODO(rkn): Specify certificate type (RSA or DSA). | 29 // TODO(rkn): Specify certificate type (RSA or DSA). |
30 // TODO(rkn): Key generation can be time consuming, so this should have an | 30 // TODO(rkn): Key generation can be time consuming, so this should have an |
31 // asynchronous interface. | 31 // asynchronous interface. |
32 // Fetches the origin bound cert for the specified origin if one exists | 32 // Fetches the origin bound cert for the specified origin if one exists |
33 // and creates one otherwise. On success, |private_key_result| stores a | 33 // and creates one otherwise. On success, |private_key_result| stores a |
34 // DER-encoded PrivateKeyInfo struct, and |cert_result| stores a DER-encoded | 34 // DER-encoded PrivateKeyInfo struct, and |cert_result| stores a DER-encoded |
35 // certificate. | 35 // certificate. |
36 bool GetOriginBoundCert(const std::string& origin, | 36 bool GetOriginBoundCert(const std::string& origin, |
37 std::string* private_key_result, | 37 std::string* private_key_result, |
38 std::string* cert_result); | 38 std::string* cert_result); |
39 | 39 |
40 // Public only for unit testing. | 40 // Public only for unit testing. |
41 int GetCertCount(); | 41 int GetCertCount(); |
42 | 42 |
43 private: | 43 private: |
44 scoped_ptr<OriginBoundCertStore> origin_bound_cert_store_; | 44 scoped_ptr<OriginBoundCertStore> origin_bound_cert_store_; |
45 }; | 45 }; |
46 | 46 |
47 } // namespace net | 47 } // namespace net |
48 | 48 |
49 #endif // NET_BASE_ORIGIN_BOUND_CERT_SERVICE_H_ | 49 #endif // NET_BASE_ORIGIN_BOUND_CERT_SERVICE_H_ |
OLD | NEW |