Skip to content
Permalink
Browse files
8262389: Use permitted_enctypes if default_tkt_enctypes or default_tg…
…s_enctypes is not present

Reviewed-by: mullan
  • Loading branch information
wangweij committed Apr 6, 2021
1 parent bfb034a commit eb5c097b6ded9646d4ba3cd9bf18c8a20494fc95
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
@@ -979,6 +979,9 @@ public void listTable() {
public int[] defaultEtype(String configName) throws KrbException {
String default_enctypes;
default_enctypes = get("libdefaults", configName);
if (default_enctypes == null && !configName.equals("permitted_enctypes")) {
default_enctypes = get("libdefaults", "permitted_enctypes");
}
int[] etype;
if (default_enctypes == null) {
if (DEBUG) {
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8262389
* @modules java.security.jgss/sun.security.krb5
* @library /test/lib
* @summary Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
*/

import jdk.test.lib.Asserts;
import sun.security.krb5.Config;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

public class Permitted {
public static void main(String[] args) throws Exception {

System.setProperty("java.security.krb5.conf", "permitted.conf");

Files.write(Path.of("permitted.conf"), List.of("[libdefaults]",
"permitted_enctypes = aes128-cts"));
Config.refresh();
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tkt_enctypes").length, 1);
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tgs_enctypes").length, 1);

Files.write(Path.of("permitted.conf"), List.of("[libdefaults]",
"default_tkt_enctypes = aes128-cts aes256-cts",
"default_tgs_enctypes = aes128-cts aes256-cts aes256-sha2",
"permitted_enctypes = aes128-cts"));
Config.refresh();
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tkt_enctypes").length, 2);
Asserts.assertEQ(Config.getInstance().defaultEtype("default_tgs_enctypes").length, 3);
}
}

1 comment on commit eb5c097

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on eb5c097 Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.