Skip to content

Commit

Permalink
[FIXED JENKINS-42030] If searchForUser fails with BadCredentialsExcep…
Browse files Browse the repository at this point in the history
…tion, wrap in a type we are allowed to throw.
  • Loading branch information
jglick committed Feb 14, 2017
1 parent 11879bf commit 7000c09
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/hudson/security/LDAPSecurityRealm.java
Expand Up @@ -102,8 +102,6 @@
import org.apache.commons.collections.map.LRUMap;
import org.apache.commons.io.input.AutoCloseInputStream;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.springframework.dao.DataAccessException;
Expand Down Expand Up @@ -942,8 +940,15 @@ public LdapUserDetails loadUserByUsername(String username) throws UsernameNotFou

return ldapUser;
} catch (LdapDataAccessException e) {
// TODO why not throw all DataAccessException up? that is why it is in the declared clause
LOGGER.log(Level.WARNING, "Failed to search LDAP for username="+username,e);
throw new UserMayOrMayNotExistException(e.getMessage(),e);
} catch (UsernameNotFoundException x) {
throw x;
} catch (DataAccessException x) {
throw x;
} catch (RuntimeException x) {
throw new LdapDataAccessException("Failed to search LDAP for " + username + ": " + x, x);
}
}
}
Expand Down

0 comments on commit 7000c09

Please sign in to comment.