2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.daikin.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.eclipse.jetty.client.HttpClient;
18 import org.eclipse.jetty.util.ssl.SslContextFactory;
19 import org.openhab.core.io.net.http.HttpClientFactory;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
23 import org.osgi.service.component.annotations.Reference;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * Factory class to create Jetty web clients
30 * Some Daikin controllers communicate via https using a custom common name,
31 * and they are accessed using an ip address.
33 * The core HttpClientFactory creates a HttpClient that will fail because of this.
34 * This factory creates a HttpClient with SslContextFactory(true)
35 * which will accept any ssl certificate without checking for common name mismatches.
37 * @author Jimmy Tanagra - Initial contribution
41 public class DaikinHttpClientFactoryImpl implements DaikinHttpClientFactory {
43 private final Logger logger = LoggerFactory.getLogger(DaikinHttpClientFactoryImpl.class);
45 private HttpClient httpClient;
48 public DaikinHttpClientFactoryImpl(@Reference HttpClientFactory httpClientFactory) {
49 this.httpClient = httpClientFactory.createHttpClient(DaikinBindingConstants.BINDING_ID,
50 new SslContextFactory.Client(true));
53 logger.debug("Daikin http client started");
54 } catch (Exception e) {
55 logger.warn("Could not start Daikin http client", e);
60 protected void deactivate() {
63 logger.debug("Daikin http client stopped");
64 } catch (Exception e) {
65 logger.debug("error while stopping Daikin http client", e);
70 public @Nullable HttpClient getHttpClient() {