From bdf00ce0c111c5ada3463222da153d3823d00d3f Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Thu, 27 Oct 2022 19:40:55 +1000 Subject: [PATCH] =?UTF-8?q?[JENKINS-69958]=20Properly=20overload=20the=20l?= =?UTF-8?q?oadGroupByGroupname2=20to=20fix=20er=E2=80=A6=20(#283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [JENKINS-69958] Properly overload the loadGroupByGroupname2 to fix error handling * [JENKINS-69958] Preserve javadoc --- .../plugins/saml/SamlSecurityRealm.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/saml/SamlSecurityRealm.java b/src/main/java/org/jenkinsci/plugins/saml/SamlSecurityRealm.java index 4c2419c6..87736d4e 100644 --- a/src/main/java/org/jenkinsci/plugins/saml/SamlSecurityRealm.java +++ b/src/main/java/org/jenkinsci/plugins/saml/SamlSecurityRealm.java @@ -29,7 +29,6 @@ import javax.servlet.http.HttpSession; import edu.umd.cs.findbugs.annotations.NonNull; import org.acegisecurity.Authentication; -import org.acegisecurity.userdetails.UsernameNotFoundException; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.saml.conf.Attribute; @@ -50,7 +49,6 @@ import org.pac4j.core.exception.http.OkAction; import org.pac4j.core.exception.http.RedirectionAction; import org.pac4j.core.exception.http.SeeOtherAction; -import org.springframework.dao.DataAccessException; import org.pac4j.saml.profile.SAML2Profile; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.GrantedAuthority; @@ -630,9 +628,8 @@ public void doLogout(StaplerRequest req, StaplerResponse rsp) throws IOException * This method is overwritten due to SAML has no way to retrieve the members of a Group and this cause issues on * some Authorization plugins. Because of that we have to implement SamlGroupDetails */ - @SuppressWarnings("deprecation") @Override - public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { + public GroupDetails loadGroupByGroupname2(String groupname, boolean fetchMembers) throws org.springframework.security.core.userdetails.UsernameNotFoundException { GroupDetails dg = new SamlGroupDetails(groupname); if (dg.getMembers().isEmpty()) { @@ -641,21 +638,6 @@ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFou return dg; } - /** - * This method is overwritten due to SAML has no way to retrieve the members of a Group and this cause issues on - * some Authorization plugins. Because of that we have to implement SamlGroupDetails - */ - @SuppressWarnings("deprecation") - @Override - public GroupDetails loadGroupByGroupname(String groupname, boolean fetchMembers) - throws UsernameNotFoundException, DataAccessException { - GroupDetails dg = loadGroupByGroupname(groupname); - if (fetchMembers) { - dg.getMembers(); - } - return dg; - } - /** * @return plugin configuration parameters. */