Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/chromeos/attestation/attestation_policy_observer.h

Issue 12556004: Created AttestationPolicyObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_
6 #define CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/public/browser/notification_observer.h"
14
15 namespace policy {
16 class CloudPolicyClient;
17 }
18
19 namespace chromeos {
20
21 class CrosSettings;
22 class CryptohomeClient;
23
24 namespace attestation {
25
26 class AttestationFlow;
27
28 // A class which observes policy changes and triggers device attestation work if
29 // necessary.
30 class AttestationPolicyObserver : public content::NotificationObserver {
31 public:
32 // The observer immediately connects with CrosSettings to listen for policy
33 // changes. The CloudPolicyClient is used to upload the device certificate to
34 // the server if one is created in response to policy changes; it must be in
35 // the registered state. This class does not take ownership of
36 // |policy_client|.
37 explicit AttestationPolicyObserver(policy::CloudPolicyClient* policy_client);
38
39 // A constructor which allows custom CryptohomeClient and AttestationFlow
40 // implementations. Useful for testing.
41 AttestationPolicyObserver(policy::CloudPolicyClient* policy_client,
42 CryptohomeClient* cryptohome_client,
43 AttestationFlow* attestation_flow);
44
45 virtual ~AttestationPolicyObserver();
46
47 // content::NotificationObserver:
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE;
51
52 private:
53 static const char kEnterpriseMachineKey[];
54
55 // Checks attestation policy and starts any necessary work.
56 void Start();
57
58 // Gets a new certificate for the Enterprise Machine Key (EMK).
59 void GetNewCertificate();
60
61 // Gets the existing EMK certificate and sends it to CheckCertificateExpiry.
62 void GetExistingCertificate();
63
64 // Checks if the given certificate is expired and, if so, get a new one.
65 void CheckCertificateExpiry(const std::string& certificate);
66
67 // Uploads a certificate to the policy server.
68 void UploadCertificate(const std::string& certificate);
69
70 // Checks if a certificate has already been uploaded and, if not, upload.
71 void CheckIfUploaded(const std::string& certificate);
72
73 base::WeakPtrFactory<AttestationPolicyObserver> weak_factory_;
74 CrosSettings* cros_settings_;
75 policy::CloudPolicyClient* policy_client_;
76 CryptohomeClient* cryptohome_client_;
77 AttestationFlow* attestation_flow_;
78 scoped_ptr<AttestationFlow> default_attestation_flow_;
79
80 DISALLOW_COPY_AND_ASSIGN(AttestationPolicyObserver);
81 };
82
83 } // namespace attestation
84 } // namespace chromeos
85
86 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698