From be58e138d08eaf2b590f2266c01ff1012363ed22 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 13 Nov 2024 10:36:11 -0800 Subject: [PATCH] [JENKINS-74842] `ClassCastException` in `ReverseProxySecurityRealm#loadGroupByGroupname2` (#153) --- .../reverse_proxy_auth/ReverseProxySecurityRealm.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/reverse_proxy_auth/ReverseProxySecurityRealm.java b/src/main/java/org/jenkinsci/plugins/reverse_proxy_auth/ReverseProxySecurityRealm.java index ef0c4c9..ffd28e0 100644 --- a/src/main/java/org/jenkinsci/plugins/reverse_proxy_auth/ReverseProxySecurityRealm.java +++ b/src/main/java/org/jenkinsci/plugins/reverse_proxy_auth/ReverseProxySecurityRealm.java @@ -785,8 +785,10 @@ public GroupDetails loadGroupByGroupname2(String groupname, boolean fetchMembers // TODO: obtain a DN instead so that we can obtain multiple attributes later String searchBase = groupSearchBase != null ? groupSearchBase : ""; String searchFilter = groupSearchFilter != null ? groupSearchFilter : GROUP_SEARCH; - groups = ldapTemplate.searchForSingleAttributeValues( - searchBase, searchFilter, new String[] {groupname}, "cn"); + try (SetContextClassLoader sccl = new SetContextClassLoader(ReverseProxySecurityRealm.class)) { + groups = ldapTemplate.searchForSingleAttributeValues( + searchBase, searchFilter, new String[] {groupname}, "cn"); + } } else { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Collection authorities =