test/jdk/sun/net/www/protocol/http/B5017051.java
author chegar
Thu, 17 Oct 2019 20:53:35 +0100
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 47216 71c04702a3d5
permissions -rw-r--r--
datagramsocketimpl-branch: update to default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
     2
 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 5017051 6360774
38557
5c485e1ea6fa 8157635: Fix module dependencies for /sun/* tests
jjiang
parents: 5506
diff changeset
    27
 * @modules jdk.httpserver
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    28
 * @library /test/lib
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @run main/othervm B5017051
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    30
 * @run main/othervm -Djava.net.preferIPv6Addresses=true B5017051
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @summary Tests CR 5017051 & 6360774
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.net.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.net.httpserver.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.concurrent.Executors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.concurrent.ExecutorService;
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    40
import jdk.test.lib.net.URIBuilder;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Part 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *  First request sent to the http server will not have an "Authorization" header set and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *  the server will respond with a 401, but not until it has set a cookie in the response
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *  headers. The subsequent request ( comes from HttpURLConnection's authentication retry )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *  will have the appropriate Authorization header and the servers context handler will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *  invoked. The test passes only if the client (HttpURLConnection) has sent the cookie
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *  in its second request that had been set via the first response from the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Part 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *  Preload the CookieManager with a cookie. Make a http request that requires authentication
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *  The cookie will be sent in the first request (without the Authorization header), the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *  server will respond with a 401 (from MyBasicAuthFilter) and the client will add the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *  appropriate Authorization header. This tests ensures that there is only one Cookie header
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *  in the request that actually makes it to the Http servers context handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public class B5017051
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
{
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    61
    HttpServer httpServer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    ExecutorService executorService;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    64
    public static void main(String[] args) throws Exception {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        new B5017051();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    68
    public B5017051() throws Exception {
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    69
        startHttpServer();
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    70
        doClient();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    73
    void doClient() throws Exception {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        java.net.Authenticator.setDefault(new MyAuthenticator());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    76
        ProxySelector.setDefault(ProxySelector.of(null));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            InetSocketAddress address = httpServer.getAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            // Part 1
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    82
            URL url = URIBuilder.newBuilder()
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    83
                .scheme("http")
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    84
                .host(address.getAddress())
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    85
                .port(address.getPort())
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    86
                .path("/test/")
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    87
                .toURL();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            HttpURLConnection uc = (HttpURLConnection)url.openConnection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            int resp = uc.getResponseCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            if (resp != 200)
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    91
                throw new RuntimeException("Failed: Part 1, Response code is not 200: " + resp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            System.out.println("Response code from Part 1 = 200 OK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            // Part 2
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    96
            URL url2 = URIBuilder.newBuilder()
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    97
                .scheme("http")
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    98
                .host(address.getAddress())
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
    99
                .port(address.getPort())
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
   100
                .path("/test2/")
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
   101
                .toURL();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            // can use the global CookieHandler used for the first test as the URL's are different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            CookieHandler ch = CookieHandler.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            Map<String,List<String>> header = new HashMap<String,List<String>>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            List<String> values = new LinkedList<String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            values.add("Test2Cookie=\"TEST2\"; path=\"/test2/\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            header.put("Set-Cookie2", values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            // preload the CookieHandler with a cookie for our URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            // so that it will be sent during the first request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            ch.put(url2.toURI(), header);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            uc = (HttpURLConnection)url2.openConnection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            resp = uc.getResponseCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            if (resp != 200)
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
   117
                throw new RuntimeException("Failed: Part 2, Response code is not 200: " + resp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            System.out.println("Response code from Part 2 = 200 OK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            httpServer.stop(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            executorService.shutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Http Server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public void startHttpServer() throws IOException {
58678
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
   131
        InetAddress loopback = InetAddress.getLoopbackAddress();
9cf78a70fa4f datagramsocketimpl-branch: update to default
chegar
parents: 47216
diff changeset
   132
        httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        // create HttpServer context for Part 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        HttpContext ctx = httpServer.createContext("/test/", new MyHandler());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        ctx.setAuthenticator( new MyBasicAuthenticator("foo"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        // CookieFilter needs to be executed before Authenticator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        ctx.getFilters().add(0, new CookieFilter());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // create HttpServer context for Part 2.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        HttpContext ctx2 = httpServer.createContext("/test2/", new MyHandler2());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        ctx2.setAuthenticator( new MyBasicAuthenticator("foobar"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        executorService = Executors.newCachedThreadPool();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        httpServer.setExecutor(executorService);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        httpServer.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    class MyHandler implements HttpHandler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        public void handle(HttpExchange t) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            InputStream is = t.getRequestBody();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            Headers reqHeaders = t.getRequestHeaders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            Headers resHeaders = t.getResponseHeaders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            while (is.read () != -1) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            is.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            if (!reqHeaders.containsKey("Authorization"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                t.sendResponseHeaders(400, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            List<String> cookies = reqHeaders.get("Cookie");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            if (cookies != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                for (String str : cookies) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    if (str.equals("Customer=WILE_E_COYOTE"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                        t.sendResponseHeaders(200, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            t.sendResponseHeaders(400, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    class MyHandler2 implements HttpHandler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        public void handle(HttpExchange t) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            InputStream is = t.getRequestBody();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            Headers reqHeaders = t.getRequestHeaders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            Headers resHeaders = t.getResponseHeaders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            while (is.read () != -1) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            is.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            if (!reqHeaders.containsKey("Authorization"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                t.sendResponseHeaders(400, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            List<String> cookies = reqHeaders.get("Cookie");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            // there should only be one Cookie header
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            if (cookies != null && (cookies.size() == 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                t.sendResponseHeaders(200, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            t.sendResponseHeaders(400, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    class MyAuthenticator extends java.net.Authenticator {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        public PasswordAuthentication getPasswordAuthentication () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            return new PasswordAuthentication("tester", "passwd".toCharArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    class MyBasicAuthenticator extends BasicAuthenticator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        public MyBasicAuthenticator(String realm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            super(realm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        public boolean checkCredentials (String username, String password) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return username.equals("tester") && password.equals("passwd");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    class CookieFilter extends Filter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        public void doFilter(HttpExchange t, Chain chain) throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            Headers resHeaders = t.getResponseHeaders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            Headers reqHeaders = t.getRequestHeaders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            if (!reqHeaders.containsKey("Authorization"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                resHeaders.set("Set-Cookie2", "Customer=\"WILE_E_COYOTE\"; path=\"/test/\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            chain.doFilter(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        public void destroy(HttpContext c) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        public void init(HttpContext c) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        public String description() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            return new String("Filter for setting a cookie for requests without an \"Authorization\" header.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
}