| 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 #include "chrome/browser/chromeos/login/managed/managed_user_authenticator.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticator
.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/chromeos/boot_times_loader.h" | 10 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 11 #include "chromeos/cryptohome/async_method_caller.h" | 11 #include "chromeos/cryptohome/async_method_caller.h" |
| 12 #include "chromeos/cryptohome/cryptohome_parameters.h" | 12 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 13 #include "chromeos/cryptohome/system_salt_getter.h" | 13 #include "chromeos/cryptohome/system_salt_getter.h" |
| 14 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
| 15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 16 #include "chromeos/login/auth/key.h" | 16 #include "chromeos/login/auth/key.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "crypto/sha2.h" | 18 #include "crypto/sha2.h" |
| 19 #include "google_apis/gaia/gaia_auth_util.h" | 19 #include "google_apis/gaia/gaia_auth_util.h" |
| 20 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Records status and calls resolver->Resolve(). | 28 // Records status and calls resolver->Resolve(). |
| 29 void TriggerResolve(ManagedUserAuthenticator::AuthAttempt* attempt, | 29 void TriggerResolve(SupervisedUserAuthenticator::AuthAttempt* attempt, |
| 30 scoped_refptr<ManagedUserAuthenticator> resolver, | 30 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 31 bool success, | 31 bool success, |
| 32 cryptohome::MountError return_code) { | 32 cryptohome::MountError return_code) { |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 34 attempt->RecordCryptohomeStatus(success, return_code); | 34 attempt->RecordCryptohomeStatus(success, return_code); |
| 35 resolver->Resolve(); | 35 resolver->Resolve(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Records status and calls resolver->Resolve(). | 38 // Records status and calls resolver->Resolve(). |
| 39 void TriggerResolveResult(ManagedUserAuthenticator::AuthAttempt* attempt, | 39 void TriggerResolveResult(SupervisedUserAuthenticator::AuthAttempt* attempt, |
| 40 scoped_refptr<ManagedUserAuthenticator> resolver, | 40 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 41 bool success, | 41 bool success, |
| 42 const std::string& result) { | 42 const std::string& result) { |
| 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 44 attempt->RecordHash(result); | 44 attempt->RecordHash(result); |
| 45 resolver->Resolve(); | 45 resolver->Resolve(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Calls TriggerResolve while adding login time marker. | 48 // Calls TriggerResolve while adding login time marker. |
| 49 void TriggerResolveWithLoginTimeMarker( | 49 void TriggerResolveWithLoginTimeMarker( |
| 50 const std::string& marker_name, | 50 const std::string& marker_name, |
| 51 ManagedUserAuthenticator::AuthAttempt* attempt, | 51 SupervisedUserAuthenticator::AuthAttempt* attempt, |
| 52 scoped_refptr<ManagedUserAuthenticator> resolver, | 52 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 53 bool success, | 53 bool success, |
| 54 cryptohome::MountError return_code) { | 54 cryptohome::MountError return_code) { |
| 55 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(marker_name, false); | 55 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(marker_name, false); |
| 56 TriggerResolve(attempt, resolver, success, return_code); | 56 TriggerResolve(attempt, resolver, success, return_code); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Calls cryptohome's mount method. | 59 // Calls cryptohome's mount method. |
| 60 void Mount(ManagedUserAuthenticator::AuthAttempt* attempt, | 60 void Mount(SupervisedUserAuthenticator::AuthAttempt* attempt, |
| 61 scoped_refptr<ManagedUserAuthenticator> resolver, | 61 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 62 int flags, | 62 int flags, |
| 63 const std::string& system_salt) { | 63 const std::string& system_salt) { |
| 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 65 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 65 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
| 66 "CryptohomeMount-LMU-Start", false); | 66 "CryptohomeMount-LMU-Start", false); |
| 67 | 67 |
| 68 Key key(attempt->password); | 68 Key key(attempt->password); |
| 69 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 69 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 70 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount( | 70 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount( |
| 71 attempt->username, | 71 attempt->username, |
| 72 key.GetSecret(), | 72 key.GetSecret(), |
| 73 flags, | 73 flags, |
| 74 base::Bind(&TriggerResolveWithLoginTimeMarker, | 74 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 75 "CryptohomeMount-LMU-End", | 75 "CryptohomeMount-LMU-End", |
| 76 attempt, | 76 attempt, |
| 77 resolver)); | 77 resolver)); |
| 78 | 78 |
| 79 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 79 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
| 80 attempt->username, | 80 attempt->username, |
| 81 base::Bind(&TriggerResolveResult, attempt, resolver)); | 81 base::Bind(&TriggerResolveResult, attempt, resolver)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Calls cryptohome's addKey method. | 84 // Calls cryptohome's addKey method. |
| 85 void AddKey(ManagedUserAuthenticator::AuthAttempt* attempt, | 85 void AddKey(SupervisedUserAuthenticator::AuthAttempt* attempt, |
| 86 scoped_refptr<ManagedUserAuthenticator> resolver, | 86 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 87 const std::string& plain_text_master_key, | 87 const std::string& plain_text_master_key, |
| 88 const std::string& system_salt) { | 88 const std::string& system_salt) { |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 90 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 90 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
| 91 "CryptohomeAddKey-LMU-Start", false); | 91 "CryptohomeAddKey-LMU-Start", false); |
| 92 | 92 |
| 93 Key user_key(attempt->password); | 93 Key user_key(attempt->password); |
| 94 user_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 94 user_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 95 Key master_key(plain_text_master_key); | 95 Key master_key(plain_text_master_key); |
| 96 master_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 96 master_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 97 cryptohome::AsyncMethodCaller::GetInstance()->AsyncAddKey( | 97 cryptohome::AsyncMethodCaller::GetInstance()->AsyncAddKey( |
| 98 attempt->username, | 98 attempt->username, |
| 99 user_key.GetSecret(), | 99 user_key.GetSecret(), |
| 100 master_key.GetSecret(), | 100 master_key.GetSecret(), |
| 101 base::Bind(&TriggerResolveWithLoginTimeMarker, | 101 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 102 "CryptohomeAddKey-LMU-End", | 102 "CryptohomeAddKey-LMU-End", |
| 103 attempt, | 103 attempt, |
| 104 resolver)); | 104 resolver)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace | 107 } // namespace |
| 108 | 108 |
| 109 ManagedUserAuthenticator::ManagedUserAuthenticator(AuthStatusConsumer* consumer) | 109 SupervisedUserAuthenticator::SupervisedUserAuthenticator( |
| 110 AuthStatusConsumer* consumer) |
| 110 : consumer_(consumer) {} | 111 : consumer_(consumer) {} |
| 111 | 112 |
| 112 void ManagedUserAuthenticator::AuthenticateToMount( | 113 void SupervisedUserAuthenticator::AuthenticateToMount( |
| 113 const std::string& username, | 114 const std::string& username, |
| 114 const std::string& password) { | 115 const std::string& password) { |
| 115 std::string canonicalized = gaia::CanonicalizeEmail(username); | 116 std::string canonicalized = gaia::CanonicalizeEmail(username); |
| 116 | 117 |
| 117 current_state_.reset(new ManagedUserAuthenticator::AuthAttempt( | 118 current_state_.reset(new SupervisedUserAuthenticator::AuthAttempt( |
| 118 canonicalized, password, false)); | 119 canonicalized, password, false)); |
| 119 | 120 |
| 120 SystemSaltGetter::Get()->GetSystemSalt( | 121 SystemSaltGetter::Get()->GetSystemSalt( |
| 121 base::Bind(&Mount, | 122 base::Bind(&Mount, |
| 122 current_state_.get(), | 123 current_state_.get(), |
| 123 scoped_refptr<ManagedUserAuthenticator>(this), | 124 scoped_refptr<SupervisedUserAuthenticator>(this), |
| 124 cryptohome::MOUNT_FLAGS_NONE)); | 125 cryptohome::MOUNT_FLAGS_NONE)); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void ManagedUserAuthenticator::AuthenticateToCreate( | 128 void SupervisedUserAuthenticator::AuthenticateToCreate( |
| 128 const std::string& username, | 129 const std::string& username, |
| 129 const std::string& password) { | 130 const std::string& password) { |
| 130 std::string canonicalized = gaia::CanonicalizeEmail(username); | 131 std::string canonicalized = gaia::CanonicalizeEmail(username); |
| 131 | 132 |
| 132 current_state_.reset(new ManagedUserAuthenticator::AuthAttempt( | 133 current_state_.reset(new SupervisedUserAuthenticator::AuthAttempt( |
| 133 canonicalized, password, false)); | 134 canonicalized, password, false)); |
| 134 | 135 |
| 135 SystemSaltGetter::Get()->GetSystemSalt( | 136 SystemSaltGetter::Get()->GetSystemSalt( |
| 136 base::Bind(&Mount, | 137 base::Bind(&Mount, |
| 137 current_state_.get(), | 138 current_state_.get(), |
| 138 scoped_refptr<ManagedUserAuthenticator>(this), | 139 scoped_refptr<SupervisedUserAuthenticator>(this), |
| 139 cryptohome::CREATE_IF_MISSING)); | 140 cryptohome::CREATE_IF_MISSING)); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void ManagedUserAuthenticator::AddMasterKey( | 143 void SupervisedUserAuthenticator::AddMasterKey( |
| 143 const std::string& username, | 144 const std::string& username, |
| 144 const std::string& password, | 145 const std::string& password, |
| 145 const std::string& master_key) { | 146 const std::string& master_key) { |
| 146 std::string canonicalized = gaia::CanonicalizeEmail(username); | 147 std::string canonicalized = gaia::CanonicalizeEmail(username); |
| 147 | 148 |
| 148 current_state_.reset(new ManagedUserAuthenticator::AuthAttempt( | 149 current_state_.reset(new SupervisedUserAuthenticator::AuthAttempt( |
| 149 canonicalized, password, true)); | 150 canonicalized, password, true)); |
| 150 | 151 |
| 151 SystemSaltGetter::Get()->GetSystemSalt( | 152 SystemSaltGetter::Get()->GetSystemSalt( |
| 152 base::Bind(&AddKey, | 153 base::Bind(&AddKey, |
| 153 current_state_.get(), | 154 current_state_.get(), |
| 154 scoped_refptr<ManagedUserAuthenticator>(this), | 155 scoped_refptr<SupervisedUserAuthenticator>(this), |
| 155 master_key)); | 156 master_key)); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void ManagedUserAuthenticator::OnAuthenticationSuccess( | 159 void SupervisedUserAuthenticator::OnAuthenticationSuccess( |
| 159 const std::string& mount_hash, | 160 const std::string& mount_hash, |
| 160 bool add_key) { | 161 bool add_key) { |
| 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 162 VLOG(1) << "Locally managed user authentication success"; | 163 VLOG(1) << "Supervised user authentication success"; |
| 163 if (consumer_) { | 164 if (consumer_) { |
| 164 if (add_key) | 165 if (add_key) |
| 165 consumer_->OnAddKeySuccess(); | 166 consumer_->OnAddKeySuccess(); |
| 166 else | 167 else |
| 167 consumer_->OnMountSuccess(mount_hash); | 168 consumer_->OnMountSuccess(mount_hash); |
| 168 } | 169 } |
| 169 } | 170 } |
| 170 | 171 |
| 171 void ManagedUserAuthenticator::OnAuthenticationFailure( | 172 void SupervisedUserAuthenticator::OnAuthenticationFailure( |
| 172 ManagedUserAuthenticator::AuthState state) { | 173 SupervisedUserAuthenticator::AuthState state) { |
| 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 174 LOG(WARNING) << "Locally managed user authentication failure"; | 175 LOG(WARNING) << "Supervised user authentication failure"; |
| 175 if (consumer_) | 176 if (consumer_) |
| 176 consumer_->OnAuthenticationFailure(state); | 177 consumer_->OnAuthenticationFailure(state); |
| 177 } | 178 } |
| 178 | 179 |
| 179 void ManagedUserAuthenticator::Resolve() { | 180 void SupervisedUserAuthenticator::Resolve() { |
| 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 181 ManagedUserAuthenticator::AuthState state = ResolveState(); | 182 SupervisedUserAuthenticator::AuthState state = ResolveState(); |
| 182 VLOG(1) << "Resolved state to: " << state; | 183 VLOG(1) << "Resolved state to: " << state; |
| 183 switch (state) { | 184 switch (state) { |
| 184 case CONTINUE: | 185 case CONTINUE: |
| 185 // These are intermediate states; we need more info from a request that | 186 // These are intermediate states; we need more info from a request that |
| 186 // is still pending. | 187 // is still pending. |
| 187 break; | 188 break; |
| 188 case FAILED_MOUNT: | 189 case FAILED_MOUNT: |
| 189 // In this case, whether login succeeded or not, we can't log | 190 // In this case, whether login succeeded or not, we can't log |
| 190 // the user in because their data is horked. So, override with | 191 // the user in because their data is horked. So, override with |
| 191 // the appropriate failure. | 192 // the appropriate failure. |
| 192 BrowserThread::PostTask( | 193 BrowserThread::PostTask( |
| 193 BrowserThread::UI, | 194 BrowserThread::UI, |
| 194 FROM_HERE, | 195 FROM_HERE, |
| 195 base::Bind( | 196 base::Bind(&SupervisedUserAuthenticator::OnAuthenticationFailure, |
| 196 &ManagedUserAuthenticator::OnAuthenticationFailure, this, state)); | 197 this, |
| 198 state)); |
| 197 break; | 199 break; |
| 198 case NO_MOUNT: | 200 case NO_MOUNT: |
| 199 // In this case, whether login succeeded or not, we can't log | 201 // In this case, whether login succeeded or not, we can't log |
| 200 // the user in because no data exist. So, override with | 202 // the user in because no data exist. So, override with |
| 201 // the appropriate failure. | 203 // the appropriate failure. |
| 202 BrowserThread::PostTask( | 204 BrowserThread::PostTask( |
| 203 BrowserThread::UI, | 205 BrowserThread::UI, |
| 204 FROM_HERE, | 206 FROM_HERE, |
| 205 base::Bind( | 207 base::Bind(&SupervisedUserAuthenticator::OnAuthenticationFailure, |
| 206 &ManagedUserAuthenticator::OnAuthenticationFailure, this, state)); | 208 this, |
| 209 state)); |
| 207 break; | 210 break; |
| 208 case FAILED_TPM: | 211 case FAILED_TPM: |
| 209 // In this case, we tried to create/mount cryptohome and failed | 212 // In this case, we tried to create/mount cryptohome and failed |
| 210 // because of the critical TPM error. | 213 // because of the critical TPM error. |
| 211 // Chrome will notify user and request reboot. | 214 // Chrome will notify user and request reboot. |
| 212 BrowserThread::PostTask( | 215 BrowserThread::PostTask( |
| 213 BrowserThread::UI, | 216 BrowserThread::UI, |
| 214 FROM_HERE, | 217 FROM_HERE, |
| 215 base::Bind( | 218 base::Bind(&SupervisedUserAuthenticator::OnAuthenticationFailure, |
| 216 &ManagedUserAuthenticator::OnAuthenticationFailure, this, state)); | 219 this, |
| 220 state)); |
| 217 break; | 221 break; |
| 218 case SUCCESS: | 222 case SUCCESS: |
| 219 VLOG(2) << "Locally managed user login"; | 223 VLOG(2) << "Supervised user login"; |
| 220 BrowserThread::PostTask( | 224 BrowserThread::PostTask( |
| 221 BrowserThread::UI, | 225 BrowserThread::UI, |
| 222 FROM_HERE, | 226 FROM_HERE, |
| 223 base::Bind(&ManagedUserAuthenticator::OnAuthenticationSuccess, | 227 base::Bind(&SupervisedUserAuthenticator::OnAuthenticationSuccess, |
| 224 this, | 228 this, |
| 225 current_state_->hash(), | 229 current_state_->hash(), |
| 226 current_state_->add_key)); | 230 current_state_->add_key)); |
| 227 break; | 231 break; |
| 228 default: | 232 default: |
| 229 NOTREACHED(); | 233 NOTREACHED(); |
| 230 break; | 234 break; |
| 231 } | 235 } |
| 232 } | 236 } |
| 233 | 237 |
| 234 ManagedUserAuthenticator::~ManagedUserAuthenticator() {} | 238 SupervisedUserAuthenticator::~SupervisedUserAuthenticator() {} |
| 235 | 239 |
| 236 ManagedUserAuthenticator::AuthState ManagedUserAuthenticator::ResolveState() { | 240 SupervisedUserAuthenticator::AuthState |
| 241 SupervisedUserAuthenticator::ResolveState() { |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 238 // If we haven't mounted the user's home dir yet, we can't be done. | 243 // If we haven't mounted the user's home dir yet, we can't be done. |
| 239 // We never get past here if a cryptohome op is still pending. | 244 // We never get past here if a cryptohome op is still pending. |
| 240 // This is an important invariant. | 245 // This is an important invariant. |
| 241 if (!current_state_->cryptohome_complete()) | 246 if (!current_state_->cryptohome_complete()) |
| 242 return CONTINUE; | 247 return CONTINUE; |
| 243 if (!current_state_->add_key && !current_state_->hash_obtained()) | 248 if (!current_state_->add_key && !current_state_->hash_obtained()) |
| 244 return CONTINUE; | 249 return CONTINUE; |
| 245 | 250 |
| 246 AuthState state; | 251 AuthState state; |
| 247 | 252 |
| 248 if (current_state_->cryptohome_outcome()) | 253 if (current_state_->cryptohome_outcome()) |
| 249 state = ResolveCryptohomeSuccessState(); | 254 state = ResolveCryptohomeSuccessState(); |
| 250 else | 255 else |
| 251 state = ResolveCryptohomeFailureState(); | 256 state = ResolveCryptohomeFailureState(); |
| 252 | 257 |
| 253 DCHECK(current_state_->cryptohome_complete()); | 258 DCHECK(current_state_->cryptohome_complete()); |
| 254 DCHECK(current_state_->hash_obtained() || current_state_->add_key); | 259 DCHECK(current_state_->hash_obtained() || current_state_->add_key); |
| 255 return state; | 260 return state; |
| 256 } | 261 } |
| 257 | 262 |
| 258 ManagedUserAuthenticator::AuthState | 263 SupervisedUserAuthenticator::AuthState |
| 259 ManagedUserAuthenticator::ResolveCryptohomeFailureState() { | 264 SupervisedUserAuthenticator::ResolveCryptohomeFailureState() { |
| 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 261 if (current_state_->cryptohome_code() == | 266 if (current_state_->cryptohome_code() == |
| 262 cryptohome::MOUNT_ERROR_TPM_NEEDS_REBOOT) { | 267 cryptohome::MOUNT_ERROR_TPM_NEEDS_REBOOT) { |
| 263 // Critical TPM error detected, reboot needed. | 268 // Critical TPM error detected, reboot needed. |
| 264 return FAILED_TPM; | 269 return FAILED_TPM; |
| 265 } | 270 } |
| 266 | 271 |
| 267 if (current_state_->cryptohome_code() == | 272 if (current_state_->cryptohome_code() == |
| 268 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST) { | 273 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST) { |
| 269 // If we tried a mount but the user did not exist, then we should wait | 274 // If we tried a mount but the user did not exist, then we should wait |
| 270 // for online login to succeed and try again with the "create" flag set. | 275 // for online login to succeed and try again with the "create" flag set. |
| 271 return NO_MOUNT; | 276 return NO_MOUNT; |
| 272 } | 277 } |
| 273 | 278 |
| 274 return FAILED_MOUNT; | 279 return FAILED_MOUNT; |
| 275 } | 280 } |
| 276 | 281 |
| 277 ManagedUserAuthenticator::AuthState | 282 SupervisedUserAuthenticator::AuthState |
| 278 ManagedUserAuthenticator::ResolveCryptohomeSuccessState() { | 283 SupervisedUserAuthenticator::ResolveCryptohomeSuccessState() { |
| 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 280 return SUCCESS; | 285 return SUCCESS; |
| 281 } | 286 } |
| 282 | 287 |
| 283 ManagedUserAuthenticator::AuthAttempt::AuthAttempt(const std::string& username, | 288 SupervisedUserAuthenticator::AuthAttempt::AuthAttempt( |
| 284 const std::string& password, | 289 const std::string& username, |
| 285 bool add_key_attempt) | 290 const std::string& password, |
| 291 bool add_key_attempt) |
| 286 : username(username), | 292 : username(username), |
| 287 password(password), | 293 password(password), |
| 288 add_key(add_key_attempt), | 294 add_key(add_key_attempt), |
| 289 cryptohome_complete_(false), | 295 cryptohome_complete_(false), |
| 290 cryptohome_outcome_(false), | 296 cryptohome_outcome_(false), |
| 291 hash_obtained_(false), | 297 hash_obtained_(false), |
| 292 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE) {} | 298 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE) {} |
| 293 | 299 |
| 294 ManagedUserAuthenticator::AuthAttempt::~AuthAttempt() {} | 300 SupervisedUserAuthenticator::AuthAttempt::~AuthAttempt() {} |
| 295 | 301 |
| 296 void ManagedUserAuthenticator::AuthAttempt::RecordCryptohomeStatus( | 302 void SupervisedUserAuthenticator::AuthAttempt::RecordCryptohomeStatus( |
| 297 bool cryptohome_outcome, | 303 bool cryptohome_outcome, |
| 298 cryptohome::MountError cryptohome_code) { | 304 cryptohome::MountError cryptohome_code) { |
| 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 300 cryptohome_complete_ = true; | 306 cryptohome_complete_ = true; |
| 301 cryptohome_outcome_ = cryptohome_outcome; | 307 cryptohome_outcome_ = cryptohome_outcome; |
| 302 cryptohome_code_ = cryptohome_code; | 308 cryptohome_code_ = cryptohome_code; |
| 303 } | 309 } |
| 304 | 310 |
| 305 void ManagedUserAuthenticator::AuthAttempt::RecordHash( | 311 void SupervisedUserAuthenticator::AuthAttempt::RecordHash( |
| 306 const std::string& hash) { | 312 const std::string& hash) { |
| 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 308 hash_obtained_ = true; | 314 hash_obtained_ = true; |
| 309 hash_ = hash; | 315 hash_ = hash; |
| 310 } | 316 } |
| 311 | 317 |
| 312 bool ManagedUserAuthenticator::AuthAttempt::cryptohome_complete() { | 318 bool SupervisedUserAuthenticator::AuthAttempt::cryptohome_complete() { |
| 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 314 return cryptohome_complete_; | 320 return cryptohome_complete_; |
| 315 } | 321 } |
| 316 | 322 |
| 317 bool ManagedUserAuthenticator::AuthAttempt::cryptohome_outcome() { | 323 bool SupervisedUserAuthenticator::AuthAttempt::cryptohome_outcome() { |
| 318 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 319 return cryptohome_outcome_; | 325 return cryptohome_outcome_; |
| 320 } | 326 } |
| 321 | 327 |
| 322 cryptohome::MountError | 328 cryptohome::MountError |
| 323 ManagedUserAuthenticator::AuthAttempt::cryptohome_code() { | 329 SupervisedUserAuthenticator::AuthAttempt::cryptohome_code() { |
| 324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 325 return cryptohome_code_; | 331 return cryptohome_code_; |
| 326 } | 332 } |
| 327 | 333 |
| 328 bool ManagedUserAuthenticator::AuthAttempt::hash_obtained() { | 334 bool SupervisedUserAuthenticator::AuthAttempt::hash_obtained() { |
| 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 330 return hash_obtained_; | 336 return hash_obtained_; |
| 331 } | 337 } |
| 332 | 338 |
| 333 std::string ManagedUserAuthenticator::AuthAttempt::hash() { | 339 std::string SupervisedUserAuthenticator::AuthAttempt::hash() { |
| 334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 335 return hash_; | 341 return hash_; |
| 336 } | 342 } |
| 337 | 343 |
| 338 } // namespace chromeos | 344 } // namespace chromeos |
| OLD | NEW |