Skip to content

Commit 02e6d0b

Browse files
Alexey Bakhtinsunyuqi-syq
authored andcommitted
[Misc] Backport JDK-8374888 to fix sun/security/krb5/auto/UserIterCount.java failure
Summary: Backport JDK-8374888 to fix sun/security/krb5/auto/UserIterCount.java failure Testing: sun/security/krb5/auto/UserIterCount.java Reviewers: MaxXSoft, D-D-H Backport-of: 99c2cd01c3f82b37ef7faac38a1b92a083c1ab91 Issue: #984
1 parent e7c722b commit 02e6d0b

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

test/jdk/sun/security/krb5/auto/UserIterCount.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,19 @@
3030
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
3131
* @run main/othervm -Djdk.net.hosts.file=TestHosts UserIterCount
3232
*/
33+
34+
import java.util.HashMap;
35+
36+
import sun.security.krb5.EncryptionKey;
37+
import sun.security.krb5.KrbException;
3338
import sun.security.krb5.PrincipalName;
3439

3540
public class UserIterCount {
3641

3742
static class MyKDC extends OneKDC {
43+
static final HashMap<String, EncryptionKey> CACHE
44+
= new HashMap<>();
45+
3846
public MyKDC() throws Exception {
3947
super(null);
4048
}
@@ -51,6 +59,18 @@ protected byte[] getParams(PrincipalName p, int etype) {
5159
return super.getParams(p, etype);
5260
}
5361
}
62+
63+
@Override
64+
EncryptionKey keyForUser(PrincipalName p, int etype, boolean server)
65+
throws KrbException {
66+
var key = p.toString() + etype + server;
67+
var v = CACHE.get(key);
68+
if (v == null) {
69+
v = super.keyForUser(p, etype, server);
70+
CACHE.put(key, v);
71+
}
72+
return v;
73+
}
5474
}
5575

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

0 commit comments

Comments
 (0)