author | alanb |
Thu, 01 Dec 2016 08:57:53 +0000 | |
changeset 42338 | a60f280f803c |
parent 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
76 | 1 |
/* |
9008
1c23e333dd76
7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
76 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
76 | 22 |
*/ |
23 |
/* |
|
24 |
* @test |
|
25 |
* @bug 6590930 |
|
30820 | 26 |
* @modules java.security.jgss/sun.security.krb5 |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30820
diff
changeset
|
27 |
* java.security.jgss/sun.security.krb5.internal.ccache:+open |
9008
1c23e333dd76
7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports
weijun
parents:
5506
diff
changeset
|
28 |
* @run main/othervm TimeInCCache |
76 | 29 |
* @summary read/write does not match for ccache |
30 |
*/ |
|
31 |
||
32 |
import java.io.ByteArrayInputStream; |
|
33 |
import java.lang.reflect.Method; |
|
22093
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
34 |
|
76 | 35 |
import sun.security.krb5.internal.ccache.CCacheInputStream; |
36 |
import sun.security.krb5.internal.ccache.Credentials; |
|
37 |
||
38 |
public class TimeInCCache { |
|
25169
365cba5326f9
8048073: Cannot read ccache entry with a realm-less service name
weijun
parents:
22093
diff
changeset
|
39 |
// Attention: this field is also used by 2 other tests: |
365cba5326f9
8048073: Cannot read ccache entry with a realm-less service name
weijun
parents:
22093
diff
changeset
|
40 |
// CorruptedCC.java and EmptyRealmCC.java |
22093
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
41 |
public static byte[] ccache; |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
42 |
|
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
43 |
static { |
76 | 44 |
// A trivial cache file, with startdate and renewTill being zero. |
45 |
// The endtime is set to sometime in year 2022, so that isValid() |
|
46 |
// will always check starttime. |
|
22093
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
47 |
String var = |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
48 |
/*0000*/ "05 04 00 0C 00 01 00 08 FF FF FF 13 FF FE 59 33 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
49 |
/*0010*/ "00 00 00 01 00 00 00 01 00 00 00 0A 4D 41 58 49 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
50 |
/*0020*/ "2E 4C 4F 43 41 4C 00 00 00 05 64 75 6D 6D 79 00 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
51 |
/*0030*/ "00 00 01 00 00 00 01 00 00 00 0A 4D 41 58 49 2E " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
52 |
/*0040*/ "4C 4F 43 41 4C 00 00 00 05 64 75 6D 6D 79 00 00 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
53 |
/*0050*/ "00 00 00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
54 |
/*0060*/ "4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
55 |
/*0070*/ "00 0A 4D 41 58 49 2E 4C 4F 43 41 4C 00 11 00 00 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
56 |
/*0080*/ "00 10 B2 AB A6 CE BC 73 44 08 D9 93 5B 3D EF E5 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
57 |
/*0090*/ "86 88 47 45 10 87 00 00 00 00 62 45 10 87 00 00 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
58 |
/*00A0*/ "00 00 00 40 E0 00 00 00 00 00 00 00 00 00 00 00 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
59 |
/*00B0*/ "00 01 00 61 81 FD 30 81 FA A0 03 02 01 05 A1 0C " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
60 |
/*00C0*/ "1B 0A 4D 41 58 49 2E 4C 4F 43 41 4C A2 1F 30 1D " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
61 |
/*00D0*/ "A0 03 02 01 00 A1 16 30 14 1B 06 6B 72 62 74 67 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
62 |
/*00E0*/ "74 1B 0A 4D 41 58 49 2E 4C 4F 43 41 4C A3 81 C3 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
63 |
/*00F0*/ "30 81 C0 A0 03 02 01 11 A1 03 02 01 01 A2 81 B3 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
64 |
/*0100*/ "04 81 B0 2B 41 BE 22 15 DE 25 23 20 32 F2 7A 4D " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
65 |
/*0110*/ "FD E3 25 63 32 7D D5 A0 B2 55 17 29 B0 44 02 93 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
66 |
/*0120*/ "E5 26 D7 B8 E0 7F 3F B4 EA 51 21 8E E2 68 7D AF " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
67 |
/*0130*/ "E3 46 E7 17 64 B5 E7 3E 88 B2 C3 9C B6 32 8B 81 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
68 |
/*0140*/ "F0 4F 96 3E D9 5B 64 F6 17 A8 EE D1 33 ED 71 12 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
69 |
/*0150*/ "62 9B 1F 62 16 AF 0B D7 D6 43 57 5C FE 2A CA 4F " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
70 |
/*0160*/ "31 A6 2B DB 5A 9A 7D 3E A8 B3 64 66 17 C7 CD 26 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
71 |
/*0170*/ "44 D4 C7 9A 67 FA 55 C6 4A 8B A9 43 99 DC 6E 86 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
72 |
/*0180*/ "73 0C 76 96 8E CD 4F 44 20 A5 CB FB CD 59 48 46 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
73 |
/*0190*/ "7B F4 A1 09 28 E2 8B 4A 4D 26 5B 7E AE 11 62 62 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
74 |
/*01A0*/ "CF 4E 24 24 67 B4 9C E9 76 A4 F8 50 67 E9 9E 38 " + |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
75 |
/*01B0*/ "15 41 B3 00 00 00 00 "; |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
76 |
ccache = new byte[var.length()/3]; |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
77 |
for (int i=0; i<ccache.length; i++) { |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
78 |
ccache[i] = Integer.valueOf(var.substring(3*i,3*i+2), 16).byteValue(); |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
79 |
} |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
80 |
} |
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
81 |
|
741504ef3df7
8028780: JDK KRB5 module throws OutOfMemoryError when CCache is corrupt
weijun
parents:
9008
diff
changeset
|
82 |
public static void main(String[] args) throws Exception { |
76 | 83 |
System.setProperty("sun.security.krb5.debug", "true"); // test code changes in DEBUG |
84 |
CCacheInputStream cis = new CCacheInputStream(new ByteArrayInputStream(ccache)); |
|
85 |
cis.readVersion(); |
|
86 |
cis.readTag(); |
|
87 |
cis.readPrincipal(0x504); |
|
88 |
Method m = CCacheInputStream.class.getDeclaredMethod("readCred", Integer.TYPE); |
|
89 |
m.setAccessible(true); |
|
90 |
Credentials c = (Credentials) m.invoke(cis, new Integer(0x504)); |
|
91 |
sun.security.krb5.Credentials cc = c.setKrbCreds(); |
|
92 |
||
93 |
// 1. Make sure starttime is still null |
|
94 |
if (cc.getStartTime() != null) { |
|
95 |
throw new Exception("Fail, starttime should be zero here"); |
|
96 |
} |
|
97 |
||
98 |
// 2. Make sure renewTill is still null |
|
99 |
if (cc.getRenewTill() != null) { |
|
100 |
throw new Exception("Fail, renewTill should be zero here"); |
|
101 |
} |
|
102 |
||
103 |
// 3. Make sure isValid works |
|
104 |
c.isValid(); |
|
105 |
} |
|
106 |
} |