1 package org.metricshub.ipmi.client;
2
3 /*-
4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5 * IPMI Java Client
6 * ჻჻჻჻჻჻
7 * Copyright 2023 MetricsHub
8 * ჻჻჻჻჻჻
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
23 */
24
25 /**
26 * IPMI configuration including the required credentials that need to be used to establish the
27 * communication with the IPMI interface.
28 *
29 */
30 public class IpmiClientConfiguration {
31
32 private String hostname;
33 private String username;
34 private char[] password;
35 private byte[] bmcKey;
36 private boolean skipAuth;
37 private long timeout;
38 private long pingPeriod = -1;
39
40 /**
41 * Instantiates a new {@link IpmiClientConfiguration} in order to query the IPMI host.
42 *
43 * @param hostname IP Address or host name of the remote IPMI host.
44 * @param username Name used to establish the connection with the host via the IPMI protocol.
45 * @param password Password used to establish the connection with the host via the IPMI protocol.
46 * @param bmcKey The key that should be provided if the two-key authentication is enabled, null otherwise.
47 * @param skipAuth Whether the client should skip authentication
48 * @param timeout Timeout used for each IPMI request.
49 */
50 public IpmiClientConfiguration(String hostname, String username, char[] password,
51 byte[] bmcKey, boolean skipAuth, long timeout) {
52 this.hostname = hostname;
53 this.username = username;
54 this.password = password;
55 this.bmcKey = bmcKey;
56 this.skipAuth = skipAuth;
57 this.timeout = timeout;
58 }
59
60 /**
61 * Instantiates a new {@link IpmiClientConfiguration} in order to query the IPMI host.
62 *
63 * @param hostname IP Address or host name of the remote IPMI host.
64 * @param username Name used to establish the connection with the host via the IPMI protocol.
65 * @param password Password used to establish the connection with the host via the IPMI protocol.
66 * @param bmcKey The key that should be provided if the two-key authentication is enabled, null otherwise.
67 * @param skipAuth Whether the client should skip authentication
68 * @param timeout Timeout used for each IPMI request.
69 * @param pingPeriod The period in milliseconds used to send the keep alive messages.<br>
70 * Set pingPeriod to 0 to turn off keep-alive messages sent to the remote host.
71 */
72 public IpmiClientConfiguration(String hostname, String username, char[] password,
73 byte[] bmcKey, boolean skipAuth, long timeout, long pingPeriod) {
74 this(hostname, username, password, bmcKey, skipAuth, timeout);
75 this.pingPeriod = pingPeriod;
76 }
77
78 /**
79 * Returns the IP Address or host name of the remote IPMI host.
80 *
81 * @return IP Address or host name of the remote IPMI host.
82 */
83 public String getHostname() {
84 return hostname;
85 }
86
87 /**
88 * Sets the IP Address or host name of the remote IPMI host.
89 *
90 * @param hostname IP Address or host name of the remote IPMI host.
91 */
92 public void setHostname(String hostname) {
93 this.hostname = hostname;
94 }
95
96 /**
97 * Returns the name used to establish the connection with the host via the IPMI
98 * protocol.
99 *
100 * @return Name used to establish the connection with the host via the IPMI protocol.
101 */
102 public String getUsername() {
103 return username;
104 }
105
106 /**
107 * Sets the name used to establish the connection with the host via the IPMI
108 * protocol.
109 *
110 * @param username Name used to establish the connection with the host via the
111 * IPMI protocol.
112 */
113 public void setUsername(String username) {
114 this.username = username;
115 }
116
117 /**
118 * Returns the password used to establish the connection with the host via the
119 * IPMI protocol.
120 *
121 * @return Password used to establish the connection with the host via the IPMI protocol.
122 */
123 public char[] getPassword() {
124 return password;
125 }
126
127 /**
128 * Sets the password used to establish the connection with the host via the IPMI
129 * protocol.
130 *
131 * @param password Password used to establish the connection with the host via the IPMI protocol.
132 */
133 public void setPassword(char[] password) {
134 this.password = password;
135 }
136
137 /**
138 * Returns the key that should be provided if the two-key authentication is
139 * enabled, null otherwise.
140 *
141 * @return The key that should be provided if the two-key authentication is
142 * enabled, null otherwise.
143 */
144 public byte[] getBmcKey() {
145 return bmcKey;
146 }
147
148 /**
149 * Sets the key that should be provided if the two-key authentication is
150 * enabled, null otherwise.
151 *
152 * @param bmcKey The key that should be provided if the two-key authentication
153 * is enabled, null otherwise.
154 */
155 public void setBmcKey(byte[] bmcKey) {
156 this.bmcKey = bmcKey;
157 }
158
159 /**
160 * Returns whether the client should skip authentication.
161 *
162 * @return Whether the client should skip authentication.
163 */
164 public boolean isSkipAuth() {
165 return skipAuth;
166 }
167
168 /**
169 * Sets whether the client should skip authentication.
170 *
171 * @param skipAuth Whether the client should skip authentication.
172 */
173 public void setSkipAuth(boolean skipAuth) {
174 this.skipAuth = skipAuth;
175 }
176
177 /**
178 * Returns the timeout used for each IPMI request.
179 *
180 * @return The timeout used for each IPMI request.
181 */
182 public long getTimeout() {
183 return timeout;
184 }
185
186 /**
187 * Sets the timeout used for each IPMI request.
188 *
189 * @param timeout The timeout used for each IPMI request.
190 */
191 public void setTimeout(long timeout) {
192 this.timeout = timeout;
193 }
194
195 /**
196 * Returns the period in milliseconds used to send the keep alive messages.
197 *
198 * @return The period in milliseconds used to send the keep alive messages.
199 */
200 public long getPingPeriod() {
201 return pingPeriod;
202 }
203
204 /**
205 * Sets the period in milliseconds used to send the keep alive messages.<br>
206 * Set pingPeriod to 0 to turn off keep-alive messages sent to the remote host.
207 *
208 * @param pingPeriod The period in milliseconds used to send the keep alive messages.
209 */
210 public void setPingPeriod(long pingPeriod) {
211 this.pingPeriod = pingPeriod;
212 }
213
214 }