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" |
11 #include "base/md5.h" | 11 #include "base/md5.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
14 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
16 #include "chromeos/chromeos_paths.h" | 16 #include "chromeos/chromeos_paths.h" |
17 #include "chromeos/cryptohome/cryptohome_parameters.h" | 17 #include "chromeos/cryptohome/cryptohome_parameters.h" |
18 #include "chromeos/dbus/cryptohome_client.h" | 18 #include "chromeos/dbus/cryptohome_client.h" |
19 #include "components/policy/proto/cloud_policy.pb.h" | 19 #include "components/policy/proto/cloud_policy.pb.h" |
20 #include "components/policy/proto/device_management_backend.pb.h" | 20 #include "components/policy/proto/device_management_backend.pb.h" |
21 #include "components/signin/core/account_id/account_id.h" | 21 #include "components/signin/core/account_id/account_id.h" |
| 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
22 | 23 |
23 namespace em = enterprise_management; | 24 namespace em = enterprise_management; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // Drop stub policy file of |policy_type| at |policy_path| containing | 28 // Drop stub policy file of |policy_type| at |policy_path| containing |
28 // |serialized_payload|. | 29 // |serialized_payload|. |
29 bool WritePolicyFile(const base::FilePath& policy_path, | 30 bool WritePolicyFile(const base::FilePath& policy_path, |
30 const std::string& serialized_payload, | 31 const std::string& serialized_payload, |
31 const std::string& policy_type) { | 32 const std::string& policy_type) { |
(...skipping 26 matching lines...) Expand all Loading... |
58 FakeAuthPolicyClient::FakeAuthPolicyClient() {} | 59 FakeAuthPolicyClient::FakeAuthPolicyClient() {} |
59 | 60 |
60 FakeAuthPolicyClient::~FakeAuthPolicyClient() {} | 61 FakeAuthPolicyClient::~FakeAuthPolicyClient() {} |
61 | 62 |
62 void FakeAuthPolicyClient::Init(dbus::Bus* bus) {} | 63 void FakeAuthPolicyClient::Init(dbus::Bus* bus) {} |
63 | 64 |
64 void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, | 65 void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, |
65 const std::string& user_principal_name, | 66 const std::string& user_principal_name, |
66 int password_fd, | 67 int password_fd, |
67 const JoinCallback& callback) { | 68 const JoinCallback& callback) { |
68 callback.Run(authpolicy::types::AD_JOIN_ERROR_NONE); | 69 callback.Run(authpolicy::ERROR_NONE); |
69 } | 70 } |
70 | 71 |
71 void FakeAuthPolicyClient::AuthenticateUser( | 72 void FakeAuthPolicyClient::AuthenticateUser( |
72 const std::string& user_principal_name, | 73 const std::string& user_principal_name, |
73 int password_fd, | 74 int password_fd, |
74 const AuthCallback& callback) { | 75 const AuthCallback& callback) { |
75 callback.Run(authpolicy::AUTH_USER_ERROR_NONE, | 76 callback.Run(authpolicy::ERROR_NONE, base::MD5String(user_principal_name)); |
76 base::MD5String(user_principal_name)); | |
77 } | 77 } |
78 | 78 |
79 void FakeAuthPolicyClient::RefreshDevicePolicy( | 79 void FakeAuthPolicyClient::RefreshDevicePolicy( |
80 const RefreshPolicyCallback& callback) { | 80 const RefreshPolicyCallback& callback) { |
81 base::FilePath policy_path; | 81 base::FilePath policy_path; |
82 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &policy_path)) { | 82 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &policy_path)) { |
83 callback.Run(false); | 83 callback.Run(false); |
84 return; | 84 return; |
85 } | 85 } |
86 policy_path = policy_path.DirName().AppendASCII("stub_device_policy"); | 86 policy_path = policy_path.DirName().AppendASCII("stub_device_policy"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (!base::PostTaskAndReplyWithResult( | 122 if (!base::PostTaskAndReplyWithResult( |
123 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), | 123 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), |
124 FROM_HERE, base::Bind(&WritePolicyFile, policy_path, payload, | 124 FROM_HERE, base::Bind(&WritePolicyFile, policy_path, payload, |
125 "google/chromeos/user"), | 125 "google/chromeos/user"), |
126 callback)) { | 126 callback)) { |
127 callback.Run(false); | 127 callback.Run(false); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 } // namespace chromeos | 131 } // namespace chromeos |
OLD | NEW |