Wrap logging in if statements. Doc cleanup

This wraps logging statements in if checks.  It also removes from the documentation specific logging examples.

Original commit: elastic/x-pack-elasticsearch@3ca7cdd4f4
This commit is contained in:
c-a-m 2014-11-06 11:13:32 -07:00
parent e526065156
commit a655a77b3a
4 changed files with 19 additions and 6 deletions

@ -68,7 +68,9 @@ public class LdapConnection implements Closeable {
*/
public List<String> getGroups(){
List<String> groups = isFindGroupsByAttribute ? getGroupsFromUserAttrs(bindDn) : getGroupsFromSearch(bindDn);
logger.debug("Found these groups [{}] for userDN [{}]", groups, this.bindDn );
if (logger.isDebugEnabled()) {
logger.debug("Found these groups [{}] for userDN [{}]", groups, this.bindDn);
}
return groups;
}

@ -124,7 +124,9 @@ public class LdapGroupToRoleMapper extends AbstractComponent {
roles.add(getRelativeName(groupLdapName));
}
}
logger.debug("The roles [{}], are mapped from these LDAP groups [{}]", roles, groupDns);
if (logger.isDebugEnabled()) {
logger.debug("The roles [{}], are mapped from these LDAP groups [{}]", roles, groupDns);
}
return roles;
}

@ -112,7 +112,9 @@ public class LdapSslSocketFactory extends SocketFactory {
builder.put(JAVA_NAMING_LDAP_FACTORY_SOCKET, LdapSslSocketFactory.class.getName());
} else {
logger.warn("LdapSslSocketFactory not used for LDAP connections");
logger.debug("LdapSslSocketFactory: secureProtocol = [{}], instance != null [{}]", secureProtocol, instance != null);
if (logger.isDebugEnabled()) {
logger.debug("LdapSslSocketFactory: secureProtocol = [{}], instance != null [{}]", secureProtocol, instance != null);
}
}
}
}

@ -91,7 +91,9 @@ public abstract class CachingUsernamePasswordRealm extends AbstractComponent imp
Callable<UserWithHash> callback = new Callable<UserWithHash>() {
@Override
public UserWithHash call() throws Exception {
logger.debug("User not found in cache, proceeding with normal authentication");
if (logger.isDebugEnabled()) {
logger.debug("User not found in cache, proceeding with normal authentication");
}
User user = doAuthenticate(token);
if (user == null) {
throw new AuthenticationException("Could not authenticate [" + token.principal() + "]");
@ -103,13 +105,18 @@ public abstract class CachingUsernamePasswordRealm extends AbstractComponent imp
try {
UserWithHash userWithHash = cache.get(token.principal(), callback);
if (userWithHash.verify(token.credentials())) {
logger.debug("Authenticated user [{}], with roles [{}]", token.principal(), userWithHash.user.roles());
if(logger.isDebugEnabled()) {
logger.debug("Authenticated user [{}], with roles [{}]", token.principal(), userWithHash.user.roles());
}
return userWithHash.user;
}
//this handles when a user's password has changed:
expire(token.principal());
userWithHash = cache.get(token.principal(), callback);
logger.debug("Cached user's password changed. Authenticated user [{}], with roles [{}]", token.principal(), userWithHash.user.roles());
if (logger.isDebugEnabled()) {
logger.debug("Cached user's password changed. Authenticated user [{}], with roles [{}]", token.principal(), userWithHash.user.roles());
}
return userWithHash.user;
} catch (ExecutionException | UncheckedExecutionException ee) {