| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ |
| 6 #define CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/chromeos/login/auth/extended_authenticator.h" | 13 #include "chrome/browser/chromeos/login/auth/extended_authenticator.h" |
| 14 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | 14 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" |
| 15 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | 15 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" |
| 16 #include "chrome/browser/managed_mode/managed_users.h" | 16 #include "chrome/browser/supervised_user/supervised_users.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 class UserContext; | 21 class UserContext; |
| 22 | 22 |
| 23 // Handles managed user password change that is detected while manager is | 23 // Handles supervised user password change that is detected while manager is |
| 24 // signed in. | 24 // signed in. |
| 25 // It uses manager's master key to authorize update of managed user's key. | 25 // It uses manager's master key to authorize update of supervised user's key. |
| 26 // Edge case: Pre-M35 supervised users don't have correct labels for keys. | 26 // Edge case: Pre-M35 supervised users don't have correct labels for keys. |
| 27 // After new managed user key is added, migration is done in following way: | 27 // After new supervised user key is added, migration is done in following way: |
| 28 // 1) Master key is added with correct label | 28 // 1) Master key is added with correct label |
| 29 // 2) Old managed user's key is deleted. | 29 // 2) Old supervised user's key is deleted. |
| 30 // 3) Old master key is deleted. | 30 // 3) Old master key is deleted. |
| 31 class ManagerPasswordService | 31 class ManagerPasswordService |
| 32 : public KeyedService, | 32 : public KeyedService, |
| 33 public chromeos::ExtendedAuthenticator::AuthStatusConsumer { | 33 public chromeos::ExtendedAuthenticator::AuthStatusConsumer { |
| 34 public: | 34 public: |
| 35 ManagerPasswordService(); | 35 ManagerPasswordService(); |
| 36 virtual ~ManagerPasswordService(); | 36 virtual ~ManagerPasswordService(); |
| 37 | 37 |
| 38 virtual void Shutdown() OVERRIDE; | 38 virtual void Shutdown() OVERRIDE; |
| 39 | 39 |
| 40 void Init(const std::string& user_id, | 40 void Init(const std::string& user_id, |
| 41 ManagedUserSyncService* user_service, | 41 SupervisedUserSyncService* user_service, |
| 42 ManagedUserSharedSettingsService* service); | 42 SupervisedUserSharedSettingsService* service); |
| 43 | 43 |
| 44 // chromeos::ExtendedAuthenticator::AuthStatusConsumer overrides: | 44 // chromeos::ExtendedAuthenticator::AuthStatusConsumer overrides: |
| 45 virtual void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state) | 45 virtual void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state) |
| 46 OVERRIDE; | 46 OVERRIDE; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 void OnSharedSettingsChange(const std::string& mu_id, const std::string& key); | 49 void OnSharedSettingsChange(const std::string& su_id, const std::string& key); |
| 50 void GetManagedUsersCallback(const std::string& sync_mu_id, | 50 void GetSupervisedUsersCallback( |
| 51 const std::string& user_id, | 51 const std::string& sync_su_id, |
| 52 scoped_ptr<base::DictionaryValue> password_data, | 52 const std::string& user_id, |
| 53 const base::DictionaryValue* managed_users); | 53 scoped_ptr<base::DictionaryValue> password_data, |
| 54 const base::DictionaryValue* supervised_users); |
| 54 void OnAddKeySuccess(const UserContext& master_key_context, | 55 void OnAddKeySuccess(const UserContext& master_key_context, |
| 55 const std::string& user_id, | 56 const std::string& user_id, |
| 56 scoped_ptr<base::DictionaryValue> password_data); | 57 scoped_ptr<base::DictionaryValue> password_data); |
| 57 void OnKeyTransformedIfNeeded(const UserContext& master_key_context); | 58 void OnKeyTransformedIfNeeded(const UserContext& master_key_context); |
| 58 void OnNewManagerKeySuccess(const UserContext& master_key_context); | 59 void OnNewManagerKeySuccess(const UserContext& master_key_context); |
| 59 void OnOldManagedUserKeyDeleted(const UserContext& master_key_context); | 60 void OnOldSupervisedUserKeyDeleted(const UserContext& master_key_context); |
| 60 void OnOldManagerKeyDeleted(const UserContext& master_key_context); | 61 void OnOldManagerKeyDeleted(const UserContext& master_key_context); |
| 61 | 62 |
| 62 // Cached value from Init(). | 63 // Cached value from Init(). |
| 63 // User id of currently logged in user, that have managed users on device. | 64 // User id of currently logged in user, that have supervised users on device. |
| 64 std::string user_id_; | 65 std::string user_id_; |
| 65 ManagedUserSyncService* user_service_; | 66 SupervisedUserSyncService* user_service_; |
| 66 ManagedUserSharedSettingsService* settings_service_; | 67 SupervisedUserSharedSettingsService* settings_service_; |
| 67 | 68 |
| 68 scoped_ptr<ManagedUserSharedSettingsService::ChangeCallbackList::Subscription> | 69 scoped_ptr<SupervisedUserSharedSettingsService::ChangeCallbackList:: |
| 70 Subscription> |
| 69 settings_service_subscription_; | 71 settings_service_subscription_; |
| 70 | 72 |
| 71 scoped_refptr<ExtendedAuthenticator> authenticator_; | 73 scoped_refptr<ExtendedAuthenticator> authenticator_; |
| 72 | 74 |
| 73 base::WeakPtrFactory<ManagerPasswordService> weak_ptr_factory_; | 75 base::WeakPtrFactory<ManagerPasswordService> weak_ptr_factory_; |
| 74 | 76 |
| 75 DISALLOW_COPY_AND_ASSIGN(ManagerPasswordService); | 77 DISALLOW_COPY_AND_ASSIGN(ManagerPasswordService); |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 } // namespace chromeos | 80 } // namespace chromeos |
| 79 #endif // CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ | 81 #endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ |
| OLD | NEW |