test/jdk/java/net/Authenticator/B4759514.java
changeset 55399 46049b8a5658
parent 47216 71c04702a3d5
equal deleted inserted replaced
55398:e53ec3b362f4 55399:46049b8a5658
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    23 
    23 
    24 /**
    24 /**
    25  * @test
    25  * @test
    26  * @bug 4759514
    26  * @bug 4759514
    27  * @modules java.base/sun.net.www
    27  * @modules java.base/sun.net.www
    28  * @library ../../../sun/net/www/httptest/
    28  * @library ../../../sun/net/www/httptest/ /test/lib
    29  * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
    29  * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
    30  * @run main B4759514
    30  * @run main/othervm B4759514
       
    31  * @run main/othervm -Djava.net.preferIPv6Addresses=true B4759514
    31  * @summary Digest Authentication is erroniously quoting the nc value, contrary to RFC 2617
    32  * @summary Digest Authentication is erroniously quoting the nc value, contrary to RFC 2617
    32  */
    33  */
    33 
    34 
    34 import java.io.*;
    35 import java.io.*;
    35 import java.net.*;
    36 import java.net.*;
       
    37 import jdk.test.lib.net.URIBuilder;
    36 
    38 
    37 public class B4759514 implements HttpCallback {
    39 public class B4759514 implements HttpCallback {
    38 
    40 
    39     static int count = 0;
    41     static int count = 0;
    40     static String authstring;
    42     static String authstring;
    95     static TestHttpServer server;
    97     static TestHttpServer server;
    96 
    98 
    97     public static void main (String[] args) throws Exception {
    99     public static void main (String[] args) throws Exception {
    98         MyAuthenticator auth = new MyAuthenticator ();
   100         MyAuthenticator auth = new MyAuthenticator ();
    99         Authenticator.setDefault (auth);
   101         Authenticator.setDefault (auth);
       
   102         ProxySelector.setDefault(ProxySelector.of(null)); // no proxy
   100         try {
   103         try {
   101             server = new TestHttpServer (new B4759514(), 1, 10, 0);
   104             InetAddress loopback = InetAddress.getLoopbackAddress();
   102             System.out.println ("Server: listening on port: " + server.getLocalPort());
   105             server = new TestHttpServer (new B4759514(), 1, 10, loopback, 0);
   103             client ("http://localhost:"+server.getLocalPort()+"/d1/foo.html");
   106             String serverURL = URIBuilder.newBuilder()
       
   107                 .scheme("http")
       
   108                 .loopback()
       
   109                 .port(server.getLocalPort())
       
   110                 .path("/")
       
   111                 .build()
       
   112                 .toString();
       
   113             System.out.println("Server: listening at: " + serverURL);
       
   114             client(serverURL + "d1/foo.html");
   104         } catch (Exception e) {
   115         } catch (Exception e) {
   105             if (server != null) {
   116             if (server != null) {
   106                 server.terminate();
   117                 server.terminate();
   107             }
   118             }
   108             throw e;
   119             throw e;