File: rollback_onc_util.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; 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,811; 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 (105 lines) | stat: -rw-r--r-- 4,400 bytes parent folder | download | duplicates (6)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2021 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_BROWSER_ASH_NET_ROLLBACK_NETWORK_CONFIG_ROLLBACK_ONC_UTIL_H_
#define CHROME_BROWSER_ASH_NET_ROLLBACK_NETWORK_CONFIG_ROLLBACK_ONC_UTIL_H_

#include "base/values.h"

// Rollback-specific functions for managed and non-managed onc configurations
// of wifi and ethernet. These functions do not validate the onc format. To be
// used only with validated input, e.g. configurations coming from Chrome.
// Look for onc_spec.md for documentation of the onc format.
namespace ash::rollback_network_config {

// Returns the value of the given key. This will crash if string value can not
// be found.
std::string GetStringValue(const base::Value::Dict& network,
                           const std::string& key);

// Returns the value of the given key. This will crash if bool value can not be
// found.
bool GetBoolValue(const base::Value::Dict& network, const std::string& key);

// Managed ONC

// Collapses a managed onc dictionary to the values that are marked as active
// configuration. Values that are not split into managed dictionaries are kept.
void ManagedOncCollapseToActive(base::Value* network);

// Collapses a managed onc dictionary to the values that are marked as shared
// setting. Values that are not split into managed dictionaries are discarded.
// This results in the part that shill saves as UI data for the given managed
// network.
void ManagedOncCollapseToUiData(base::Value* network);

// Sets the PSK password of a managed onc dictionary as device or policy
// configured, depending on the source of the network.
void ManagedOncWiFiSetPskPassword(base::Value::Dict* network,
                                  const std::string& password);
// Sets the EAP password of a managed onc dictionary as device or policy
// configured, depending on the source of the network.
void ManagedOncSetEapPassword(base::Value::Dict* network,
                              const std::string& password);

// ONC

bool OncIsWiFi(const base::Value::Dict& network);
bool OncIsEthernet(const base::Value::Dict& network);

bool OncIsSourceDevicePolicy(const base::Value::Dict& network);
bool OncIsSourceDevice(const base::Value::Dict& network);

bool OncHasNoSecurity(const base::Value::Dict& network);

// Returns true if the given network is of a type that would require an EAP
// entry.
bool OncIsEap(const base::Value::Dict& network);

// Returns true if the given dictionary has an EAP entry.
bool OncHasEapConfiguration(const base::Value::Dict& network);

// Returns true if the given network is an EAP network and is of a type that
// does not require a client certificate.
bool OncIsEapWithoutClientCertificate(const base::Value::Dict& network);

// ONC>EAP
// The following functions only succeed if called on a dictionary containing
// an EAP entry within a wifi or ethernet entry.

std::string OncGetEapIdentity(const base::Value::Dict& network);
std::string OncGetEapInner(const base::Value::Dict& network);
std::string OncGetEapOuter(const base::Value::Dict& network);
bool OncGetEapSaveCredentials(const base::Value::Dict& network);
std::string OncGetEapPassword(const base::Value::Dict& network);
std::string OncGetEapClientCertType(const base::Value::Dict& network);
std::string OncGetEapClientCertPKCS11Id(const base::Value::Dict& network);

// Returns true if the given EAP wifi or ethernet is of a type that may require
// a client certificate.
bool OncEapRequiresClientCertificate(const base::Value::Dict& network);

void OncSetEapPassword(base::Value::Dict* network, const std::string& password);

// ONC>WiFi
// The following functions only succeed if called on a dictionary containing
// a wifi entry.

std::string OncWiFiGetSecurity(const base::Value::Dict& network);
std::string OncWiFiGetPassword(const base::Value::Dict& network);

bool OncWiFiIsPsk(const base::Value::Dict& network);

void OncWiFiSetPskPassword(base::Value::Dict* network,
                           const std::string& password);

// ONC>Ethernet
// The following functions only succeed if called on a dictionary containing
// an ethernet entry.

std::string OncEthernetGetAuthentication(const base::Value::Dict& network);

}  // namespace ash::rollback_network_config

#endif  // CHROME_BROWSER_ASH_NET_ROLLBACK_NETWORK_CONFIG_ROLLBACK_ONC_UTIL_H_