jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java
author stefank
Mon, 04 Apr 2016 09:15:01 +0200
changeset 37241 b9961c99c356
parent 36511 9d0388c6b336
child 36967 d041d2e80712
permissions -rw-r--r--
8152538: UL doesn't inline the LogTagSet::is_level check Reviewed-by: mlarsson, brutisso
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
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
    26
 * @bug 6578647 6829283
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    27
 * @modules java.base/sun.net.spi.nameservice
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    28
 *          java.base/sun.security.util
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    29
 *          java.security.jgss/sun.security.jgss
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    30
 *          java.security.jgss/sun.security.krb5
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    31
 *          java.security.jgss/sun.security.krb5.internal
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    32
 *          java.security.jgss/sun.security.krb5.internal.ccache
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    33
 *          java.security.jgss/sun.security.krb5.internal.crypto
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31474
diff changeset
    34
 *          java.security.jgss/sun.security.krb5.internal.ktab
8396
587947f96036 7018928: test failure: sun/security/krb5/auto/SSL.java
weijun
parents: 7977
diff changeset
    35
 * @run main/othervm HttpNegotiateServer
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    36
 * @summary Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
    37
 * @summary HTTP/Negotiate: Authenticator triggered again when user cancels the first one
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    38
 */
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    39
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    40
import com.sun.net.httpserver.Headers;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    41
import com.sun.net.httpserver.HttpContext;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    42
import com.sun.net.httpserver.HttpExchange;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    43
import com.sun.net.httpserver.HttpHandler;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    44
import com.sun.net.httpserver.HttpServer;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    45
import com.sun.net.httpserver.HttpPrincipal;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    46
import com.sun.security.auth.module.Krb5LoginModule;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    47
import java.io.BufferedReader;
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
    48
import java.io.File;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
    49
import java.io.FileOutputStream;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    50
import java.io.IOException;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    51
import java.io.InputStream;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    52
import java.io.InputStreamReader;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    53
import java.net.HttpURLConnection;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    54
import java.net.InetSocketAddress;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    55
import java.net.PasswordAuthentication;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    56
import java.net.Proxy;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    57
import java.net.URL;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    58
import java.net.URLConnection;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    59
import java.security.*;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    60
import java.util.HashMap;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    61
import java.util.Map;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    62
import javax.security.auth.Subject;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    63
import javax.security.auth.callback.Callback;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    64
import javax.security.auth.callback.CallbackHandler;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    65
import javax.security.auth.callback.NameCallback;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    66
import javax.security.auth.callback.PasswordCallback;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    67
import javax.security.auth.callback.UnsupportedCallbackException;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    68
import javax.security.auth.login.AppConfigurationEntry;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    69
import javax.security.auth.login.Configuration;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    70
import javax.security.auth.login.LoginContext;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    71
import javax.security.auth.login.LoginException;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    72
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    73
import org.ietf.jgss.GSSContext;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    74
import org.ietf.jgss.GSSCredential;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    75
import org.ietf.jgss.GSSManager;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    76
import sun.security.jgss.GSSUtil;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    77
import sun.security.krb5.Config;
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
    78
import java.util.Base64;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    79
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
 * 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
    82
 * 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
    83
 * Subject.doAs.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    84
 */
3046
dd50d75d88e6 6849275: enhance krb5 reg tests
weijun
parents: 2942
diff changeset
    85
public class HttpNegotiateServer {
2942
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
    // Two realm, web server in one, proxy server in another
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    88
    final static String REALM_WEB = "WEB.DOMAIN";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    89
    final static String REALM_PROXY = "PROXY.DOMAIN";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    90
    final static String KRB5_CONF = "web.conf";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    91
    final static String KRB5_TAB = "web.ktab";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    92
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    93
    // user principals
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    94
    final static String WEB_USER = "web";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    95
    final static char[] WEB_PASS = "webby".toCharArray();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    96
    final static String PROXY_USER = "pro";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    97
    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
    98
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
    99
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   100
    final static String WEB_HOST = "host.web.domain";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   101
    final static String PROXY_HOST = "host.proxy.domain";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   102
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   103
    // web page content
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   104
    final static String CONTENT = "Hello, World!";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   105
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   106
    // 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
   107
    static int count = 0;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   108
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   109
    static int webPort, proxyPort;
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   110
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   111
    // 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
   112
    // 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
   113
    static URL webUrl, proxyUrl;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   114
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   115
    /**
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   116
     * This Authenticator checks everything:
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   117
     * scheme, protocol, requestor type, host, port, and url
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   118
     */
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   119
    static class KnowAllAuthenticator extends java.net.Authenticator {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   120
        public PasswordAuthentication getPasswordAuthentication () {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   121
            if (!getRequestingScheme().equalsIgnoreCase("Negotiate")) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   122
                throw new RuntimeException("Bad scheme");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   123
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   124
            if (!getRequestingProtocol().equalsIgnoreCase("HTTP")) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   125
                throw new RuntimeException("Bad protocol");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   126
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   127
            if (getRequestorType() == RequestorType.SERVER) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   128
                if (!this.getRequestingHost().equalsIgnoreCase(webUrl.getHost())) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   129
                    throw new RuntimeException("Bad host");
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
                if (this.getRequestingPort() != webUrl.getPort()) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   132
                    throw new RuntimeException("Bad port");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   133
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   134
                if (!this.getRequestingURL().equals(webUrl)) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   135
                    throw new RuntimeException("Bad url");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   136
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   137
                return new PasswordAuthentication(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   138
                        WEB_USER+"@"+REALM_WEB, WEB_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   139
            } else if (getRequestorType() == RequestorType.PROXY) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   140
                if (!this.getRequestingHost().equalsIgnoreCase(PROXY_HOST)) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   141
                    throw new RuntimeException("Bad host");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   142
                }
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   143
                if (this.getRequestingPort() != proxyPort) {
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   144
                    throw new RuntimeException("Bad port");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   145
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   146
                if (!this.getRequestingURL().equals(proxyUrl)) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   147
                    throw new RuntimeException("Bad url");
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
                return new PasswordAuthentication(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   150
                        PROXY_USER+"@"+REALM_PROXY, PROXY_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   151
            } else  {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   152
                throw new RuntimeException("Bad requster type");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   153
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   154
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   155
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   156
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   157
    /**
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   158
     * This Authenticator knows nothing
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
    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
   161
        @Override
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   162
        public PasswordAuthentication getPasswordAuthentication () {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   163
            HttpNegotiateServer.count++;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   164
            return null;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   165
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   166
    }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   167
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   168
    public static void main(String[] args)
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   169
            throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   170
25151
7a670121602e 8029994: Support "include" and "includedir" in krb5.conf
weijun
parents: 23010
diff changeset
   171
        System.setProperty("sun.security.krb5.debug", "true");
7a670121602e 8029994: Support "include" and "includedir" in krb5.conf
weijun
parents: 23010
diff changeset
   172
3046
dd50d75d88e6 6849275: enhance krb5 reg tests
weijun
parents: 2942
diff changeset
   173
        KDC kdcw = KDC.create(REALM_WEB);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   174
        kdcw.addPrincipal(WEB_USER, WEB_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   175
        kdcw.addPrincipalRandKey("krbtgt/" + REALM_WEB);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   176
        kdcw.addPrincipalRandKey("HTTP/" + WEB_HOST);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   177
3046
dd50d75d88e6 6849275: enhance krb5 reg tests
weijun
parents: 2942
diff changeset
   178
        KDC kdcp = KDC.create(REALM_PROXY);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   179
        kdcp.addPrincipal(PROXY_USER, PROXY_PASS);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   180
        kdcp.addPrincipalRandKey("krbtgt/" + REALM_PROXY);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   181
        kdcp.addPrincipalRandKey("HTTP/" + PROXY_HOST);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   182
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   183
        KDC.saveConfig(KRB5_CONF, kdcw, kdcp,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   184
                "default_keytab_name = " + KRB5_TAB,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   185
                "[domain_realm]",
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   186
                "",
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   187
                ".web.domain="+REALM_WEB,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   188
                ".proxy.domain="+REALM_PROXY);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   189
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   190
        System.setProperty("java.security.krb5.conf", KRB5_CONF);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   191
        Config.refresh();
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   192
        KDC.writeMultiKtab(KRB5_TAB, kdcw, kdcp);
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   193
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   194
        // 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
   195
        // will be ignored.
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   196
        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
   197
        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
   198
        FileOutputStream fos = new FileOutputStream(f);
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   199
        fos.write((
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   200
                "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
   201
                "    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
   202
                ).getBytes());
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   203
        fos.close();
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   204
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   205
        HttpServer h1 = httpd("Negotiate", false,
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   206
                "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
   207
        webPort = h1.getAddress().getPort();
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   208
        HttpServer h2 = httpd("Negotiate", true,
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   209
                "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
   210
        proxyPort = h2.getAddress().getPort();
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   211
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   212
        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
   213
        proxyUrl = new URL("http://nosuchplace/a/b/c");
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   214
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   215
        try {
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   216
            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
   217
            try {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   218
                test6578647();
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
                e1 = e;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   221
                e.printStackTrace();
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   222
            }
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   223
            try {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   224
                test6829283();
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   225
            } catch (Exception e) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   226
                e2 = e;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   227
                e.printStackTrace();
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   228
            }
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   229
            try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   230
                test8077155();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   231
            } catch (Exception e) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   232
                e3 = e;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   233
                e.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   234
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   235
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   236
            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
   237
                throw new RuntimeException("Test error");
2942
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
        } finally {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   240
            // Must stop. Seems there's no HttpServer.startAsDaemon()
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   241
            if (h1 != null) h1.stop(0);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   242
            if (h2 != null) h2.stop(0);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   243
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   244
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   245
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   246
    static void test6578647() throws Exception {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   247
        BufferedReader reader;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   248
        java.net.Authenticator.setDefault(new KnowAllAuthenticator());
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(
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   251
                webUrl.openConnection().getInputStream()));
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   252
        if (!reader.readLine().equals(CONTENT)) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   253
            throw new RuntimeException("Bad content");
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   254
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   255
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   256
        reader = new BufferedReader(new InputStreamReader(
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   257
                proxyUrl.openConnection(
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   258
                new Proxy(Proxy.Type.HTTP,
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   259
                    new InetSocketAddress(PROXY_HOST, proxyPort)))
5154
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   260
                .getInputStream()));
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   261
        if (!reader.readLine().equals(CONTENT)) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   262
            throw new RuntimeException("Bad content");
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   263
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   264
    }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   265
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   266
    static void test6829283() throws Exception {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   267
        BufferedReader reader;
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   268
        java.net.Authenticator.setDefault(new KnowNothingAuthenticator());
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   269
        try {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   270
            new BufferedReader(new InputStreamReader(
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   271
                    webUrl.openConnection().getInputStream()));
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   272
        } catch (IOException ioe) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   273
            // 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
   274
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   275
        if (count > 1) {
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   276
            throw new RuntimeException("Authenticator called twice");
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   277
        }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   278
    }
07af3c279166 6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one
weijun
parents: 4236
diff changeset
   279
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   280
    static void testConnect() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   281
        InputStream inputStream = null;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   282
        try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   283
            URL url = webUrl;
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
            URLConnection conn = url.openConnection();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   286
            conn.connect();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   287
            inputStream = conn.getInputStream();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   288
            byte[] b = new byte[inputStream.available()];
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   289
            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
   290
                b[j] = (byte) inputStream.read();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   291
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   292
            String s = new String(b);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   293
            System.out.println("Length: " + s.length());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   294
            System.out.println(s);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   295
        } catch (Exception ex) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   296
              throw new RuntimeException(ex);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   297
        } finally {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   298
            if (inputStream != null) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   299
                try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   300
                    inputStream.close();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   301
                } catch (IOException e) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   302
                    e.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   303
                }
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
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   306
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   307
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   308
    static void test8077155() throws Exception {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   309
        final String username = WEB_USER;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   310
        final char[] password = WEB_PASS;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   311
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   312
        SecurityManager security = new SecurityManager();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   313
        Policy.setPolicy(new SecurityPolicy());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   314
        System.setSecurityManager(security);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   315
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   316
        CallbackHandler callback = new CallbackHandler() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   317
            @Override
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   318
            public void handle(Callback[] pCallbacks) throws IOException, UnsupportedCallbackException {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   319
                for (Callback cb : pCallbacks) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   320
                    if (cb instanceof NameCallback) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   321
                        NameCallback ncb = (NameCallback)cb;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   322
                        ncb.setName(username);
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
                    } else  if (cb instanceof PasswordCallback) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   325
                        PasswordCallback pwdcb = (PasswordCallback) cb;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   326
                        pwdcb.setPassword(password);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   327
                    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   328
                }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   329
            }
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
        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   332
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   333
        final String jaasConfigName = "oracle.test.kerberos.login";
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   334
        final String krb5LoginModule = "com.sun.security.auth.module.Krb5LoginModule";
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   335
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   336
        Configuration loginConfig = new Configuration() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   337
            @Override
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   338
            public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   339
                if (! jaasConfigName.equals(name)) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   340
                    return new AppConfigurationEntry[0];
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
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   343
                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
   344
                options.put("useTicketCache", Boolean.FALSE.toString());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   345
                options.put("useKeyTab", Boolean.FALSE.toString());
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
                return new AppConfigurationEntry[] {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   348
                        new AppConfigurationEntry(krb5LoginModule,
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   349
                                LoginModuleControlFlag.REQUIRED,
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   350
                                options)
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   351
                        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   352
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   353
        };
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   354
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   355
        // oracle context/subject/login
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   356
        LoginContext context = null;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   357
        try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   358
            context = new LoginContext("oracle.test.kerberos.login", null, callback, loginConfig);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   359
            context.login();
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
        } catch (LoginException ex) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   362
            ex.printStackTrace();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   363
            throw new RuntimeException(ex);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   364
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   365
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   366
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   367
        Subject subject = context.getSubject();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   368
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   369
        final PrivilegedExceptionAction<Object> test_action = new PrivilegedExceptionAction<Object>() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   370
            public Object run() throws Exception {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   371
                testConnect();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   372
                return null;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   373
            }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   374
        };
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
        System.err.println("\n\nExpecting to succeed when executing with the the logged in subject.");
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   377
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   378
        try {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   379
            Subject.doAs(subject, test_action);
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   380
            System.err.println("\n\nConnection succeed when executing with the the logged in subject.");
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   381
        } catch (PrivilegedActionException e) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   382
            System.err.println("\n\nFailure unexpected when executing with the the logged in subject.");
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 {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   388
            System.err.println("\n\nExpecting to fail when running with the current user's login.");
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   389
            testConnect();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   390
        } catch (Exception ex) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   391
            System.err.println("\nConnect failed when running with the current user's login:\n" + ex.getMessage());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   392
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   393
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   394
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   395
    /**
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   396
     * Creates and starts an HTTP or proxy server that requires
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   397
     * Negotiate authentication.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   398
     * @param scheme "Negotiate" or "Kerberos"
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   399
     * @param principal the krb5 service principal the server runs with
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   400
     * @return the server
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   401
     */
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   402
    public static HttpServer httpd(String scheme, boolean proxy,
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   403
            String principal, String ktab) throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   404
        MyHttpHandler h = new MyHttpHandler();
9008
1c23e333dd76 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents: 8396
diff changeset
   405
        HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   406
        HttpContext hc = server.createContext("/", h);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   407
        hc.setAuthenticator(new MyServerAuthenticator(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   408
                proxy, scheme, principal, ktab));
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   409
        server.start();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   410
        return server;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   411
    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   412
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   413
    static class MyHttpHandler implements HttpHandler {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   414
        public void handle(HttpExchange t) throws IOException {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   415
            t.sendResponseHeaders(200, 0);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   416
            t.getResponseBody().write(CONTENT.getBytes());
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   417
            t.close();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   418
        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   419
    }
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
    static class MyServerAuthenticator
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   422
            extends com.sun.net.httpserver.Authenticator {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   423
        Subject s = new Subject();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   424
        GSSManager m = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   425
        GSSCredential cred = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   426
        String scheme = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   427
        String reqHdr = "WWW-Authenticate";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   428
        String respHdr = "Authorization";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   429
        int err = HttpURLConnection.HTTP_UNAUTHORIZED;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   430
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   431
        public MyServerAuthenticator(boolean proxy, String scheme,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   432
                String principal, String ktab) throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   433
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   434
            this.scheme = scheme;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   435
            if (proxy) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   436
                reqHdr = "Proxy-Authenticate";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   437
                respHdr = "Proxy-Authorization";
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   438
                err = HttpURLConnection.HTTP_PROXY_AUTH;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   439
            }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   440
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   441
            Krb5LoginModule krb5 = new Krb5LoginModule();
7977
f47f211cd627 7008713: diamond conversion of kerberos5 and security tools
smarks
parents: 5506
diff changeset
   442
            Map<String, String> map = new HashMap<>();
f47f211cd627 7008713: diamond conversion of kerberos5 and security tools
smarks
parents: 5506
diff changeset
   443
            Map<String, Object> shared = new HashMap<>();
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   444
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   445
            map.put("storeKey", "true");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   446
            map.put("isInitiator", "false");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   447
            map.put("useKeyTab", "true");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   448
            map.put("keyTab", ktab);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   449
            map.put("principal", principal);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   450
            krb5.initialize(s, null, shared, map);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   451
            krb5.login();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   452
            krb5.commit();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   453
            m = GSSManager.getInstance();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   454
            cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   455
                @Override
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   456
                public GSSCredential run() throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   457
                    System.err.println("Creating GSSCredential");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   458
                    return m.createCredential(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   459
                            null,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   460
                            GSSCredential.INDEFINITE_LIFETIME,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   461
                            MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")?
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   462
                                    GSSUtil.GSS_SPNEGO_MECH_OID:
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   463
                                    GSSUtil.GSS_KRB5_MECH_OID,
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   464
                            GSSCredential.ACCEPT_ONLY);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   465
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   466
            });
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   467
        }
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
        @Override
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   470
        public Result authenticate(HttpExchange exch) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   471
            // The GSContext is stored in an HttpContext attribute named
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   472
            // "GSSContext" and is created at the first request.
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   473
            GSSContext c = null;
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   474
            String auth = exch.getRequestHeaders().getFirst(respHdr);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   475
            try {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   476
                c = (GSSContext)exch.getHttpContext().getAttributes().get("GSSContext");
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   477
                if (auth == null) {                 // First request
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   478
                    Headers map = exch.getResponseHeaders();
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   479
                    map.set (reqHdr, scheme);        // Challenge!
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   480
                    c = Subject.doAs(s, new PrivilegedExceptionAction<GSSContext>() {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   481
                        @Override
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   482
                        public GSSContext run() throws Exception {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   483
                            return m.createContext(cred);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   484
                        }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   485
                    });
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   486
                    exch.getHttpContext().getAttributes().put("GSSContext", c);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   487
                    return new com.sun.net.httpserver.Authenticator.Retry(err);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   488
                } else {                            // Later requests
16020
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 11107
diff changeset
   489
                    byte[] token = Base64.getMimeDecoder().decode(auth.split(" ")[1]);
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   490
                    token = c.acceptSecContext(token, 0, token.length);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   491
                    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
   492
                    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
   493
                            .encodeToString(token).replaceAll("\\s", ""));
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   494
                    if (c.isEstablished()) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   495
                        return new com.sun.net.httpserver.Authenticator.Success(
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   496
                                new HttpPrincipal(c.getSrcName().toString(), ""));
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   497
                    } else {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   498
                        return new com.sun.net.httpserver.Authenticator.Retry(err);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   499
                    }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   500
                }
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   501
            } catch (Exception e) {
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   502
                throw new RuntimeException(e);
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
diff changeset
   503
            }
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
}
30685
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   507
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   508
class SecurityPolicy extends Policy {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   509
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   510
    private static Permissions perms;
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   511
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   512
    public SecurityPolicy() {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   513
        super();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   514
        if (perms == null) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   515
            perms = new Permissions();
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   516
            perms.add(new AllPermission());
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   517
        }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   518
    }
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   519
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   520
    @Override
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   521
    public PermissionCollection getPermissions(CodeSource codesource) {
5806d3adbd6b 8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
robm
parents: 25151
diff changeset
   522
        return perms;
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
}