From 961f1e5c24e6c23858664ce739b84e65ded8fdeb Mon Sep 17 00:00:00 2001 From: Patrick Dowler Date: Fri, 20 Oct 2023 13:12:35 -0700 Subject: [PATCH] cadc-access-control-server: handle invalid group names in ldap --- cadc-access-control-server/build.gradle | 2 +- .../java/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cadc-access-control-server/build.gradle b/cadc-access-control-server/build.gradle index c8bc364c..15df99d2 100644 --- a/cadc-access-control-server/build.gradle +++ b/cadc-access-control-server/build.gradle @@ -13,7 +13,7 @@ sourceCompatibility = 1.8 group = 'org.opencadc' -version = '1.3.33' +version = '1.3.34' description = 'OpenCADC User+Group server library' def git_url = 'https://github.com/opencadc/ac' diff --git a/cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java b/cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java index dc295b7f..0d303630 100755 --- a/cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java +++ b/cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java @@ -797,7 +797,9 @@ public Group getGroup(final int gid) Group ldapGroup = createGroupFromSearchResult(searchEntry, PUB_GROUP_ATTRS, ldapConn); return ldapGroup; - + } catch (IllegalArgumentException ex) { + // invalid group name + throw new GroupNotFoundException("porobably invalid group name: " + ex); } catch (LDAPException e1) { logger.debug("getGroup Exception: " + e1, e1); LdapDAO.checkLdapResult(e1.getResultCode()); @@ -867,9 +869,10 @@ private Group getGroup(final DN groupDN, final String loggableID, String[] attri profiler.checkpoint("getGroup.addMembers"); return ldapGroup; - } - catch (LDAPException e1) - { + } catch (IllegalArgumentException ex) { + // invalid group name + throw new GroupNotFoundException("porobably invalid group name: " + ex); + } catch (LDAPException e1) { logger.debug("getGroup Exception: " + e1, e1); LdapDAO.checkLdapResult(e1.getResultCode()); throw new RuntimeException("BUG: checkLdapResult didn't throw an exception");