OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // TODO(dkrahn): Clean up this private API once all clients have been migrated | 5 // TODO(dkrahn): Clean up this private API once all clients have been migrated |
6 // to use the public API. crbug.com/588339. | 6 // to use the public API. crbug.com/588339. |
7 | 7 |
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_PRIVATE_ENTERPRIS
E_PLATFORM_KEYS_PRIVATE_API_H__ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_PRIVATE_ENTERPRIS
E_PLATFORM_KEYS_PRIVATE_API_H__ |
9 #define CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_PRIVATE_ENTERPRIS
E_PLATFORM_KEYS_PRIVATE_API_H__ | 9 #define CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_PRIVATE_ENTERPRIS
E_PLATFORM_KEYS_PRIVATE_API_H__ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "chrome/common/extensions/api/enterprise_platform_keys_private.h" | 16 #include "chrome/common/extensions/api/enterprise_platform_keys_private.h" |
17 #include "chromeos/attestation/attestation_constants.h" | 17 #include "chromeos/attestation/attestation_constants.h" |
18 #include "chromeos/attestation/attestation_flow.h" | 18 #include "chromeos/attestation/attestation_flow.h" |
19 #include "chromeos/dbus/cryptohome_client.h" | 19 #include "chromeos/dbus/cryptohome_client.h" |
20 #include "chromeos/dbus/dbus_method_call_status.h" | 20 #include "chromeos/dbus/dbus_method_call_status.h" |
21 #include "components/signin/core/account_id/account_id.h" | 21 #include "components/signin/core/account_id/account_id.h" |
22 #include "extensions/browser/extension_function.h" | 22 #include "extensions/browser/extension_function.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
24 | 24 |
25 class PrefService; | 25 class PrefService; |
26 class Profile; | 26 class Profile; |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 class CryptohomeClient; | 29 class CryptohomeClient; |
| 30 class InstallAttributes; |
30 } | 31 } |
31 | 32 |
32 namespace cryptohome { | 33 namespace cryptohome { |
33 class AsyncMethodCaller; | 34 class AsyncMethodCaller; |
34 } | 35 } |
35 | 36 |
36 namespace policy { | |
37 class EnterpriseInstallAttributes; | |
38 } | |
39 | |
40 namespace user_prefs { | 37 namespace user_prefs { |
41 class PrefRegistrySyncable; | 38 class PrefRegistrySyncable; |
42 } | 39 } |
43 | 40 |
44 namespace extensions { | 41 namespace extensions { |
45 | 42 |
46 // A callback for challenge key operations. If the operation succeeded, | 43 // A callback for challenge key operations. If the operation succeeded, |
47 // |success| is true and |data| is the challenge response. Otherwise, |success| | 44 // |success| is true and |data| is the challenge response. Otherwise, |success| |
48 // is false and |data| is an error message. | 45 // is false and |data| is an error message. |
49 using ChallengeKeyCallback = | 46 using ChallengeKeyCallback = |
(...skipping 15 matching lines...) Expand all Loading... |
65 PREPARE_KEY_USER_REJECTED, | 62 PREPARE_KEY_USER_REJECTED, |
66 PREPARE_KEY_GET_CERTIFICATE_FAILED, | 63 PREPARE_KEY_GET_CERTIFICATE_FAILED, |
67 PREPARE_KEY_RESET_REQUIRED | 64 PREPARE_KEY_RESET_REQUIRED |
68 }; | 65 }; |
69 | 66 |
70 EPKPChallengeKeyBase(); | 67 EPKPChallengeKeyBase(); |
71 EPKPChallengeKeyBase( | 68 EPKPChallengeKeyBase( |
72 chromeos::CryptohomeClient* cryptohome_client, | 69 chromeos::CryptohomeClient* cryptohome_client, |
73 cryptohome::AsyncMethodCaller* async_caller, | 70 cryptohome::AsyncMethodCaller* async_caller, |
74 chromeos::attestation::AttestationFlow* attestation_flow, | 71 chromeos::attestation::AttestationFlow* attestation_flow, |
75 policy::EnterpriseInstallAttributes* install_attributes); | 72 chromeos::InstallAttributes* install_attributes); |
76 virtual ~EPKPChallengeKeyBase(); | 73 virtual ~EPKPChallengeKeyBase(); |
77 | 74 |
78 // Returns a trusted value from CroSettings indicating if the device | 75 // Returns a trusted value from CroSettings indicating if the device |
79 // attestation is enabled. | 76 // attestation is enabled. |
80 void GetDeviceAttestationEnabled( | 77 void GetDeviceAttestationEnabled( |
81 const base::Callback<void(bool)>& callback) const; | 78 const base::Callback<void(bool)>& callback) const; |
82 | 79 |
83 // Returns true if the device is enterprise managed. | 80 // Returns true if the device is enterprise managed. |
84 bool IsEnterpriseDevice() const; | 81 bool IsEnterpriseDevice() const; |
85 | 82 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 bool result); | 151 bool result); |
155 void AskForUserConsent(const base::Callback<void(bool)>& callback) const; | 152 void AskForUserConsent(const base::Callback<void(bool)>& callback) const; |
156 void AskForUserConsentCallback( | 153 void AskForUserConsentCallback( |
157 const PrepareKeyContext& context, | 154 const PrepareKeyContext& context, |
158 bool result); | 155 bool result); |
159 void GetCertificateCallback( | 156 void GetCertificateCallback( |
160 const base::Callback<void(PrepareKeyResult)>& callback, | 157 const base::Callback<void(PrepareKeyResult)>& callback, |
161 bool success, | 158 bool success, |
162 const std::string& pem_certificate_chain); | 159 const std::string& pem_certificate_chain); |
163 | 160 |
164 policy::EnterpriseInstallAttributes* install_attributes_; | 161 chromeos::InstallAttributes* install_attributes_; |
165 }; | 162 }; |
166 | 163 |
167 class EPKPChallengeMachineKey : public EPKPChallengeKeyBase { | 164 class EPKPChallengeMachineKey : public EPKPChallengeKeyBase { |
168 public: | 165 public: |
169 static const char kGetCertificateFailedError[]; | 166 static const char kGetCertificateFailedError[]; |
170 static const char kNonEnterpriseDeviceError[]; | 167 static const char kNonEnterpriseDeviceError[]; |
171 | 168 |
172 EPKPChallengeMachineKey(); | 169 EPKPChallengeMachineKey(); |
173 EPKPChallengeMachineKey( | 170 EPKPChallengeMachineKey( |
174 chromeos::CryptohomeClient* cryptohome_client, | 171 chromeos::CryptohomeClient* cryptohome_client, |
175 cryptohome::AsyncMethodCaller* async_caller, | 172 cryptohome::AsyncMethodCaller* async_caller, |
176 chromeos::attestation::AttestationFlow* attestation_flow, | 173 chromeos::attestation::AttestationFlow* attestation_flow, |
177 policy::EnterpriseInstallAttributes* install_attributes); | 174 chromeos::InstallAttributes* install_attributes); |
178 ~EPKPChallengeMachineKey() override; | 175 ~EPKPChallengeMachineKey() override; |
179 | 176 |
180 // Asynchronously run the flow to challenge a machine key in the |caller| | 177 // Asynchronously run the flow to challenge a machine key in the |caller| |
181 // context. | 178 // context. |
182 void Run(scoped_refptr<UIThreadExtensionFunction> caller, | 179 void Run(scoped_refptr<UIThreadExtensionFunction> caller, |
183 const ChallengeKeyCallback& callback, | 180 const ChallengeKeyCallback& callback, |
184 const std::string& encoded_challenge); | 181 const std::string& encoded_challenge); |
185 | 182 |
186 // Like |Run| but expects a Base64 |encoded_challenge|. | 183 // Like |Run| but expects a Base64 |encoded_challenge|. |
187 void DecodeAndRun(scoped_refptr<UIThreadExtensionFunction> caller, | 184 void DecodeAndRun(scoped_refptr<UIThreadExtensionFunction> caller, |
(...skipping 14 matching lines...) Expand all Loading... |
202 public: | 199 public: |
203 static const char kGetCertificateFailedError[]; | 200 static const char kGetCertificateFailedError[]; |
204 static const char kKeyRegistrationFailedError[]; | 201 static const char kKeyRegistrationFailedError[]; |
205 static const char kUserPolicyDisabledError[]; | 202 static const char kUserPolicyDisabledError[]; |
206 | 203 |
207 EPKPChallengeUserKey(); | 204 EPKPChallengeUserKey(); |
208 EPKPChallengeUserKey( | 205 EPKPChallengeUserKey( |
209 chromeos::CryptohomeClient* cryptohome_client, | 206 chromeos::CryptohomeClient* cryptohome_client, |
210 cryptohome::AsyncMethodCaller* async_caller, | 207 cryptohome::AsyncMethodCaller* async_caller, |
211 chromeos::attestation::AttestationFlow* attestation_flow, | 208 chromeos::attestation::AttestationFlow* attestation_flow, |
212 policy::EnterpriseInstallAttributes* install_attributes); | 209 chromeos::InstallAttributes* install_attributes); |
213 ~EPKPChallengeUserKey() override; | 210 ~EPKPChallengeUserKey() override; |
214 | 211 |
215 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 212 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
216 | 213 |
217 // Asynchronously run the flow to challenge a user key in the |caller| | 214 // Asynchronously run the flow to challenge a user key in the |caller| |
218 // context. | 215 // context. |
219 void Run(scoped_refptr<UIThreadExtensionFunction> caller, | 216 void Run(scoped_refptr<UIThreadExtensionFunction> caller, |
220 const ChallengeKeyCallback& callback, | 217 const ChallengeKeyCallback& callback, |
221 const std::string& challenge, | 218 const std::string& challenge, |
222 bool register_key); | 219 bool register_key); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 EPKPChallengeUserKey* impl_; | 288 EPKPChallengeUserKey* impl_; |
292 | 289 |
293 DECLARE_EXTENSION_FUNCTION( | 290 DECLARE_EXTENSION_FUNCTION( |
294 "enterprise.platformKeysPrivate.challengeUserKey", | 291 "enterprise.platformKeysPrivate.challengeUserKey", |
295 ENTERPRISE_PLATFORMKEYSPRIVATE_CHALLENGEUSERKEY); | 292 ENTERPRISE_PLATFORMKEYSPRIVATE_CHALLENGEUSERKEY); |
296 }; | 293 }; |
297 | 294 |
298 } // namespace extensions | 295 } // namespace extensions |
299 | 296 |
300 #endif // CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_PRIVATE_ENTERP
RISE_PLATFORM_KEYS_PRIVATE_API_H__ | 297 #endif // CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_PRIVATE_ENTERP
RISE_PLATFORM_KEYS_PRIVATE_API_H__ |
OLD | NEW |