// Path: src/main/java/com/bwssystems/HABridge/NamedIP.java
// public class NamedIP {
// 	private String name;
// 	private String ip;
// 	private String webhook;
// 	private String port;
// 	private String username;
// 	private String password;
// 	private JsonObject extensions;
// 	private Boolean secure;
// 	private String httpPreamble;
// 	private String encodedLogin;
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getIp() {
// 		return ip;
// 	}
// 
// 	public void setIp(String ip) {
// 		this.ip = ip;
// 	}
// 
// 	public String getWebhook() {
// 		return webhook;
// 	}
// 
// 	public void setWebhook(final String webhook) {
// 		this.webhook = webhook;
// 	}
// 
// 	public String getPort() {
// 		return port;
// 	}
// 
// 	public void setPort(String port) {
// 		this.port = port;
// 	}
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public Boolean getSecure() {
// 		return secure;
// 	}
// 
// 	public void setSecure(Boolean secure) {
// 		this.secure = secure;
// 	}
// 
// 	public JsonObject getExtensions() {
// 		return extensions;
// 	}
// 
// 	public void setExtensions(JsonObject extensions) {
// 		this.extensions = extensions;
// 	}
// 
// 	public String getHttpPreamble() {
// 		if (httpPreamble == null || !httpPreamble.trim().isEmpty()) {
// 			if (getSecure() != null && getSecure())
// 				httpPreamble = "https://";
// 			else
// 				httpPreamble = "http://";
// 
// 			httpPreamble = httpPreamble + getIp();
// 			if (getPort() != null && !getPort().trim().isEmpty()) {
// 				httpPreamble = httpPreamble + ":" + getPort();
// 			}
// 		}
// 		return httpPreamble;
// 	}
// 
// 	public void setHttpPreamble(String httpPreamble) {
// 		this.httpPreamble = httpPreamble;
// 	}
// 
// 	public String getUserPass64() {
// 		if (encodedLogin == null || !encodedLogin.trim().isEmpty()) {
// 			if (getUsername() != null && !getUsername().isEmpty() && getPassword() != null
// 					&& !getPassword().isEmpty()) {
// 				String userPass = getUsername() + ":" + getPassword();
// 				encodedLogin = new String(Base64.encodeBase64(userPass.getBytes()));
// 			}
// 		}
// 
// 		return encodedLogin;
// 	}
// }


import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bwssystems.HABridge.DeviceMapTypes;
import com.bwssystems.HABridge.NamedIP;
import com.bwssystems.HABridge.api.NameValue;

					log.warn(
							"HTTP response code was not an expected successful response of between 200 - 299, the code was: "
									+ response.getStatusLine() + " with the content of <<<" + theContent + ">>>");
					if (response.getStatusLine().getStatusCode() == 504) {
						log.warn("HTTP response code was 504, retrying...");
						log.debug("The 504 error content is <<<" + theContent + ">>>");
						theContent = null;
					} else
						retryCount = 2;
				}

			} catch (ClientProtocolException e) {
				log.warn("Client Protocol Exception received, retyring....");
			} catch (IOException e) {
				log.warn("Error calling out to HA gateway: IOException in log: " + e.getMessage(), e);
				retryCount = 2;
			}

			if (retryCount < 2) {
				theContent = null;
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e1) {
					// noop
				}
			}
		}
		return theContent;
	}


// Path: src/main/java/com/bwssystems/HABridge/NamedIP.java
// public class NamedIP {
// 	private String name;
// 	private String ip;
// 	private String webhook;
// 	private String port;
// 	private String username;
// 	private String password;
// 	private JsonObject extensions;
// 	private Boolean secure;
// 	private String httpPreamble;
// 	private String encodedLogin;
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getIp() {
// 		return ip;
// 	}
// 
// 	public void setIp(String ip) {
// 		this.ip = ip;
// 	}
// 
// 	public String getWebhook() {
// 		return webhook;
// 	}
// 
// 	public void setWebhook(final String webhook) {
// 		this.webhook = webhook;
// 	}
// 
// 	public String getPort() {
// 		return port;
// 	}
// 
// 	public void setPort(String port) {
// 		this.port = port;
// 	}
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public Boolean getSecure() {
// 		return secure;
// 	}
// 
// 	public void setSecure(Boolean secure) {
// 		this.secure = secure;
// 	}
// 
// 	public JsonObject getExtensions() {
// 		return extensions;
// 	}
// 
// 	public void setExtensions(JsonObject extensions) {
// 		this.extensions = extensions;
// 	}
// 
// 	public String getHttpPreamble() {
// 		if (httpPreamble == null || !httpPreamble.trim().isEmpty()) {
// 			if (getSecure() != null && getSecure())
// 				httpPreamble = "https://";
// 			else
// 				httpPreamble = "http://";
// 
// 			httpPreamble = httpPreamble + getIp();
// 			if (getPort() != null && !getPort().trim().isEmpty()) {
// 				httpPreamble = httpPreamble + ":" + getPort();
// 			}
// 		}
// 		return httpPreamble;
// 	}
// 
// 	public void setHttpPreamble(String httpPreamble) {
// 		this.httpPreamble = httpPreamble;
// 	}
// 
// 	public String getUserPass64() {
// 		if (encodedLogin == null || !encodedLogin.trim().isEmpty()) {
// 			if (getUsername() != null && !getUsername().isEmpty() && getPassword() != null
// 					&& !getPassword().isEmpty()) {
// 				String userPass = getUsername() + ":" + getPassword();
// 				encodedLogin = new String(Base64.encodeBase64(userPass.getBytes()));
// 			}
// 		}
// 
// 		return encodedLogin;
// 	}
// }


// Path: src/main/java/com/bwssystems/HABridge/plugins/http/HTTPHandler.java
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bwssystems.HABridge.DeviceMapTypes;
import com.bwssystems.HABridge.NamedIP;
import com.bwssystems.HABridge.api.NameValue;

					log.warn(
							"HTTP response code was not an expected successful response of between 200 - 299, the code was: "
									+ response.getStatusLine() + " with the content of <<<" + theContent + ">>>");
					if (response.getStatusLine().getStatusCode() == 504) {
						log.warn("HTTP response code was 504, retrying...");
						log.debug("The 504 error content is <<<" + theContent + ">>>");
						theContent = null;
					} else
						retryCount = 2;
				}

			} catch (ClientProtocolException e) {
				log.warn("Client Protocol Exception received, retyring....");
			} catch (IOException e) {
				log.warn("Error calling out to HA gateway: IOException in log: " + e.getMessage(), e);
				retryCount = 2;
			}

			if (retryCount < 2) {
				theContent = null;
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e1) {
					// noop
				}
			}
		}
		return theContent;
	}


	public NameValue[] addBasicAuthHeader(NameValue[] theHeaders, NamedIP theTarget) {
