2 * Copyright (c) 2010-2020 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.linky.internal.handler;
15 import java.util.ArrayList;
16 import java.util.List;
18 import okhttp3.Cookie;
19 import okhttp3.CookieJar;
20 import okhttp3.HttpUrl;
23 * The {@link LinkyCookieJar} is responsible to holds cookies
26 * @author Gaƫl L'hopital - Initial contribution
28 public class LinkyCookieJar implements CookieJar {
30 private static final String LOGIN_URL_PATH = "/auth/UI/Login";
32 private List<Cookie> cookies = new ArrayList<>();
35 public void saveFromResponse(final HttpUrl url, final List<Cookie> cookies) {
36 this.cookies.addAll(cookies);
40 public List<Cookie> loadForRequest(final HttpUrl url) {
41 if (LOGIN_URL_PATH.equals(url.url().getPath())) {
42 cookies = new ArrayList<>();