[KYUUBI #6396] Add caching for KerberosAuthentication using ticketCache key
This pull request fixes #6396
By using a cache to store CachingKerberosAuthentication objects keyed by the ticket cache path, we ensure that each unique ticket cache path generates a distinct authentication object.
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
---
- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #6401 from lsm1/branch-kyuubi-6396.
Closes #6396
bb8f738e1 [senmiaoliu] fix kyuubiClientTicketCache
Authored-by: senmiaoliu <senmiaoliu@trip.com>
Signed-off-by: Shaoyun Chen <csy@apache.org>
(cherry picked from commit 4285abc3ae)
This commit is contained in:
parent
7e6503d456
commit
89ea49f203
@ -22,18 +22,19 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class KerberosAuthenticationManager {
|
||||
|
||||
private static CachingKerberosAuthentication GLOBAL_TGT_CACHE_AUTHENTICATION;
|
||||
private static final Map<String, CachingKerberosAuthentication> TGT_CACHE_AUTHENTICATION_CACHE =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<String, CachingKerberosAuthentication> KEYTAB_AUTHENTICATION_CACHE =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
public static synchronized CachingKerberosAuthentication getTgtCacheAuthentication(
|
||||
String ticketCache) {
|
||||
if (GLOBAL_TGT_CACHE_AUTHENTICATION == null) {
|
||||
KerberosAuthentication tgtCacheAuth = new KerberosAuthentication(ticketCache);
|
||||
GLOBAL_TGT_CACHE_AUTHENTICATION = new CachingKerberosAuthentication(tgtCacheAuth);
|
||||
}
|
||||
return GLOBAL_TGT_CACHE_AUTHENTICATION;
|
||||
public static CachingKerberosAuthentication getTgtCacheAuthentication(String ticketCache) {
|
||||
return TGT_CACHE_AUTHENTICATION_CACHE.computeIfAbsent(
|
||||
ticketCache,
|
||||
key -> {
|
||||
KerberosAuthentication tgtCacheAuth = new KerberosAuthentication(ticketCache);
|
||||
return new CachingKerberosAuthentication(tgtCacheAuth);
|
||||
});
|
||||
}
|
||||
|
||||
public static CachingKerberosAuthentication getKeytabAuthentication(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user