| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_IMPL_H_ | 5 #ifndef CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_IMPL_H_ |
| 6 #define CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_IMPL_H_ | 6 #define CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chromeos/chromeos_export.h" | 16 #include "chromeos/chromeos_export.h" |
| 17 #include "chromeos/network/onc/onc_certificate_importer.h" | 17 #include "chromeos/network/onc/onc_certificate_importer.h" |
| 18 #include "components/onc/onc_constants.h" | 18 #include "components/onc/onc_constants.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class DictionaryValue; | 21 class DictionaryValue; |
| 22 class ListValue; | 22 class ListValue; |
| 23 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
| 24 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace cert_database { |
| 28 class CertDatabaseServiceIOPart; |
| 29 } |
| 30 |
| 27 namespace net { | 31 namespace net { |
| 28 class NSSCertDatabase; | 32 class NSSCertDatabase; |
| 29 class X509Certificate; | 33 class X509Certificate; |
| 30 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 34 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 31 } | 35 } |
| 32 | 36 |
| 33 namespace chromeos { | 37 namespace chromeos { |
| 34 namespace onc { | 38 namespace onc { |
| 35 | 39 |
| 36 // This class handles certificate imports from ONC (both policy and user | 40 // This class handles certificate imports from ONC (both policy and user |
| 37 // imports) into a certificate store. The GUID of Client certificates is stored | 41 // imports) into a certificate store. The GUID of Client certificates is stored |
| 38 // together with the certificate as Nickname. In contrast, Server and CA | 42 // together with the certificate as Nickname. In contrast, Server and CA |
| 39 // certificates are identified by their PEM and not by GUID. | 43 // certificates are identified by their PEM and not by GUID. |
| 40 // TODO(pneubeck): Replace Nickname by PEM for Client | 44 // TODO(pneubeck): Replace Nickname by PEM for Client |
| 41 // certificates. http://crbug.com/252119 | 45 // certificates. http://crbug.com/252119 |
| 42 class CHROMEOS_EXPORT CertificateImporterImpl : public CertificateImporter { | 46 class CHROMEOS_EXPORT CertificateImporterImpl : public CertificateImporter { |
| 43 public: | 47 public: |
| 44 // |io_task_runner| will be used for NSSCertDatabase accesses. | 48 // |io_task_runner| will be used for NSSCertDatabase accesses. |
| 45 CertificateImporterImpl( | 49 CertificateImporterImpl( |
| 46 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 50 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
| 47 net::NSSCertDatabase* target_nssdb_); | 51 const base::WeakPtr<cert_database::CertDatabaseServiceIOPart>& |
| 52 cert_db_io); |
| 48 virtual ~CertificateImporterImpl(); | 53 virtual ~CertificateImporterImpl(); |
| 49 | 54 |
| 50 // CertificateImporter overrides | 55 // CertificateImporter overrides |
| 51 virtual void ImportCertificates(const base::ListValue& certificates, | 56 virtual void ImportCertificates(const base::ListValue& certificates, |
| 52 ::onc::ONCSource source, | 57 ::onc::ONCSource source, |
| 53 const DoneCallback& done_callback) override; | 58 const DoneCallback& done_callback) override; |
| 54 | 59 |
| 55 private: | 60 private: |
| 56 void RunDoneCallback(const CertificateImporter::DoneCallback& callback, | 61 void RunDoneCallback(const CertificateImporter::DoneCallback& callback, |
| 57 bool success, | 62 bool success, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 net::CertificateList* onc_trusted_certificates); | 101 net::CertificateList* onc_trusted_certificates); |
| 97 | 102 |
| 98 static bool ParseClientCertificate(const std::string& guid, | 103 static bool ParseClientCertificate(const std::string& guid, |
| 99 const base::DictionaryValue& certificate, | 104 const base::DictionaryValue& certificate, |
| 100 net::NSSCertDatabase* nssdb); | 105 net::NSSCertDatabase* nssdb); |
| 101 | 106 |
| 102 // The task runner to use for NSSCertDatabase accesses. | 107 // The task runner to use for NSSCertDatabase accesses. |
| 103 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | 108 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
| 104 | 109 |
| 105 // The certificate database to which certificates are imported. | 110 // The certificate database to which certificates are imported. |
| 106 net::NSSCertDatabase* target_nssdb_; | 111 base::WeakPtr<cert_database::CertDatabaseServiceIOPart> cert_db_io_; |
| 107 | 112 |
| 108 base::WeakPtrFactory<CertificateImporterImpl> weak_factory_; | 113 base::WeakPtrFactory<CertificateImporterImpl> weak_factory_; |
| 109 | 114 |
| 110 DISALLOW_COPY_AND_ASSIGN(CertificateImporterImpl); | 115 DISALLOW_COPY_AND_ASSIGN(CertificateImporterImpl); |
| 111 }; | 116 }; |
| 112 | 117 |
| 113 } // namespace onc | 118 } // namespace onc |
| 114 } // namespace chromeos | 119 } // namespace chromeos |
| 115 | 120 |
| 116 #endif // CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_IMPL_H_ | 121 #endif // CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_IMPL_H_ |
| OLD | NEW |