Skip to content

Commit

Permalink
[JENKINS-44743] Fix findbugs warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rsandell committed Jun 9, 2017
1 parent 9f18009 commit 82b6bdb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/main/java/hudson/security/LDAPSecurityRealm.java
Expand Up @@ -675,13 +675,15 @@ public boolean hasMultiConfiguration() {

@CheckForNull @Restricted(NoExternalUse.class)
public LDAPConfiguration getConfigurationFor(String configurationId) {
for (LDAPConfiguration configuration : configurations) {
if (configuration.isConfiguration(configurationId)) {
return configuration;
if (configurations != null) {
for (LDAPConfiguration configuration : configurations) {
if (configuration.isConfiguration(configurationId)) {
return configuration;
}
}
if (configurations.size() == 1) {
return configurations.get(0);
}
}
if (configurations != null && configurations.size() == 1) {
return configurations.get(0);
}
return null;
}
Expand Down
Expand Up @@ -43,6 +43,7 @@
import org.acegisecurity.ldap.LdapTemplate;
import org.acegisecurity.ldap.search.FilterBasedLdapUserSearch;
import org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator;
import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.digester.Digester;
import org.apache.commons.httpclient.util.URIUtil;
Expand Down Expand Up @@ -501,21 +502,21 @@ private String generateId() {
@Restricted(NoExternalUse.class)
static String generateId(String serverUrl, String rootDN, String userSearchBase, String userSearch) {
final MessageDigest digest = DigestUtils.getMd5Digest();
digest.update(normalizeServer(serverUrl).getBytes());
digest.update(normalizeServer(serverUrl).getBytes(Charsets.UTF_8));
if (StringUtils.isNotBlank(rootDN)) {
digest.update(rootDN.getBytes()); //Should have been inferred in the constructor if needed
digest.update(rootDN.getBytes(Charsets.UTF_8)); //Should have been inferred in the constructor if needed
} else {
digest.update(new byte[]{0});
}
if (StringUtils.isNotBlank(userSearchBase)) {
digest.update(userSearchBase.getBytes());
digest.update(userSearchBase.getBytes(Charsets.UTF_8));
} else {
digest.update(new byte[]{0});
}
if (StringUtils.isNotBlank(userSearch)) {
digest.update(userSearch.getBytes());
digest.update(userSearch.getBytes(Charsets.UTF_8));
} else {
digest.update(LDAPConfigurationDescriptor.DEFAULT_USER_SEARCH.getBytes());
digest.update(LDAPConfigurationDescriptor.DEFAULT_USER_SEARCH.getBytes(Charsets.UTF_8));
}
return new String(Base64.encode(digest.digest()));
}
Expand Down

0 comments on commit 82b6bdb

Please sign in to comment.