/*
 *     Copyright (C) 2015 ASIP Santé
 */
package fr.asipsante.mss.connectkit.connection;

import java.net.CookiePolicy;
import java.net.HttpCookie;
import java.net.URI;
import java.util.List;

/**
 * Filtre d'extraction des cookies d'une connexion par leur nom.
 * 
 * @author ASIP Santé
 *
 */
public final class JsessionIdSearchCookiePolicy implements CookiePolicy {
    private List<String> targetList;

    public JsessionIdSearchCookiePolicy(List<String> targets) {
        this.targetList = targets;
    }

    public boolean shouldAccept(URI uri, HttpCookie cookie) {
        if (targetList.contains(cookie.getName())) {
            return true;
        } else {
            return false;
        }
    }
}