jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java
author weijun
Fri, 16 Dec 2016 19:50:35 +0800
changeset 42705 5163a5964bd7
parent 42688 b43174398bd8
child 44045 8102155116c6
permissions -rw-r--r--
8171340: HttpNegotiateServer/java test should not use system proxy on Mac Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 16020
diff changeset
     2
 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     4
 *
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     8
 *
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    13
 * accompanied this code).
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    14
 *
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5154
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5154
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5154
diff changeset
    21
 * questions.
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    22
 */
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    23
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    24
/*
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    25
 * @test
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
    26
 * @bug 6578647 6829283 8171340
8396
587947f96036 7018928: test failure: sun/security/krb5/auto/SSL.java
weijun
parents: 7977
diff changeset
    27
 * @run main/othervm HttpNegotiateServer
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
    28
 * @summary Undefined requesting URL in java.net.Authenticator
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
    29
 *          .getPasswordAuthentication()
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
    30
 * @summary HTTP/Negotiate: Authenticator triggered again when
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
    31
 *          user cancels the first one
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    32
 */
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    33
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    34
import com.sun.net.httpserver.Headers;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    35
import com.sun.net.httpserver.HttpContext;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    36
import com.sun.net.httpserver.HttpExchange;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    37
import com.sun.net.httpserver.HttpHandler;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    38
import com.sun.net.httpserver.HttpServer;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    39
import com.sun.net.httpserver.HttpPrincipal;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    40
import com.sun.security.auth.module.Krb5LoginModule;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    41
import java.io.BufferedReader;
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
    42
import java.io.File;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
    43
import java.io.FileOutputStream;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    44
import java.io.IOException;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    45
import java.io.InputStream;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    46
import java.io.InputStreamReader;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    47
import java.net.HttpURLConnection;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    48
import java.net.InetSocketAddress;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    49
import java.net.PasswordAuthentication;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    50
import java.net.Proxy;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    51
import java.net.URL;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    52
import java.net.URLConnection;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    53
import java.security.*;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    54
import java.util.HashMap;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    55
import java.util.Map;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    56
import javax.security.auth.Subject;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    57
import javax.security.auth.callback.Callback;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    58
import javax.security.auth.callback.CallbackHandler;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    59
import javax.security.auth.callback.NameCallback;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    60
import javax.security.auth.callback.PasswordCallback;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    61
import javax.security.auth.callback.UnsupportedCallbackException;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    62
import javax.security.auth.login.AppConfigurationEntry;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    63
import javax.security.auth.login.Configuration;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    64
import javax.security.auth.login.LoginContext;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    65
import javax.security.auth.login.LoginException;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    66
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    67
import org.ietf.jgss.GSSContext;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    68
import org.ietf.jgss.GSSCredential;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    69
import org.ietf.jgss.GSSManager;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    70
import sun.security.jgss.GSSUtil;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    71
import sun.security.krb5.Config;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    72
import java.util.Base64;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    73
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    74
/**
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    75
 * Basic JGSS/krb5 test with 3 parties: client, server, backend server. Each
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    76
 * party uses JAAS login to get subjects and executes JGSS calls using
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    77
 * Subject.doAs.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    78
 */
3046
dd50d75d88e6 6849275: enhance krb5 reg tests
weijun
parents: 2942
diff changeset
    79
public class HttpNegotiateServer {
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    80
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    81
    // Two realm, web server in one, proxy server in another
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    82
    final static String REALM_WEB = "WEB.DOMAIN";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    83
    final static String REALM_PROXY = "PROXY.DOMAIN";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    84
    final static String KRB5_CONF = "web.conf";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    85
    final static String KRB5_TAB = "web.ktab";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    86
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    87
    // user principals
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    88
    final static String WEB_USER = "web";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    89
    final static char[] WEB_PASS = "webby".toCharArray();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    90
    final static String PROXY_USER = "pro";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    91
    final static char[] PROXY_PASS = "proxy".toCharArray();
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
    92
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    93
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    94
    final static String WEB_HOST = "host.web.domain";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    95
    final static String PROXY_HOST = "host.proxy.domain";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    96
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    97
    // web page content
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    98
    final static String CONTENT = "Hello, World!";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    99
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   100
    // For 6829283, count how many times the Authenticator is called.
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   101
    static int count = 0;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   102
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   103
    static int webPort, proxyPort;
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   104
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   105
    // URLs for web test, proxy test. The proxy server is not a real proxy
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   106
    // since it fakes the same content for any URL. :)
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   107
    static URL webUrl, proxyUrl;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   108
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   109
    /**
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   110
     * This Authenticator checks everything:
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   111
     * scheme, protocol, requestor type, host, port, and url
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   112
     */
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   113
    static class KnowAllAuthenticator extends java.net.Authenticator {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   114
        public PasswordAuthentication getPasswordAuthentication () {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   115
            if (!getRequestingScheme().equalsIgnoreCase("Negotiate")) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   116
                throw new RuntimeException("Bad scheme");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   117
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   118
            if (!getRequestingProtocol().equalsIgnoreCase("HTTP")) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   119
                throw new RuntimeException("Bad protocol");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   120
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   121
            if (getRequestorType() == RequestorType.SERVER) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   122
                if (!this.getRequestingHost().equalsIgnoreCase(webUrl.getHost())) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   123
                    throw new RuntimeException("Bad host");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   124
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   125
                if (this.getRequestingPort() != webUrl.getPort()) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   126
                    throw new RuntimeException("Bad port");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   127
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   128
                if (!this.getRequestingURL().equals(webUrl)) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   129
                    throw new RuntimeException("Bad url");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   130
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   131
                return new PasswordAuthentication(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   132
                        WEB_USER+"@"+REALM_WEB, WEB_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   133
            } else if (getRequestorType() == RequestorType.PROXY) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   134
                if (!this.getRequestingHost().equalsIgnoreCase(PROXY_HOST)) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   135
                    throw new RuntimeException("Bad host");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   136
                }
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   137
                if (this.getRequestingPort() != proxyPort) {
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   138
                    throw new RuntimeException("Bad port");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   139
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   140
                if (!this.getRequestingURL().equals(proxyUrl)) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   141
                    throw new RuntimeException("Bad url");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   142
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   143
                return new PasswordAuthentication(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   144
                        PROXY_USER+"@"+REALM_PROXY, PROXY_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   145
            } else  {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   146
                throw new RuntimeException("Bad requster type");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   147
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   148
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   149
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   150
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   151
    /**
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   152
     * This Authenticator knows nothing
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   153
     */
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   154
    static class KnowNothingAuthenticator extends java.net.Authenticator {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   155
        @Override
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   156
        public PasswordAuthentication getPasswordAuthentication () {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   157
            HttpNegotiateServer.count++;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   158
            return null;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   159
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   160
    }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   161
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   162
    public static void main(String[] args)
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   163
            throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   164
25151
7a670121602e 8029994: Support "include" and "includedir" in krb5.conf
weijun
parents: 23010
diff changeset
   165
        System.setProperty("sun.security.krb5.debug", "true");
7a670121602e 8029994: Support "include" and "includedir" in krb5.conf
weijun
parents: 23010
diff changeset
   166
3046
dd50d75d88e6 6849275: enhance krb5 reg tests
weijun
parents: 2942
diff changeset
   167
        KDC kdcw = KDC.create(REALM_WEB);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   168
        kdcw.addPrincipal(WEB_USER, WEB_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   169
        kdcw.addPrincipalRandKey("krbtgt/" + REALM_WEB);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   170
        kdcw.addPrincipalRandKey("HTTP/" + WEB_HOST);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   171
3046
dd50d75d88e6 6849275: enhance krb5 reg tests
weijun
parents: 2942
diff changeset
   172
        KDC kdcp = KDC.create(REALM_PROXY);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   173
        kdcp.addPrincipal(PROXY_USER, PROXY_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   174
        kdcp.addPrincipalRandKey("krbtgt/" + REALM_PROXY);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   175
        kdcp.addPrincipalRandKey("HTTP/" + PROXY_HOST);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   176
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   177
        KDC.saveConfig(KRB5_CONF, kdcw, kdcp,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   178
                "default_keytab_name = " + KRB5_TAB,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   179
                "[domain_realm]",
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   180
                "",
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   181
                ".web.domain="+REALM_WEB,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   182
                ".proxy.domain="+REALM_PROXY);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   183
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   184
        System.setProperty("java.security.krb5.conf", KRB5_CONF);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   185
        Config.refresh();
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   186
        KDC.writeMultiKtab(KRB5_TAB, kdcw, kdcp);
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   187
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   188
        // Write a customized JAAS conf file, so that any kinit cache
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   189
        // will be ignored.
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   190
        System.setProperty("java.security.auth.login.config", OneKDC.JAAS_CONF);
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   191
        File f = new File(OneKDC.JAAS_CONF);
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   192
        FileOutputStream fos = new FileOutputStream(f);
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   193
        fos.write((
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   194
                "com.sun.security.jgss.krb5.initiate {\n" +
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   195
                "    com.sun.security.auth.module.Krb5LoginModule required;\n};\n"
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   196
                ).getBytes());
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   197
        fos.close();
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   198
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   199
        HttpServer h1 = httpd("Negotiate", false,
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   200
                "HTTP/" + WEB_HOST + "@" + REALM_WEB, KRB5_TAB);
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   201
        webPort = h1.getAddress().getPort();
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   202
        HttpServer h2 = httpd("Negotiate", true,
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   203
                "HTTP/" + PROXY_HOST + "@" + REALM_PROXY, KRB5_TAB);
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   204
        proxyPort = h2.getAddress().getPort();
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   205
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   206
        webUrl = new URL("http://" + WEB_HOST +":" + webPort + "/a/b/c");
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   207
        proxyUrl = new URL("http://nosuchplace/a/b/c");
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   208
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   209
        try {
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   210
            Exception e1 = null, e2 = null, e3 = null;
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   211
            try {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   212
                test6578647();
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   213
            } catch (Exception e) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   214
                e1 = e;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   215
                e.printStackTrace();
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   216
            }
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   217
            try {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   218
                test6829283();
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   219
            } catch (Exception e) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   220
                e2 = e;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   221
                e.printStackTrace();
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   222
            }
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   223
            try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   224
                test8077155();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   225
            } catch (Exception e) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   226
                e3 = e;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   227
                e.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   228
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   229
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   230
            if (e1 != null || e2 != null || e3 != null) {
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   231
                throw new RuntimeException("Test error");
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   232
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   233
        } finally {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   234
            // Must stop. Seems there's no HttpServer.startAsDaemon()
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   235
            if (h1 != null) h1.stop(0);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   236
            if (h2 != null) h2.stop(0);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   237
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   238
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   239
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   240
    static void test6578647() throws Exception {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   241
        BufferedReader reader;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   242
        java.net.Authenticator.setDefault(new KnowAllAuthenticator());
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   243
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   244
        reader = new BufferedReader(new InputStreamReader(
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   245
                webUrl.openConnection(Proxy.NO_PROXY).getInputStream()));
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   246
        if (!reader.readLine().equals(CONTENT)) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   247
            throw new RuntimeException("Bad content");
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   248
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   249
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   250
        reader = new BufferedReader(new InputStreamReader(
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   251
                proxyUrl.openConnection(new Proxy(Proxy.Type.HTTP,
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   252
                                new InetSocketAddress(PROXY_HOST, proxyPort)))
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   253
                        .getInputStream()));
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   254
        if (!reader.readLine().equals(CONTENT)) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   255
            throw new RuntimeException("Bad content");
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   256
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   257
    }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   258
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   259
    static void test6829283() throws Exception {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   260
        BufferedReader reader;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   261
        java.net.Authenticator.setDefault(new KnowNothingAuthenticator());
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   262
        try {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   263
            new BufferedReader(new InputStreamReader(
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   264
                    webUrl.openConnection(Proxy.NO_PROXY).getInputStream()));
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   265
        } catch (IOException ioe) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   266
            // Will fail since no username and password is provided.
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   267
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   268
        if (count > 1) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   269
            throw new RuntimeException("Authenticator called twice");
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   270
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   271
    }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   272
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   273
    static void testConnect() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   274
        InputStream inputStream = null;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   275
        try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   276
            URL url = webUrl;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   277
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   278
            URLConnection conn = url.openConnection(Proxy.NO_PROXY);
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   279
            conn.connect();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   280
            inputStream = conn.getInputStream();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   281
            byte[] b = new byte[inputStream.available()];
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   282
            for (int j = 0; j < b.length; j++) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   283
                b[j] = (byte) inputStream.read();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   284
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   285
            String s = new String(b);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   286
            System.out.println("Length: " + s.length());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   287
            System.out.println(s);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   288
        } catch (Exception ex) {
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   289
            throw new RuntimeException(ex);
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   290
        } finally {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   291
            if (inputStream != null) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   292
                try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   293
                    inputStream.close();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   294
                } catch (IOException e) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   295
                    e.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   296
                }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   297
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   298
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   299
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   300
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   301
    static void test8077155() throws Exception {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   302
        final String username = WEB_USER;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   303
        final char[] password = WEB_PASS;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   304
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   305
        SecurityManager security = new SecurityManager();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   306
        Policy.setPolicy(new SecurityPolicy());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   307
        System.setSecurityManager(security);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   308
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   309
        CallbackHandler callback = new CallbackHandler() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   310
            @Override
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   311
            public void handle(Callback[] pCallbacks)
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   312
                    throws IOException, UnsupportedCallbackException {
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   313
                for (Callback cb : pCallbacks) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   314
                    if (cb instanceof NameCallback) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   315
                        NameCallback ncb = (NameCallback)cb;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   316
                        ncb.setName(username);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   317
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   318
                    } else  if (cb instanceof PasswordCallback) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   319
                        PasswordCallback pwdcb = (PasswordCallback) cb;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   320
                        pwdcb.setPassword(password);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   321
                    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   322
                }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   323
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   324
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   325
        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   326
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   327
        final String jaasConfigName = "oracle.test.kerberos.login";
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   328
        final String krb5LoginModule
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   329
                = "com.sun.security.auth.module.Krb5LoginModule";
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   330
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   331
        Configuration loginConfig = new Configuration() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   332
            @Override
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   333
            public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   334
                if (! jaasConfigName.equals(name)) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   335
                    return new AppConfigurationEntry[0];
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   336
                }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   337
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   338
                Map<String, String> options = new HashMap<String, String>();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   339
                options.put("useTicketCache", Boolean.FALSE.toString());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   340
                options.put("useKeyTab", Boolean.FALSE.toString());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   341
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   342
                return new AppConfigurationEntry[] {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   343
                        new AppConfigurationEntry(krb5LoginModule,
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   344
                                LoginModuleControlFlag.REQUIRED,
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   345
                                options)
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   346
                        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   347
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   348
        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   349
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   350
        // oracle context/subject/login
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   351
        LoginContext context = null;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   352
        try {
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   353
            context = new LoginContext(
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   354
                    "oracle.test.kerberos.login", null, callback, loginConfig);
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   355
            context.login();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   356
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   357
        } catch (LoginException ex) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   358
            ex.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   359
            throw new RuntimeException(ex);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   360
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   361
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   362
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   363
        Subject subject = context.getSubject();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   364
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   365
        final PrivilegedExceptionAction<Object> test_action
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   366
                = new PrivilegedExceptionAction<Object>() {
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   367
            public Object run() throws Exception {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   368
                testConnect();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   369
                return null;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   370
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   371
        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   372
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   373
        System.err.println("\n\nExpecting to succeed when executing " +
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   374
                "with the the logged in subject.");
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   375
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   376
        try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   377
            Subject.doAs(subject, test_action);
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   378
            System.err.println("\n\nConnection succeed when executing " +
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   379
                    "with the the logged in subject.");
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   380
        } catch (PrivilegedActionException e) {
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   381
            System.err.println("\n\nFailure unexpected when executing " +
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   382
                    "with the the logged in subject.");
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   383
            e.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   384
            throw new RuntimeException("Failed to login as subject");
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   385
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   386
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   387
        try {
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   388
            System.err.println("\n\nExpecting to fail when running " +
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   389
                    "with the current user's login.");
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   390
            testConnect();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   391
        } catch (Exception ex) {
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   392
            System.err.println("\nConnect failed when running " +
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   393
                    "with the current user's login:\n" + ex.getMessage());
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   394
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   395
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   396
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   397
    /**
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   398
     * Creates and starts an HTTP or proxy server that requires
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   399
     * Negotiate authentication.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   400
     * @param scheme "Negotiate" or "Kerberos"
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   401
     * @param principal the krb5 service principal the server runs with
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   402
     * @return the server
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   403
     */
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   404
    public static HttpServer httpd(String scheme, boolean proxy,
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   405
            String principal, String ktab) throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   406
        MyHttpHandler h = new MyHttpHandler();
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   407
        HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   408
        HttpContext hc = server.createContext("/", h);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   409
        hc.setAuthenticator(new MyServerAuthenticator(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   410
                proxy, scheme, principal, ktab));
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   411
        server.start();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   412
        return server;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   413
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   414
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   415
    static class MyHttpHandler implements HttpHandler {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   416
        public void handle(HttpExchange t) throws IOException {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   417
            t.sendResponseHeaders(200, 0);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   418
            t.getResponseBody().write(CONTENT.getBytes());
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   419
            t.close();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   420
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   421
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   422
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   423
    static class MyServerAuthenticator
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   424
            extends com.sun.net.httpserver.Authenticator {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   425
        Subject s = new Subject();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   426
        GSSManager m = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   427
        GSSCredential cred = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   428
        String scheme = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   429
        String reqHdr = "WWW-Authenticate";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   430
        String respHdr = "Authorization";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   431
        int err = HttpURLConnection.HTTP_UNAUTHORIZED;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   432
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   433
        public MyServerAuthenticator(boolean proxy, String scheme,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   434
                String principal, String ktab) throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   435
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   436
            this.scheme = scheme;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   437
            if (proxy) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   438
                reqHdr = "Proxy-Authenticate";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   439
                respHdr = "Proxy-Authorization";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   440
                err = HttpURLConnection.HTTP_PROXY_AUTH;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   441
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   442
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   443
            Krb5LoginModule krb5 = new Krb5LoginModule();
7977
f47f211cd627 7008713: diamond conversion of kerberos5 and security tools
smarks
parents: 5506
diff changeset
   444
            Map<String, String> map = new HashMap<>();
f47f211cd627 7008713: diamond conversion of kerberos5 and security tools
smarks
parents: 5506
diff changeset
   445
            Map<String, Object> shared = new HashMap<>();
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   446
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   447
            map.put("storeKey", "true");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   448
            map.put("isInitiator", "false");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   449
            map.put("useKeyTab", "true");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   450
            map.put("keyTab", ktab);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   451
            map.put("principal", principal);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   452
            krb5.initialize(s, null, shared, map);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   453
            krb5.login();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   454
            krb5.commit();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   455
            m = GSSManager.getInstance();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   456
            cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   457
                @Override
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   458
                public GSSCredential run() throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   459
                    System.err.println("Creating GSSCredential");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   460
                    return m.createCredential(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   461
                            null,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   462
                            GSSCredential.INDEFINITE_LIFETIME,
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   463
                            MyServerAuthenticator.this.scheme
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   464
                                        .equalsIgnoreCase("Negotiate") ?
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   465
                                    GSSUtil.GSS_SPNEGO_MECH_OID :
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   466
                                    GSSUtil.GSS_KRB5_MECH_OID,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   467
                            GSSCredential.ACCEPT_ONLY);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   468
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   469
            });
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   470
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   471
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   472
        @Override
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   473
        public Result authenticate(HttpExchange exch) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   474
            // The GSContext is stored in an HttpContext attribute named
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   475
            // "GSSContext" and is created at the first request.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   476
            GSSContext c = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   477
            String auth = exch.getRequestHeaders().getFirst(respHdr);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   478
            try {
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   479
                c = (GSSContext)exch.getHttpContext()
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   480
                        .getAttributes().get("GSSContext");
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   481
                if (auth == null) {                 // First request
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   482
                    Headers map = exch.getResponseHeaders();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   483
                    map.set (reqHdr, scheme);        // Challenge!
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   484
                    c = Subject.doAs(s, new PrivilegedExceptionAction<GSSContext>() {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   485
                        @Override
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   486
                        public GSSContext run() throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   487
                            return m.createContext(cred);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   488
                        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   489
                    });
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   490
                    exch.getHttpContext().getAttributes().put("GSSContext", c);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   491
                    return new com.sun.net.httpserver.Authenticator.Retry(err);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   492
                } else {                            // Later requests
42705
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   493
                    byte[] token = Base64.getMimeDecoder()
5163a5964bd7 8171340: HttpNegotiateServer/java test should not use system proxy on Mac
weijun
parents: 42688
diff changeset
   494
                            .decode(auth.split(" ")[1]);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   495
                    token = c.acceptSecContext(token, 0, token.length);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   496
                    Headers map = exch.getResponseHeaders();
16020
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 11107
diff changeset
   497
                    map.set (reqHdr, scheme + " " + Base64.getMimeEncoder()
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 11107
diff changeset
   498
                            .encodeToString(token).replaceAll("\\s", ""));
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   499
                    if (c.isEstablished()) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   500
                        return new com.sun.net.httpserver.Authenticator.Success(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   501
                                new HttpPrincipal(c.getSrcName().toString(), ""));
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   502
                    } else {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   503
                        return new com.sun.net.httpserver.Authenticator.Retry(err);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   504
                    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   505
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   506
            } catch (Exception e) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   507
                throw new RuntimeException(e);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   508
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   509
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   510
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   511
}
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   512
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   513
class SecurityPolicy extends Policy {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   514
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   515
    private static Permissions perms;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   516
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   517
    public SecurityPolicy() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   518
        super();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   519
        if (perms == null) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   520
            perms = new Permissions();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   521
            perms.add(new AllPermission());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   522
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   523
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   524
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   525
    @Override
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   526
    public PermissionCollection getPermissions(CodeSource codesource) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   527
        return perms;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   528
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   529
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   530
}