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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const std::string& object_guid, |
109 int password_fd, | 109 int password_fd, |
110 AuthCallback callback) { | 110 AuthCallback callback) { |
111 authpolicy::ErrorType error = authpolicy::ERROR_NONE; | 111 authpolicy::ErrorType error = authpolicy::ERROR_NONE; |
112 authpolicy::ActiveDirectoryAccountData account_data; | 112 authpolicy::ActiveDirectoryAccountInfo account_info; |
113 if (!started_) { | 113 if (!started_) { |
114 LOG(ERROR) << "authpolicyd not started"; | 114 LOG(ERROR) << "authpolicyd not started"; |
115 error = authpolicy::ERROR_DBUS_FAILURE; | 115 error = authpolicy::ERROR_DBUS_FAILURE; |
116 } else { | 116 } else { |
117 if (auth_error_ == authpolicy::ERROR_NONE) { | 117 if (auth_error_ == authpolicy::ERROR_NONE) { |
118 if (object_guid.empty()) | 118 if (object_guid.empty()) |
119 account_data.set_account_id(base::MD5String(user_principal_name)); | 119 account_info.set_account_id(base::MD5String(user_principal_name)); |
120 else | 120 else |
121 account_data.set_account_id(object_guid); | 121 account_info.set_account_id(object_guid); |
122 } | 122 } |
123 error = auth_error_; | 123 error = auth_error_; |
124 } | 124 } |
125 PostDelayedClosure(base::BindOnce(std::move(callback), error, account_data)); | 125 PostDelayedClosure(base::BindOnce(std::move(callback), error, account_info)); |
| 126 } |
| 127 |
| 128 void FakeAuthPolicyClient::GetUserStatus(const std::string& object_guid, |
| 129 GetUserStatusCallback callback) { |
| 130 authpolicy::ActiveDirectoryUserStatus user_status; |
| 131 user_status.mutable_account_info()->set_account_id(object_guid); |
| 132 PostDelayedClosure( |
| 133 base::BindOnce(std::move(callback), authpolicy::ERROR_NONE, user_status)); |
126 } | 134 } |
127 | 135 |
128 void FakeAuthPolicyClient::RefreshDevicePolicy(RefreshPolicyCallback callback) { | 136 void FakeAuthPolicyClient::RefreshDevicePolicy(RefreshPolicyCallback callback) { |
129 if (!started_) { | 137 if (!started_) { |
130 LOG(ERROR) << "authpolicyd not started"; | 138 LOG(ERROR) << "authpolicyd not started"; |
131 std::move(callback).Run(false); | 139 std::move(callback).Run(false); |
132 return; | 140 return; |
133 } | 141 } |
134 base::FilePath policy_path; | 142 base::FilePath policy_path; |
135 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &policy_path)) { | 143 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &policy_path)) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 .WithShutdownBehavior( | 193 .WithShutdownBehavior( |
186 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 194 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
187 .WithPriority(base::TaskPriority::BACKGROUND) | 195 .WithPriority(base::TaskPriority::BACKGROUND) |
188 .MayBlock(), | 196 .MayBlock(), |
189 base::BindOnce(&WritePolicyFile, policy_path, payload, | 197 base::BindOnce(&WritePolicyFile, policy_path, payload, |
190 "google/chromeos/user"), | 198 "google/chromeos/user"), |
191 std::move(callback)); | 199 std::move(callback)); |
192 } | 200 } |
193 | 201 |
194 } // namespace chromeos | 202 } // namespace chromeos |
OLD | NEW |