2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.util;
21 import java.net.CookieManager;
22 import java.net.CookieStore;
23 import java.net.HttpCookie;
25 import java.util.Collections;
26 import java.util.List;
29 * Implementation of {@link CookieStore} that delegates to an instance created by {@link CookieManager}
30 * via {@link CookieManager#getCookieStore()}.
32 public class HttpCookieStore implements CookieStore
34 private final CookieStore delegate;
36 public HttpCookieStore()
38 delegate = new CookieManager().getCookieStore();
42 public void add(URI uri, HttpCookie cookie)
44 delegate.add(uri, cookie);
48 public List<HttpCookie> get(URI uri)
50 return delegate.get(uri);
54 public List<HttpCookie> getCookies()
56 return delegate.getCookies();
60 public List<URI> getURIs()
62 return delegate.getURIs();
66 public boolean remove(URI uri, HttpCookie cookie)
68 return delegate.remove(uri, cookie);
72 public boolean removeAll()
74 return delegate.removeAll();
77 public static class Empty implements CookieStore
80 public void add(URI uri, HttpCookie cookie)
85 public List<HttpCookie> get(URI uri)
87 return Collections.emptyList();
91 public List<HttpCookie> getCookies()
93 return Collections.emptyList();
97 public List<URI> getURIs()
99 return Collections.emptyList();
103 public boolean remove(URI uri, HttpCookie cookie)
109 public boolean removeAll()