forked from libapps/libapps-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh_policy.js
More file actions
82 lines (74 loc) · 1.93 KB
/
ssh_policy.js
File metadata and controls
82 lines (74 loc) · 1.93 KB
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
// Copyright 2025 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Manages SSH policy configurations, including SSH known hosts
* and SSH config.
* Provides methods for creating from json object, getters and setters.
* This class is designed to work with plain JavaScript objects and a binary
* (Protobuf-like) format.
* This conforms with /proto/ssh_policy.proto
*/
/**
* Manages SSH policy configurations.
*/
export class SshPolicy {
/**
* Initializes the policy with default empty values.
* @param {{
* sshKnownHosts: (string|undefined),
* sshConfig: (string|undefined)
* }=} options The options object.
*/
constructor({
sshKnownHosts = '',
sshConfig = '',
} = {}) {
/** @private {string} */
this.sshKnownHosts_ = sshKnownHosts;
/** @private {string} */
this.sshConfig_ = sshConfig;
}
/**
* @return {string} The SSH known hosts.
*/
getSshKnownHosts() {
return this.sshKnownHosts_;
}
/**
* @param {string} value The new SSH known hosts.
* @return {!SshPolicy} This instance for chaining.
*/
setSshKnownHosts(value) {
this.sshKnownHosts_ = value;
return this;
}
/**
* @return {string} The SSH config.
*/
getSshConfig() {
return this.sshConfig_;
}
/**
* @param {string} value The new SSH config.
* @return {!SshPolicy} This instance for chaining.
*/
setSshConfig(value) {
this.sshConfig_ = value;
return this;
}
/**
* Creates an SshPolicy instance from a plain object.
* @param {?{
* sshKnownHosts: (string|undefined),
* sshConfig: (string|undefined)
* }=} obj The object to create the policy from.
* @return {!SshPolicy} A new SshPolicy instance.
*/
static from(obj) {
return new SshPolicy({
sshKnownHosts: obj?.sshKnownHosts ?? '',
sshConfig: obj?.sshConfig ?? '',
});
}
}