author | msheppar |
Thu, 21 Feb 2013 20:01:22 +0000 | |
changeset 16020 | b57c48f16179 |
parent 14030 | 8dc91f5c3d67 |
child 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
14030
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
1 |
/* |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
4 |
* |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
8 |
* |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
13 |
* accompanied this code). |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
14 |
* |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
18 |
* |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
21 |
* questions. |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
22 |
*/ |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
23 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
24 |
/* |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
25 |
* @test |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
26 |
* @bug 7201053 |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
27 |
* @summary Krb5LoginModule shows NPE when both useTicketCache and storeKey |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
28 |
* are set to true |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
29 |
* @compile -XDignore.symbol.file UseCacheAndStoreKey.java |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
30 |
* @run main/othervm UseCacheAndStoreKey |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
31 |
*/ |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
32 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
33 |
import java.io.FileOutputStream; |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
34 |
import javax.security.auth.login.LoginException; |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
35 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
36 |
// The basic krb5 test skeleton you can copy from |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
37 |
public class UseCacheAndStoreKey { |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
38 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws Exception { |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
40 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
41 |
new OneKDC(null).writeJAASConf(); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
42 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
43 |
// KDC would save ccache for client |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
44 |
System.setProperty("test.kdc.save.ccache", "cache.here"); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
45 |
try (FileOutputStream fos = new FileOutputStream(OneKDC.JAAS_CONF)) { |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
46 |
fos.write(( |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
47 |
"me {\n" + |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
48 |
" com.sun.security.auth.module.Krb5LoginModule required\n" + |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
49 |
" principal=\"" + OneKDC.USER + "\"\n" + |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
50 |
" useTicketCache=true\n" + |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
51 |
" ticketCache=cache.here\n" + |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
52 |
" isInitiator=true\n" + |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
53 |
" storeKey=true;\n};\n" |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
54 |
).getBytes()); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
55 |
} |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
56 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
57 |
// The first login will use default callback and succeed |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
58 |
Context.fromJAAS("me"); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
59 |
|
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
60 |
// The second login uses ccache and won't be able to store the keys |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
61 |
try { |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
62 |
Context.fromJAAS("me"); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
63 |
throw new Exception("Should fail"); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
64 |
} catch (LoginException le) { |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
65 |
if (le.getMessage().indexOf("NullPointerException") >= 0 |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
66 |
|| le.getCause() instanceof NullPointerException) { |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
67 |
throw new Exception("NPE"); |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
68 |
} |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
69 |
} |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
70 |
} |
8dc91f5c3d67
7201053: Krb5LoginModule shows NPE when both useTicketCache and storeKey are set to true
weijun
parents:
diff
changeset
|
71 |
} |