| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromeos/dbus/fake_auth_policy_client.h" | 5 #include "chromeos/dbus/fake_auth_policy_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 user_principal_name, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 98 user_principal_name, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 99 if (parts.size() != 2 || parts[0].empty() || parts[1].empty()) { | 99 if (parts.size() != 2 || parts[0].empty() || parts[1].empty()) { |
| 100 error = authpolicy::ERROR_PARSE_UPN_FAILED; | 100 error = authpolicy::ERROR_PARSE_UPN_FAILED; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 PostDelayedClosure(base::BindOnce(std::move(callback), error)); | 103 PostDelayedClosure(base::BindOnce(std::move(callback), error)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void FakeAuthPolicyClient::AuthenticateUser( | 106 void FakeAuthPolicyClient::AuthenticateUser( |
| 107 const std::string& user_principal_name, | 107 const std::string& user_principal_name, |
| 108 const std::string& object_guid, |
| 108 int password_fd, | 109 int password_fd, |
| 109 AuthCallback callback) { | 110 AuthCallback callback) { |
| 110 authpolicy::ErrorType error = authpolicy::ERROR_NONE; | 111 authpolicy::ErrorType error = authpolicy::ERROR_NONE; |
| 111 authpolicy::ActiveDirectoryAccountData account_data; | 112 authpolicy::ActiveDirectoryAccountData account_data; |
| 112 if (!started_) { | 113 if (!started_) { |
| 113 LOG(ERROR) << "authpolicyd not started"; | 114 LOG(ERROR) << "authpolicyd not started"; |
| 114 error = authpolicy::ERROR_DBUS_FAILURE; | 115 error = authpolicy::ERROR_DBUS_FAILURE; |
| 115 } else { | 116 } else { |
| 116 if (auth_error_ == authpolicy::ERROR_NONE) | 117 if (auth_error_ == authpolicy::ERROR_NONE) { |
| 117 account_data.set_account_id(base::MD5String(user_principal_name)); | 118 if (object_guid.empty()) |
| 119 account_data.set_account_id(base::MD5String(user_principal_name)); |
| 120 else |
| 121 account_data.set_account_id(object_guid); |
| 122 } |
| 118 error = auth_error_; | 123 error = auth_error_; |
| 119 } | 124 } |
| 120 PostDelayedClosure(base::BindOnce(std::move(callback), error, account_data)); | 125 PostDelayedClosure(base::BindOnce(std::move(callback), error, account_data)); |
| 121 } | 126 } |
| 122 | 127 |
| 123 void FakeAuthPolicyClient::RefreshDevicePolicy(RefreshPolicyCallback callback) { | 128 void FakeAuthPolicyClient::RefreshDevicePolicy(RefreshPolicyCallback callback) { |
| 124 if (!started_) { | 129 if (!started_) { |
| 125 LOG(ERROR) << "authpolicyd not started"; | 130 LOG(ERROR) << "authpolicyd not started"; |
| 126 std::move(callback).Run(false); | 131 std::move(callback).Run(false); |
| 127 return; | 132 return; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 .WithShutdownBehavior( | 185 .WithShutdownBehavior( |
| 181 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 186 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
| 182 .WithPriority(base::TaskPriority::BACKGROUND) | 187 .WithPriority(base::TaskPriority::BACKGROUND) |
| 183 .MayBlock(), | 188 .MayBlock(), |
| 184 base::BindOnce(&WritePolicyFile, policy_path, payload, | 189 base::BindOnce(&WritePolicyFile, policy_path, payload, |
| 185 "google/chromeos/user"), | 190 "google/chromeos/user"), |
| 186 std::move(callback)); | 191 std::move(callback)); |
| 187 } | 192 } |
| 188 | 193 |
| 189 } // namespace chromeos | 194 } // namespace chromeos |
| OLD | NEW |