2 * Copyright 2017-2018 Gregory Moyer and contributors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openhab.binding.lametrictime.api.local;
19 import java.net.URISyntaxException;
21 public class LocalConfiguration
24 private String apiKey;
26 private boolean secure = true;
27 private boolean ignoreCertificateValidation = true;
28 private boolean ignoreHostnameValidation = true;
30 private String insecureScheme = "http";
31 private int insecurePort = 8080;
33 private String secureScheme = "https";
34 private int securePort = 4343;
36 private String basePath = "/api/v2";
38 private String authUser = "dev";
40 private boolean logging = false;
41 private String logLevel = "INFO";
42 private int logMax = 104857600; // 100kb
44 public String getHost()
49 public void setHost(String host)
54 public LocalConfiguration withHost(String host)
60 public String getApiKey()
65 public void setApiKey(String apiKey)
70 public LocalConfiguration withApiKey(String apiKey)
76 public boolean isSecure()
81 public void setSecure(boolean secure)
86 public LocalConfiguration withSecure(boolean secure)
92 public boolean isIgnoreCertificateValidation()
94 return ignoreCertificateValidation;
97 public void setIgnoreCertificateValidation(boolean ignoreCertificateValidation)
99 this.ignoreCertificateValidation = ignoreCertificateValidation;
102 public LocalConfiguration withIgnoreCertificateValidation(boolean ignoreCertificateValidation)
104 this.ignoreCertificateValidation = ignoreCertificateValidation;
108 public boolean isIgnoreHostnameValidation()
110 return ignoreHostnameValidation;
113 public void setIgnoreHostnameValidation(boolean ignoreHostnameValidation)
115 this.ignoreHostnameValidation = ignoreHostnameValidation;
118 public LocalConfiguration withIgnoreHostnameValidation(boolean ignoreHostnameValidation)
120 this.ignoreHostnameValidation = ignoreHostnameValidation;
124 public String getInsecureScheme()
126 return insecureScheme;
129 public void setInsecureScheme(String insecureScheme)
131 this.insecureScheme = insecureScheme;
134 public LocalConfiguration withInsecureScheme(String insecureScheme)
136 this.insecureScheme = insecureScheme;
140 public int getInsecurePort()
145 public void setInsecurePort(int insecurePort)
147 this.insecurePort = insecurePort;
150 public LocalConfiguration withInsecurePort(int insecurePort)
152 this.insecurePort = insecurePort;
156 public String getSecureScheme()
161 public void setSecureScheme(String secureScheme)
163 this.secureScheme = secureScheme;
166 public LocalConfiguration withSecureScheme(String secureScheme)
168 this.secureScheme = secureScheme;
172 public int getSecurePort()
177 public void setSecurePort(int securePort)
179 this.securePort = securePort;
182 public LocalConfiguration withSecurePort(int securePort)
184 this.securePort = securePort;
188 public String getBasePath()
193 public void setBasePath(String basePath)
195 this.basePath = basePath;
198 public LocalConfiguration withBasePath(String basePath)
200 this.basePath = basePath;
204 public String getAuthUser()
209 public void setAuthUser(String authUser)
211 this.authUser = authUser;
214 public LocalConfiguration withAuthUser(String authUser)
216 this.authUser = authUser;
220 public boolean isLogging()
225 public void setLogging(boolean logging)
227 this.logging = logging;
230 public LocalConfiguration withLogging(boolean logging)
232 this.logging = logging;
236 public String getLogLevel()
241 public void setLogLevel(String logLevel)
243 this.logLevel = logLevel;
246 public LocalConfiguration withLogLevel(String logLevel)
248 this.logLevel = logLevel;
252 public int getLogMax()
257 public void setLogMax(int logMax)
259 this.logMax = logMax;
262 public LocalConfiguration withLogMax(int logMax)
264 this.logMax = logMax;
268 public URI getBaseUri()
270 String scheme = secure ? secureScheme : insecureScheme;
271 int port = secure ? securePort : insecurePort;
274 return new URI(scheme, null, host, port, basePath, null, null);
276 catch (URISyntaxException e)
278 throw new RuntimeException("Invalid configuration", e);