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 #include "chrome/browser/chromeos/login/managed/supervised_user_login_flow.h" | 5 #include "chrome/browser/chromeos/login/managed/supervised_user_login_flow.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/login/auth/key.h" |
13 #include "chrome/browser/chromeos/login/login_utils.h" | 14 #include "chrome/browser/chromeos/login/login_utils.h" |
14 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
" | 15 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
" |
15 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc
reen.h" | 16 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc
reen.h" |
16 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h
" | 17 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h
" |
17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
18 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 19 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
19 #include "chrome/browser/chromeos/login/users/user_manager.h" | 20 #include "chrome/browser/chromeos/login/users/user_manager.h" |
20 #include "chrome/browser/chromeos/login/wizard_controller.h" | 21 #include "chrome/browser/chromeos/login/wizard_controller.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 | 23 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 auth->GetPasswordSchema(user_id()); | 140 auth->GetPasswordSchema(user_id()); |
140 | 141 |
141 key.revision = revision; | 142 key.revision = revision; |
142 | 143 |
143 if (SupervisedUserAuthentication::SCHEMA_PLAIN == current_schema) { | 144 if (SupervisedUserAuthentication::SCHEMA_PLAIN == current_schema) { |
144 // We need to add new key, and block old one. As we don't actually have | 145 // We need to add new key, and block old one. As we don't actually have |
145 // signature key, use Migrate privilege instead of AuthorizedUpdate. | 146 // signature key, use Migrate privilege instead of AuthorizedUpdate. |
146 key.privileges = kCryptohomeManagedUserIncompleteKeyPrivileges; | 147 key.privileges = kCryptohomeManagedUserIncompleteKeyPrivileges; |
147 | 148 |
148 VLOG(1) << "Adding new schema key"; | 149 VLOG(1) << "Adding new schema key"; |
149 DCHECK(context_.GetKeyLabel().empty()); | 150 DCHECK(context_.GetKey()->GetLabel().empty()); |
150 authenticator_->AddKey(context_, | 151 authenticator_->AddKey(context_, |
151 key, | 152 key, |
152 false /* no key exists */, | 153 false /* no key exists */, |
153 base::Bind(&SupervisedUserLoginFlow::OnNewKeyAdded, | 154 base::Bind(&SupervisedUserLoginFlow::OnNewKeyAdded, |
154 weak_factory_.GetWeakPtr(), | 155 weak_factory_.GetWeakPtr(), |
155 Passed(&data_copy))); | 156 Passed(&data_copy))); |
156 } else if (SupervisedUserAuthentication::SCHEMA_SALT_HASHED == | 157 } else if (SupervisedUserAuthentication::SCHEMA_SALT_HASHED == |
157 current_schema) { | 158 current_schema) { |
158 VLOG(1) << "Updating the key"; | 159 VLOG(1) << "Updating the key"; |
159 | 160 |
160 if (auth->HasIncompleteKey(user_id())) { | 161 if (auth->HasIncompleteKey(user_id())) { |
161 // We need to use Migrate instead of Authorized Update privilege. | 162 // We need to use Migrate instead of Authorized Update privilege. |
162 key.privileges = kCryptohomeManagedUserIncompleteKeyPrivileges; | 163 key.privileges = kCryptohomeManagedUserIncompleteKeyPrivileges; |
163 } | 164 } |
164 // Just update the key. | 165 // Just update the key. |
165 DCHECK_EQ(context_.GetKeyLabel(), kCryptohomeManagedUserKeyLabel); | 166 DCHECK_EQ(context_.GetKey()->GetLabel(), kCryptohomeManagedUserKeyLabel); |
166 authenticator_->UpdateKeyAuthorized( | 167 authenticator_->UpdateKeyAuthorized( |
167 context_, | 168 context_, |
168 key, | 169 key, |
169 signature, | 170 signature, |
170 base::Bind(&SupervisedUserLoginFlow::OnPasswordUpdated, | 171 base::Bind(&SupervisedUserLoginFlow::OnPasswordUpdated, |
171 weak_factory_.GetWeakPtr(), | 172 weak_factory_.GetWeakPtr(), |
172 Passed(&data_copy))); | 173 Passed(&data_copy))); |
173 } else { | 174 } else { |
174 NOTREACHED() << "Unsupported password schema"; | 175 NOTREACHED() << "Unsupported password schema"; |
175 } | 176 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 Profile* profile) { | 250 Profile* profile) { |
250 profile_ = profile; | 251 profile_ = profile; |
251 UserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken( | 252 UserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken( |
252 profile, | 253 profile, |
253 base::Bind( | 254 base::Bind( |
254 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded, | 255 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded, |
255 weak_factory_.GetWeakPtr())); | 256 weak_factory_.GetWeakPtr())); |
256 } | 257 } |
257 | 258 |
258 } // namespace chromeos | 259 } // namespace chromeos |
OLD | NEW |