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
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 ;
3338import sun .security .krb5 .PrincipalName ;
3439
3540public 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