File: dm_message.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (68 lines) | stat: -rw-r--r-- 2,775 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_UPDATER_DEVICE_MANAGEMENT_DM_MESSAGE_H_
#define CHROME_UPDATER_DEVICE_MANAGEMENT_DM_MESSAGE_H_

#include <string>
#include <vector>

#include "base/containers/flat_map.h"
#include "chrome/enterprise_companion/device_management_storage/dm_storage.h"

namespace policy {
enum class PolicyFetchReason;
}  // namespace policy

namespace updater {

class CachedPolicyInfo;
struct PolicyValidationResult;

// DM policy map: policy_type --> serialized policy data of PolicyFetchResponse.
using DMPolicyMap = base::flat_map<std::string, std::string>;

// The policy type for Omaha policy settings.
inline constexpr char kGoogleUpdatePolicyType[] = "google/machine-level-omaha";

// Returns the serialized data from a DeviceManagementRequest, which wraps
// a RegisterBrowserRequest, to register the current device.
std::string GetRegisterBrowserRequestData();

// Returns the serialized data from a DeviceManagementRequest, which wraps
// a PolicyFetchRequest, to fetch policies for the given type.
std::string GetPolicyFetchRequestData(
    policy::PolicyFetchReason reason,
    const std::string& policy_type,
    const device_management_storage::CachedPolicyInfo& policy_info);

// Returns the serialized data from a DeviceManagementRequest, which wraps
// a PolicyValidationReportRequest, to report possible policy validation errors.
std::string GetPolicyValidationReportRequestData(
    const PolicyValidationResult& validation_result);

// Parses the DeviceManagementResponse for a device registration request, and
// returns the DM token. Returns empty string if parsing failed or the response
// is unexpected.
std::string ParseDeviceRegistrationResponse(const std::string& response_data);

// Determines whether the DMToken is expected to be deleted based on the
// DMServer response contents.
bool ShouldDeleteDmToken(const std::string& response_data);

// Parses and validates the DeviceManagementResponse for a policy fetch request,
// and returns valid policies in the DMPolicyMap. All validation issues will be
// put into the `validation_results`, if there's any. `policy_info`,
// `expected_dm_token`, `expected_device_id` are used for validation, to check
// response's the signatures and whether it is intended for current device.
DMPolicyMap ParsePolicyFetchResponse(
    const std::string& response_data,
    const device_management_storage::CachedPolicyInfo& policy_info,
    const std::string& expected_dm_token,
    const std::string& expected_device_id,
    std::vector<PolicyValidationResult>& validation_results);

}  // namespace updater

#endif  // CHROME_UPDATER_DEVICE_MANAGEMENT_DM_MESSAGE_H_