| 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 CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.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 "base/observer_list.h" |
| 14 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 15 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" |
| 15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 16 | 17 |
| 17 namespace chromeos { | 18 namespace chromeos { |
| 18 class User; | 19 class User; |
| 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 policy { | 27 namespace policy { |
| 27 | 28 |
| 28 class PolicyCertVerifier; | |
| 29 class PolicyService; | 29 class PolicyService; |
| 30 | 30 |
| 31 // Implements additional special handling of ONC user policies. Namely string | 31 // Implements additional special handling of ONC user policies. Namely string |
| 32 // expansion with the user's name (or email address, etc.) and handling of "Web" | 32 // expansion with the user's name (or email address, etc.) and handling of "Web" |
| 33 // trust of certificates. Web trusted certificates are pushed to the | 33 // trust of certificates. |
| 34 // PolicyCertVerifier if set. | |
| 35 class UserNetworkConfigurationUpdater : public NetworkConfigurationUpdater, | 34 class UserNetworkConfigurationUpdater : public NetworkConfigurationUpdater, |
| 36 public BrowserContextKeyedService { | 35 public BrowserContextKeyedService { |
| 37 public: | 36 public: |
| 37 class WebTrustedCertsObserver { |
| 38 public: |
| 39 // Is called everytime the list of imported certificates with Web trust is |
| 40 // changed. |
| 41 virtual void OnTrustAnchorsChanged( |
| 42 const net::CertificateList& trust_anchors) = 0; |
| 43 }; |
| 44 |
| 38 virtual ~UserNetworkConfigurationUpdater(); | 45 virtual ~UserNetworkConfigurationUpdater(); |
| 39 | 46 |
| 40 // Creates an updater that applies the ONC user policy from |policy_service| | 47 // Creates an updater that applies the ONC user policy from |policy_service| |
| 41 // for user |user| once the policy service is completely initialized and on | 48 // for user |user| once the policy service is completely initialized and on |
| 42 // each policy change. Imported certificates, that request it, are only | 49 // each policy change. Imported certificates, that request it, are only |
| 43 // granted Web trust if |allow_trusted_certs_from_policy| is true. A reference | 50 // granted Web trust if |allow_trusted_certs_from_policy| is true. A reference |
| 44 // to |user| is stored. It must outlive the returned updater. | 51 // to |user| is stored. It must outlive the returned updater. |
| 45 static scoped_ptr<UserNetworkConfigurationUpdater> CreateForUserPolicy( | 52 static scoped_ptr<UserNetworkConfigurationUpdater> CreateForUserPolicy( |
| 46 bool allow_trusted_certs_from_policy, | 53 bool allow_trusted_certs_from_policy, |
| 47 const chromeos::User& user, | 54 const chromeos::User& user, |
| 48 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, | 55 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, |
| 49 PolicyService* policy_service, | 56 PolicyService* policy_service, |
| 50 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); | 57 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); |
| 51 | 58 |
| 52 // Sets the CertVerifier on which the current list of Web trusted server and | 59 void AddTrustedCertsObserver(WebTrustedCertsObserver* observer); |
| 53 // CA certificates will be set. Policy updates will trigger further calls to | 60 void RemoveTrustedCertsObserver(WebTrustedCertsObserver* observer); |
| 54 // |cert_verifier| later. |cert_verifier| must be valid until | |
| 55 // SetPolicyCertVerifier is called again (with another CertVerifier or NULL) | |
| 56 // or until this Updater is destructed. |cert_verifier|'s methods are only | |
| 57 // called on the IO thread. This function must be called on the UI thread. | |
| 58 void SetPolicyCertVerifier(PolicyCertVerifier* cert_verifier); | |
| 59 | 61 |
| 60 // Sets |certs| to the list of Web trusted server and CA certificates from the | 62 // Sets |certs| to the list of Web trusted server and CA certificates from the |
| 61 // last received policy. | 63 // last received policy. |
| 62 void GetWebTrustedCertificates(net::CertificateList* certs) const; | 64 void GetWebTrustedCertificates(net::CertificateList* certs) const; |
| 63 | 65 |
| 64 private: | 66 private: |
| 65 class CrosTrustAnchorProvider; | 67 class CrosTrustAnchorProvider; |
| 66 | 68 |
| 67 UserNetworkConfigurationUpdater( | 69 UserNetworkConfigurationUpdater( |
| 68 bool allow_trusted_certs_from_policy, | 70 bool allow_trusted_certs_from_policy, |
| 69 const chromeos::User& user, | 71 const chromeos::User& user, |
| 70 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, | 72 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, |
| 71 PolicyService* policy_service, | 73 PolicyService* policy_service, |
| 72 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); | 74 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); |
| 73 | 75 |
| 74 virtual void ImportCertificates( | 76 virtual void ImportCertificates( |
| 75 const base::ListValue& certificates_onc) OVERRIDE; | 77 const base::ListValue& certificates_onc) OVERRIDE; |
| 76 | 78 |
| 77 virtual void ApplyNetworkPolicy( | 79 virtual void ApplyNetworkPolicy( |
| 78 base::ListValue* network_configs_onc, | 80 base::ListValue* network_configs_onc, |
| 79 base::DictionaryValue* global_network_config) OVERRIDE; | 81 base::DictionaryValue* global_network_config) OVERRIDE; |
| 80 | 82 |
| 81 // Push |web_trust_certs_| to |cert_verifier_| if necessary. | 83 void NotifyTrustAnchorsChanged(); |
| 82 void SetTrustAnchors(); | |
| 83 | 84 |
| 84 // Whether Web trust is allowed or not. Only relevant for user policies. | 85 // Whether Web trust is allowed or not. Only relevant for user policies. |
| 85 bool allow_trusted_certificates_from_policy_; | 86 bool allow_trusted_certificates_from_policy_; |
| 86 | 87 |
| 87 // The user for whom the user policy will be applied. Is NULL if this Updater | 88 // The user for whom the user policy will be applied. Is NULL if this Updater |
| 88 // is used for device policy. | 89 // is used for device policy. |
| 89 const chromeos::User* user_; | 90 const chromeos::User* user_; |
| 90 | 91 |
| 91 // Calls to this object are only allowed on the IO Thread. | 92 ObserverList<WebTrustedCertsObserver, true> observer_list_; |
| 92 PolicyCertVerifier* cert_verifier_; | |
| 93 | 93 |
| 94 // Contains the certificates of the last import that requested web trust. Must | 94 // Contains the certificates of the last import that requested web trust. Must |
| 95 // be empty if Web trust from policy is not allowed. | 95 // be empty if Web trust from policy is not allowed. |
| 96 net::CertificateList web_trust_certs_; | 96 net::CertificateList web_trust_certs_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(UserNetworkConfigurationUpdater); | 98 DISALLOW_COPY_AND_ASSIGN(UserNetworkConfigurationUpdater); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace policy | 101 } // namespace policy |
| 102 | 102 |
| 103 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ | 103 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ |
| OLD | NEW |