test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 43497 jdk/test/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java@1a2262d4395c
child 52121 934969c63223
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42351
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     1
/*
43497
1a2262d4395c 8173475: java/net/HttpURLConnection/SetAuthenticator tests have undeclared dependency on java.logging module
skovalev
parents: 42351
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
42351
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     4
 *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    10
 *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    15
 * accompanied this code).
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    16
 *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    20
 *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    23
 * questions.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    24
 */
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    25
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    26
import java.io.IOException;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    27
import java.io.UncheckedIOException;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    28
import java.net.Authenticator;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    29
import java.net.HttpURLConnection;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    30
import java.net.InetSocketAddress;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    31
import java.net.MalformedURLException;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    32
import java.net.PasswordAuthentication;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    33
import java.net.Proxy;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    34
import java.net.URL;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    35
import java.util.Locale;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    36
import java.util.concurrent.atomic.AtomicInteger;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    37
import java.util.logging.Level;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    38
import java.util.logging.Logger;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    39
import java.util.stream.Stream;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    40
import javax.net.ssl.HostnameVerifier;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    41
import javax.net.ssl.HttpsURLConnection;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    42
import javax.net.ssl.SSLContext;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    43
import javax.net.ssl.SSLSession;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    44
import jdk.testlibrary.SimpleSSLContext;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    45
43497
1a2262d4395c 8173475: java/net/HttpURLConnection/SetAuthenticator tests have undeclared dependency on java.logging module
skovalev
parents: 42351
diff changeset
    46
/*
42351
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    47
 * @test
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    48
 * @bug 8169415
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    49
 * @library /lib/testlibrary/
43497
1a2262d4395c 8173475: java/net/HttpURLConnection/SetAuthenticator tests have undeclared dependency on java.logging module
skovalev
parents: 42351
diff changeset
    50
 * @modules java.logging
1a2262d4395c 8173475: java/net/HttpURLConnection/SetAuthenticator tests have undeclared dependency on java.logging module
skovalev
parents: 42351
diff changeset
    51
 *          java.base/sun.net.www
42351
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    52
 *          jdk.httpserver/sun.net.httpserver
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    53
 * @build jdk.testlibrary.SimpleSSLContext HTTPTest HTTPTestServer HTTPTestClient
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    54
 * @summary A simple HTTP test that starts an echo server supporting Digest
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    55
 *          authentication, then starts a regular HTTP client to invoke it.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    56
 *          The client first does a GET request on "/", then follows on
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    57
 *          with a POST request that sends "Hello World!" to the server.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    58
 *          The client expects to receive "Hello World!" in return.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    59
 *          The test supports several execution modes:
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    60
 *            SERVER: The server performs Digest Server authentication;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    61
 *            PROXY:  The server pretends to be a proxy and performs
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    62
 *                    Digest Proxy authentication;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    63
 *            SERVER307: The server redirects the client (307) to another
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    64
 *                    server that perform Digest authentication;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    65
 *            PROXY305: The server attempts to redirect
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    66
 *                    the client to a proxy using 305 code;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    67
 * @run main/othervm HTTPTest SERVER
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    68
 * @run main/othervm HTTPTest PROXY
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    69
 * @run main/othervm HTTPTest SERVER307
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    70
 * @run main/othervm HTTPTest PROXY305
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    71
 *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    72
 * @author danielfuchs
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    73
 */
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    74
public class HTTPTest {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    75
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    76
    public static final boolean DEBUG =
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    77
         Boolean.parseBoolean(System.getProperty("test.debug", "false"));
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    78
    public static enum HttpAuthType { SERVER, PROXY, SERVER307, PROXY305 };
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    79
    public static enum HttpProtocolType { HTTP, HTTPS };
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    80
    public static enum HttpSchemeType { NONE, BASICSERVER, BASIC, DIGEST };
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    81
    public static final HttpAuthType DEFAULT_HTTP_AUTH_TYPE = HttpAuthType.SERVER;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    82
    public static final HttpProtocolType DEFAULT_PROTOCOL_TYPE = HttpProtocolType.HTTP;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    83
    public static final HttpSchemeType DEFAULT_SCHEME_TYPE = HttpSchemeType.DIGEST;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    84
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    85
    public static class HttpTestAuthenticator extends Authenticator {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    86
        private final String realm;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    87
        private final String username;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    88
        // Used to prevent incrementation of 'count' when calling the
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    89
        // authenticator from the server side.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    90
        private final ThreadLocal<Boolean> skipCount = new ThreadLocal<>();
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    91
        // count will be incremented every time getPasswordAuthentication()
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    92
        // is called from the client side.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    93
        final AtomicInteger count = new AtomicInteger();
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    94
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    95
        public HttpTestAuthenticator(String realm, String username) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    96
            this.realm = realm;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    97
            this.username = username;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    98
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
    99
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   100
        @Override
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   101
        protected PasswordAuthentication getPasswordAuthentication() {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   102
            if (skipCount.get() == null || skipCount.get().booleanValue() == false) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   103
                System.out.println("Authenticator called: " + count.incrementAndGet());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   104
            }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   105
            return new PasswordAuthentication(getUserName(),
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   106
                    new char[] {'b','a','r'});
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   107
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   108
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   109
        // Called by the server side to get the password of the user
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   110
        // being authentified.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   111
        public final char[] getPassword(String user) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   112
            if (user.equals(username)) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   113
                skipCount.set(Boolean.TRUE);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   114
                try {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   115
                    return getPasswordAuthentication().getPassword();
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   116
                } finally {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   117
                    skipCount.set(Boolean.FALSE);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   118
                }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   119
            }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   120
            throw new SecurityException("User unknown: " + user);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   121
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   122
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   123
        public final String getUserName() {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   124
            return username;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   125
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   126
        public final String getRealm() {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   127
            return realm;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   128
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   129
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   130
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   131
    public static final HttpTestAuthenticator AUTHENTICATOR;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   132
    static {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   133
        AUTHENTICATOR = new HttpTestAuthenticator("dublin", "foox");
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   134
        Authenticator.setDefault(AUTHENTICATOR);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   135
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   136
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   137
    static {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   138
        try {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   139
            HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   140
                public boolean verify(String hostname, SSLSession session) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   141
                    return true;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   142
                }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   143
            });
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   144
            SSLContext.setDefault(new SimpleSSLContext().get());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   145
        } catch (IOException ex) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   146
            throw new ExceptionInInitializerError(ex);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   147
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   148
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   149
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   150
    static final Logger logger = Logger.getLogger ("com.sun.net.httpserver");
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   151
    static {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   152
        if (DEBUG) logger.setLevel(Level.ALL);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   153
        Stream.of(Logger.getLogger("").getHandlers())
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   154
              .forEach(h -> h.setLevel(Level.ALL));
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   155
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   156
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   157
    static final int EXPECTED_AUTH_CALLS_PER_TEST = 1;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   158
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   159
    public static void main(String[] args) throws Exception {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   160
        // new HTTPTest().execute(HttpAuthType.SERVER.name());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   161
        new HTTPTest().execute(args);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   162
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   163
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   164
    public void execute(String... args) throws Exception {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   165
        Stream<HttpAuthType> modes;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   166
        if (args == null || args.length == 0) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   167
            modes = Stream.of(HttpAuthType.values());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   168
        } else {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   169
            modes = Stream.of(args).map(HttpAuthType::valueOf);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   170
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   171
        modes.forEach(this::test);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   172
        System.out.println("Test PASSED - Authenticator called: "
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   173
                 + expected(AUTHENTICATOR.count.get()));
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   174
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   175
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   176
    public void test(HttpAuthType mode) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   177
        for (HttpProtocolType type: HttpProtocolType.values()) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   178
            test(type, mode);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   179
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   180
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   181
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   182
    public HttpSchemeType getHttpSchemeType() {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   183
        return DEFAULT_SCHEME_TYPE;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   184
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   185
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   186
    public void test(HttpProtocolType protocol, HttpAuthType mode) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   187
        if (mode == HttpAuthType.PROXY305 && protocol == HttpProtocolType.HTTPS ) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   188
            // silently skip unsupported test combination
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   189
            return;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   190
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   191
        System.out.println("\n**** Testing " + protocol + " "
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   192
                           + mode + " mode ****\n");
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   193
        int authCount = AUTHENTICATOR.count.get();
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   194
        int expectedIncrement = 0;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   195
        try {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   196
            // Creates an HTTP server that echoes back whatever is in the
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   197
            // request body.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   198
            HTTPTestServer server =
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   199
                    HTTPTestServer.create(protocol,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   200
                                          mode,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   201
                                          AUTHENTICATOR,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   202
                                          getHttpSchemeType());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   203
            try {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   204
                expectedIncrement += run(server, protocol, mode);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   205
            } finally {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   206
                server.stop();
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   207
            }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   208
        }  catch (IOException ex) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   209
            ex.printStackTrace(System.err);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   210
            throw new UncheckedIOException(ex);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   211
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   212
        int count = AUTHENTICATOR.count.get();
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   213
        if (count != authCount + expectedIncrement) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   214
            throw new AssertionError("Authenticator called " + count(count)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   215
                        + " expected it to be called "
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   216
                        + expected(authCount + expectedIncrement));
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   217
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   218
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   219
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   220
    /**
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   221
     * Runs the test with the given parameters.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   222
     * @param server    The server
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   223
     * @param protocol  The protocol (HTTP/HTTPS)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   224
     * @param mode      The mode (PROXY, SERVER, SERVER307...)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   225
     * @return The number of times the default authenticator should have been
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   226
     *         called.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   227
     * @throws IOException in case of connection or protocol issues
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   228
     */
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   229
    public int run(HTTPTestServer server,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   230
                   HttpProtocolType protocol,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   231
                   HttpAuthType mode)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   232
            throws IOException
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   233
    {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   234
        // Connect to the server with a GET request, then with a
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   235
        // POST that contains "Hello World!"
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   236
        HTTPTestClient.connect(protocol, server, mode, null);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   237
        // return the number of times the default authenticator is supposed
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   238
        // to have been called.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   239
        return EXPECTED_AUTH_CALLS_PER_TEST;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   240
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   241
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   242
    public static String count(int count) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   243
        switch(count) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   244
            case 0: return "not even once";
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   245
            case 1: return "once";
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   246
            case 2: return "twice";
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   247
            default: return String.valueOf(count) + " times";
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   248
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   249
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   250
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   251
    public static String expected(int count) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   252
        switch(count) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   253
            default: return count(count);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   254
        }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   255
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   256
    public static String protocol(HttpProtocolType type) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   257
        return type.name().toLowerCase(Locale.US);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   258
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   259
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   260
    public static URL url(HttpProtocolType protocol, InetSocketAddress address,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   261
                          String path) throws MalformedURLException {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   262
        return new URL(protocol(protocol),
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   263
                       address.getHostString(),
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   264
                       address.getPort(), path);
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   265
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   266
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   267
    public static Proxy proxy(HTTPTestServer server, HttpAuthType authType) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   268
        return (authType == HttpAuthType.PROXY)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   269
               ? new Proxy(Proxy.Type.HTTP, server.getAddress())
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   270
               : null;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   271
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   272
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   273
    public static HttpURLConnection openConnection(URL url,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   274
                                                   HttpAuthType authType,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   275
                                                   Proxy proxy)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   276
                                    throws IOException {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   277
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   278
        HttpURLConnection conn = (HttpURLConnection)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   279
                (authType == HttpAuthType.PROXY
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   280
                    ? url.openConnection(proxy)
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   281
                    : url.openConnection());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   282
        return conn;
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   283
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents:
diff changeset
   284
}