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