Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_NETWORK_SETTINGS_ONC_CERTIFICATE_IMPORTER_H_ | 5 #ifndef CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NETWORK_SETTINGS_ONC_CERTIFICATE_IMPORTER_H_ | 6 #define CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/chromeos/cros/network_ui_data.h" | 14 #include "chromeos/chromeos_export.h" |
| 15 #include "chromeos/network/onc/onc_constants.h" | |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class DictionaryValue; | 18 class DictionaryValue; |
| 18 class ListValue; | 19 class ListValue; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 class X509Certificate; | 23 class X509Certificate; |
| 23 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 24 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace chromeos { | 27 namespace chromeos { |
| 27 namespace onc { | 28 namespace onc { |
| 28 | 29 |
| 30 CHROMEOS_EXPORT extern const char kErrorCertDataMalformed[]; | |
|
pneubeck (no reviews)
2012/12/04 10:43:56
If we want to use the strings as replacements for
Greg Spencer (Chromium)
2012/12/07 18:12:27
We're not returning these anymore.
| |
| 31 CHROMEOS_EXPORT extern const char kErrorCertDataMissing[]; | |
| 32 CHROMEOS_EXPORT extern const char kErrorCertDelete[]; | |
| 33 CHROMEOS_EXPORT extern const char kErrorCertGuidCollision[]; | |
| 34 CHROMEOS_EXPORT extern const char kErrorCertGuidMissing[]; | |
| 35 CHROMEOS_EXPORT extern const char kErrorCertImport[]; | |
| 36 CHROMEOS_EXPORT extern const char kErrorCertTrustInvalid[]; | |
| 37 CHROMEOS_EXPORT extern const char kErrorCertTrustUnknown[]; | |
| 38 CHROMEOS_EXPORT extern const char kErrorCertTypeMissing[]; | |
| 39 CHROMEOS_EXPORT extern const char kErrorUnknown[]; | |
| 40 | |
| 29 // This class handles certificate imports from ONC (both policy and user | 41 // This class handles certificate imports from ONC (both policy and user |
| 30 // imports) into the certificate store. In particular, the GUID of certificates | 42 // imports) into the certificate store. In particular, the GUID of certificates |
| 31 // is stored together with the certificate as Nickname. | 43 // is stored together with the certificate as Nickname. |
| 32 class CertificateImporter { | 44 class CHROMEOS_EXPORT CertificateImporter { |
| 33 public: | 45 public: |
| 46 | |
| 34 // Certificates pushed from a policy source with Web trust are only imported | 47 // Certificates pushed from a policy source with Web trust are only imported |
| 35 // with ParseCertificate() if the |allow_web_trust_from_policy| permission is | 48 // with ParseCertificate() if the |allow_web_trust_from_policy| permission is |
| 36 // granted. | 49 // granted. |
| 37 CertificateImporter(NetworkUIData::ONCSource onc_source, | 50 CertificateImporter(ONCSource onc_source, |
| 38 bool allow_web_trust_from_policy); | 51 bool allow_web_trust_from_policy); |
| 39 | 52 |
| 40 // Parses and stores the certificates in |onc_certificates| into the | 53 // Parses and stores the certificates in |onc_certificates| into the |
| 41 // certificate store. If the "Remove" field of a certificate is enabled, then | 54 // certificate store. If the "Remove" field of a certificate is enabled, then |
| 42 // removes the certificate from the store instead of importing. Returns false | 55 // removes the certificate from the store instead of importing. Returns the |
| 43 // and sets |error| to a user readable message if an error occured. In that | 56 // result of the parse operation. In case of an error, some of the |
| 44 // case, some of the certificates may already be stored/removed. Otherwise, if | 57 // certificates may already be stored/removed. Otherwise, if no error |
| 45 // no error occured, returns true and doesn't modify |error|. | 58 // occurred, returns PARSE_OK. |
| 46 bool ParseAndStoreCertificates(const base::ListValue& onc_certificates, | 59 bool ParseAndStoreCertificates( |
|
pneubeck (no reviews)
2012/12/04 10:43:56
You don't document the return value anymore.
I wo
Greg Spencer (Chromium)
2012/12/07 18:12:27
Fixed this: it now returns an error code, and docu
| |
| 47 std::string* error); | 60 const base::ListValue& onc_certificates, |
| 61 std::string* result); | |
| 48 | 62 |
| 49 // Parses and stores/removes |certificate| in/from the certificate | 63 // Parses and stores/removes |certificate| in/from the certificate |
| 50 // store. Returns false if an error occured. Returns true otherwise. | 64 // store. Returns false if an error occurred. Returns true otherwise. |
| 51 bool ParseAndStoreCertificate(const base::DictionaryValue& certificate); | 65 bool ParseAndStoreCertificate( |
| 66 const base::DictionaryValue& certificate, | |
| 67 std::string* result); | |
| 52 | 68 |
| 53 // Lists the certificates that have the string |label| as their certificate | 69 // Lists the certificates that have the string |label| as their certificate |
| 54 // nickname (exact match). | 70 // nickname (exact match). |
| 55 static void ListCertsWithNickname(const std::string& label, | 71 static void ListCertsWithNickname(const std::string& label, |
| 56 net::CertificateList* result); | 72 net::CertificateList* result); |
| 57 | 73 |
| 58 protected: | 74 protected: |
| 59 // Deletes any certificate that has the string |label| as its nickname (exact | 75 // Deletes any certificate that has the string |label| as its nickname (exact |
| 60 // match). | 76 // match). |
| 61 static bool DeleteCertAndKeyByNickname(const std::string& label); | 77 static bool DeleteCertAndKeyByNickname(const std::string& label); |
| 62 | 78 |
| 63 private: | 79 private: |
| 64 bool ParseServerOrCaCertificate( | 80 bool ParseServerOrCaCertificate( |
| 65 const std::string& cert_type, | 81 const std::string& cert_type, |
| 66 const std::string& guid, | 82 const std::string& guid, |
| 67 const base::DictionaryValue& certificate); | 83 const base::DictionaryValue& certificate, |
| 84 std::string* result); | |
| 68 bool ParseClientCertificate( | 85 bool ParseClientCertificate( |
|
pneubeck (no reviews)
2012/12/04 10:43:56
nit: add an empty line
Greg Spencer (Chromium)
2012/12/07 18:12:27
Done.
| |
| 69 const std::string& guid, | 86 const std::string& guid, |
| 70 const base::DictionaryValue& certificate); | 87 const base::DictionaryValue& certificate, |
| 88 std::string* result); | |
| 71 | 89 |
| 72 // Where the ONC blob comes from. | 90 // Where the ONC blob comes from. |
| 73 NetworkUIData::ONCSource onc_source_; | 91 ONCSource onc_source_; |
| 74 | 92 |
| 75 // Whether certificates with Web trust should be stored when pushed from a | 93 // Whether certificates with Web trust should be stored when pushed from a |
| 76 // policy source. | 94 // policy source. |
| 77 bool allow_web_trust_from_policy_; | 95 bool allow_web_trust_from_policy_; |
| 78 | 96 |
| 79 std::string error_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(CertificateImporter); | 97 DISALLOW_COPY_AND_ASSIGN(CertificateImporter); |
| 82 }; | 98 }; |
| 83 | 99 |
| 84 } // chromeos | 100 } // chromeos |
| 85 } // onc | 101 } // onc |
| 86 | 102 |
| 87 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_SETTINGS_ONC_CERTIFICATE_IMPORTER_H_ | 103 #endif // CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_H_ |
| OLD | NEW |