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_SSL_SSL_CLIENT_AUTH_CACHE_H_ | 5 #ifndef NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ |
6 #define NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ | 6 #define NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // The SSLClientAuthCache class is a simple cache structure to store SSL | 21 // The SSLClientAuthCache class is a simple cache structure to store SSL |
22 // client certificates. Provides lookup, insertion, and deletion of entries. | 22 // client certificates. Provides lookup, insertion, and deletion of entries. |
23 // The parameter for doing lookups, insertions, and deletions is the server's | 23 // The parameter for doing lookups, insertions, and deletions is the server's |
24 // host and port. | 24 // host and port. |
25 // | 25 // |
26 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common | 26 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common |
27 // code to a template class. | 27 // code to a template class. |
28 class NET_EXPORT_PRIVATE SSLClientAuthCache : public CertDatabase::Observer { | 28 class NET_EXPORT_PRIVATE SSLClientAuthCache : public CertDatabase::Observer { |
29 public: | 29 public: |
30 SSLClientAuthCache(); | 30 SSLClientAuthCache(); |
31 virtual ~SSLClientAuthCache(); | 31 ~SSLClientAuthCache() override; |
32 | 32 |
33 // Checks for a client certificate preference for SSL server at |server|. | 33 // Checks for a client certificate preference for SSL server at |server|. |
34 // Returns true if a preference is found, and sets |*certificate| to the | 34 // Returns true if a preference is found, and sets |*certificate| to the |
35 // desired client certificate. The desired certificate may be NULL, which | 35 // desired client certificate. The desired certificate may be NULL, which |
36 // indicates a preference to not send any certificate to |server|. | 36 // indicates a preference to not send any certificate to |server|. |
37 // If a certificate preference is not found, returns false. | 37 // If a certificate preference is not found, returns false. |
38 bool Lookup(const HostPortPair& server, | 38 bool Lookup(const HostPortPair& server, |
39 scoped_refptr<X509Certificate>* certificate); | 39 scoped_refptr<X509Certificate>* certificate); |
40 | 40 |
41 // Add a client certificate for |server| to the cache. If there is already | 41 // Add a client certificate for |server| to the cache. If there is already |
42 // a client certificate for |server|, it will be overwritten. A NULL | 42 // a client certificate for |server|, it will be overwritten. A NULL |
43 // |client_cert| indicates a preference that no client certificate should | 43 // |client_cert| indicates a preference that no client certificate should |
44 // be sent to |server|. | 44 // be sent to |server|. |
45 void Add(const HostPortPair& server, X509Certificate* client_cert); | 45 void Add(const HostPortPair& server, X509Certificate* client_cert); |
46 | 46 |
47 // Remove the client certificate for |server| from the cache, if one exists. | 47 // Remove the client certificate for |server| from the cache, if one exists. |
48 void Remove(const HostPortPair& server); | 48 void Remove(const HostPortPair& server); |
49 | 49 |
50 // CertDatabase::Observer methods: | 50 // CertDatabase::Observer methods: |
51 virtual void OnCertAdded(const X509Certificate* cert) override; | 51 void OnCertAdded(const X509Certificate* cert) override; |
52 | 52 |
53 private: | 53 private: |
54 typedef HostPortPair AuthCacheKey; | 54 typedef HostPortPair AuthCacheKey; |
55 typedef scoped_refptr<X509Certificate> AuthCacheValue; | 55 typedef scoped_refptr<X509Certificate> AuthCacheValue; |
56 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; | 56 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; |
57 | 57 |
58 // internal representation of cache, an STL map. | 58 // internal representation of cache, an STL map. |
59 AuthCacheMap cache_; | 59 AuthCacheMap cache_; |
60 }; | 60 }; |
61 | 61 |
62 } // namespace net | 62 } // namespace net |
63 | 63 |
64 #endif // NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ | 64 #endif // NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ |
OLD | NEW |