Skip to content

Commit

Permalink
[JENKINS-69958] Properly overload the loadGroupByGroupname2 to fix er… (
Browse files Browse the repository at this point in the history
#283)

* [JENKINS-69958] Properly overload the loadGroupByGroupname2 to fix error handling

* [JENKINS-69958] Preserve javadoc
  • Loading branch information
Dohbedoh authored Oct 27, 2022
1 parent a7b367d commit bdf00ce
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/main/java/org/jenkinsci/plugins/saml/SamlSecurityRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -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.
*/
Expand Down

0 comments on commit bdf00ce

Please sign in to comment.