author | ssahoo |
Thu, 25 Jan 2018 05:57:22 -0800 | |
changeset 48668 | 2da4a52715d8 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
21961
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
1 |
/* |
48668 | 2 |
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
21961
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
4 |
* |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
8 |
* |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
13 |
* accompanied this code). |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
14 |
* |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
18 |
* |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
21 |
* questions. |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
22 |
*/ |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
23 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
24 |
/* |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
25 |
* @test |
48668 | 26 |
* @bug 8028351 8194486 |
21961
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
27 |
* @summary JWS doesn't get authenticated when using kerberos auth proxy |
48668 | 28 |
* @library /test/lib |
21961
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
29 |
* @compile -XDignore.symbol.file LoginNoPass.java |
48668 | 30 |
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts |
31 |
* @run main/othervm -Djdk.net.hosts.file=TestHosts LoginNoPass |
|
21961
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
32 |
*/ |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
33 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
34 |
import sun.security.jgss.GSSUtil; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
35 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
36 |
import javax.security.auth.callback.Callback; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
37 |
import javax.security.auth.callback.CallbackHandler; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
38 |
import javax.security.auth.callback.NameCallback; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
39 |
import javax.security.auth.callback.PasswordCallback; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
40 |
import java.security.Security; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
41 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
42 |
public class LoginNoPass { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
43 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
44 |
static boolean kdcTouched = false; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
46 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
47 |
new OneKDC(null) { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
48 |
protected byte[] processAsReq(byte[] in) throws Exception { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
49 |
kdcTouched = true; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
50 |
return super.processAsReq(in); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
51 |
} |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
52 |
}.writeJAASConf(); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
53 |
Security.setProperty("auth.login.defaultCallbackHandler", |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
54 |
"LoginNoPass$CallbackForClient"); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
55 |
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false"); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
56 |
|
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
57 |
try { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
58 |
Context c; |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
59 |
c = Context.fromJAAS("client"); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
60 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
61 |
c.take(new byte[0]); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
62 |
} catch (Exception e) { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
63 |
e.printStackTrace(System.out); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
64 |
// OK |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
65 |
} |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
66 |
if (kdcTouched) { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
67 |
throw new Exception("Failed"); |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
68 |
} |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
69 |
} |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
70 |
public static class CallbackForClient implements CallbackHandler { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
71 |
public void handle(Callback[] callbacks) { |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
72 |
// Do nothing |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
73 |
} |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
74 |
} |
50019af27ca3
8028351: JWS doesn't get authenticated when using kerberos auth proxy
weijun
parents:
diff
changeset
|
75 |
} |