Skip to content

Commit eb5c097

Browse files
committedApr 6, 2021
8262389: Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
Reviewed-by: mullan
1 parent bfb034a commit eb5c097

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
 

‎src/java.security.jgss/share/classes/sun/security/krb5/Config.java

+3
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,9 @@ public void listTable() {
979979
public int[] defaultEtype(String configName) throws KrbException {
980980
String default_enctypes;
981981
default_enctypes = get("libdefaults", configName);
982+
if (default_enctypes == null && !configName.equals("permitted_enctypes")) {
983+
default_enctypes = get("libdefaults", "permitted_enctypes");
984+
}
982985
int[] etype;
983986
if (default_enctypes == null) {
984987
if (DEBUG) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
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+
*
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.
22+
*/
23+
/*
24+
* @test
25+
* @bug 8262389
26+
* @modules java.security.jgss/sun.security.krb5
27+
* @library /test/lib
28+
* @summary Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
29+
*/
30+
31+
import jdk.test.lib.Asserts;
32+
import sun.security.krb5.Config;
33+
34+
import java.nio.file.Files;
35+
import java.nio.file.Path;
36+
import java.util.List;
37+
38+
public class Permitted {
39+
public static void main(String[] args) throws Exception {
40+
41+
System.setProperty("java.security.krb5.conf", "permitted.conf");
42+
43+
Files.write(Path.of("permitted.conf"), List.of("[libdefaults]",
44+
"permitted_enctypes = aes128-cts"));
45+
Config.refresh();
46+
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tkt_enctypes").length, 1);
47+
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tgs_enctypes").length, 1);
48+
49+
Files.write(Path.of("permitted.conf"), List.of("[libdefaults]",
50+
"default_tkt_enctypes = aes128-cts aes256-cts",
51+
"default_tgs_enctypes = aes128-cts aes256-cts aes256-sha2",
52+
"permitted_enctypes = aes128-cts"));
53+
Config.refresh();
54+
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tkt_enctypes").length, 2);
55+
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tgs_enctypes").length, 3);
56+
}
57+
}

0 commit comments

Comments
 (0)
Please sign in to comment.