@ -72,7 +73,7 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource {
@@ -72,7 +73,7 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource {
"Root DNs must be the same when using multiple URLs");
rootDn=(rootDn!=null)?rootDn:urlRootDn;
@ -89,7 +90,7 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource {
@@ -89,7 +90,7 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource {
// Remove the pooling flag unless authenticating as the 'manager' user.
@ -166,7 +166,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@@ -166,7 +166,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@ -223,7 +223,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@@ -223,7 +223,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
logger.debug(LogMessage.format("No attribute value found for '%s'",attributeName));
logger.debug(LogMessage.format("Did not find attribute value for %s",attributeName));
return;
}
List<String>stringValues=newArrayList<>();
@ -233,9 +233,9 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@@ -233,9 +233,9 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
stringValues.add((String)value);
}
else{
logger.debug(LogMessage.format("Attribute:%s contains a non string value of type[%s]",
attributeName,value.getClass()));
stringValues.add(value.toString());
logger.debug(LogMessage.format("Coerced attribute value for %s of type %s to a String",
attributeName,value.getClass()));
}
}
}
@ -270,7 +270,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@@ -270,7 +270,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
logger.debug(LogMessage.format("Searching for entry under DN '%s', base = '%s', filter = '%s'",ctxBaseDn,
logger.trace(LogMessage.format("Searching for entry under DN '%s', base = '%s', filter = '%s'",ctxBaseDn,
searchBaseDn,filter));
Set<DirContextOperations>results=newHashSet<>();
try{
@ -284,7 +284,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@@ -284,7 +284,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
@ -68,7 +67,6 @@ public abstract class AbstractLdapAuthenticationProvider implements Authenticati
@@ -68,7 +67,6 @@ public abstract class AbstractLdapAuthenticationProvider implements Authenticati
@ -104,6 +102,7 @@ public abstract class AbstractLdapAuthenticationProvider implements Authenticati
@@ -104,6 +102,7 @@ public abstract class AbstractLdapAuthenticationProvider implements Authenticati
@ -65,7 +65,7 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@@ -65,7 +65,7 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@ -76,11 +76,18 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@@ -76,11 +76,18 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
break;
}
}
if(user==null){
logger.debug(LogMessage.of(()->"Failed to bind with any user DNs "+getUserDns(username)));
}
// Otherwise use the configured search object to find the user and authenticate
// with the returned DN.
if(user==null&&getUserSearch()!=null){
logger.trace("Searching for user using "+getUserSearch());
logger.debug("Failed to find user using "+getUserSearch());
}
}
if(user==null){
thrownewBadCredentialsException(
@ -98,13 +105,12 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@@ -98,13 +105,12 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@ -112,6 +118,7 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@@ -112,6 +118,7 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@ -141,7 +148,7 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@@ -141,7 +148,7 @@ public class BindAuthenticator extends AbstractLdapAuthenticator {
@ -76,25 +76,37 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic
@@ -76,25 +76,37 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic
@ -48,7 +48,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
@@ -48,7 +48,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
log.warn("No Authentication object set in SecurityContext - returning empty String as Principal");
log.debug("Returning empty String as Principal since authentication is null");
return"";
}
Objectprincipal=authentication.getPrincipal();
@ -57,7 +57,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
@@ -57,7 +57,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
log.debug("Anonymous Authentication, returning empty String as Principal");
log.debug("Returning empty String as Principal since authentication is anonymous");
return"";
}
thrownewIllegalArgumentException(
@ -71,7 +71,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
@@ -71,7 +71,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
@ -50,8 +50,7 @@ public class PasswordPolicyAwareContextSource extends DefaultSpringSecurityConte
@@ -50,8 +50,7 @@ public class PasswordPolicyAwareContextSource extends DefaultSpringSecurityConte
if(principal.equals(this.userDn)){
returnsuper.getContext(principal,credentials);
}
this.logger
.debug(LogMessage.format("Binding as '%s', prior to reconnect as user '%s'",this.userDn,principal));
this.logger.trace(LogMessage.format("Binding as %s, prior to reconnect as user %s",this.userDn,principal));
// First bind as manager user before rebinding as the specific principal.
@ -63,8 +62,7 @@ public class PasswordPolicyAwareContextSource extends DefaultSpringSecurityConte
@@ -63,8 +62,7 @@ public class PasswordPolicyAwareContextSource extends DefaultSpringSecurityConte
this.logger.debug(LogMessage.format("Failed to bind with %s",ctrl),ex);
}
LdapUtils.closeContext(ctx);
if(ctrl!=null&&ctrl.isLocked()){
@ -72,8 +70,7 @@ public class PasswordPolicyAwareContextSource extends DefaultSpringSecurityConte
@@ -72,8 +70,7 @@ public class PasswordPolicyAwareContextSource extends DefaultSpringSecurityConte
}
throwLdapUtils.convertLdapException(ex);
}
this.logger.debug(
LogMessage.of(()->"PPolicy control returned: "+PasswordPolicyControlExtractor.extractControl(ctx)));
this.logger.debug(LogMessage.of(()->"Bound with "+PasswordPolicyControlExtractor.extractControl(ctx)));
@ -158,19 +159,21 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
@@ -158,19 +159,21 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
sb.append(", warning: time before expiration is ").append(this.timeBeforeExpiration);
sb.append("warning=time before expiration is ").append(this.timeBeforeExpiration).append("; ");
}
if(!hasError()&&!hasWarning()){
sb.append("(no error, no warning)");
sb.append("(no error, no warning)");
}
sb.append("]");
returnsb.toString();
}
@ -192,7 +195,8 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
@@ -192,7 +195,8 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
@ -79,8 +79,8 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
@@ -79,8 +79,8 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
this.searchBase=searchBase;
setSearchSubtree(true);
if(searchBase.length()==0){
logger.info(
"SearchBase not set. Searches will be performed from the root: "+contextSource.getBaseLdapPath());
logger.info(LogMessage.format("Searches will be performed from the root %s since SearchBase not set",
contextSource.getBaseLdapPath()));
}
}
@ -93,11 +93,14 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
@@ -93,11 +93,14 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
logger.debug(LogMessage.of(()->"Found user '"+username+"', with "+this));
returnoperations;
}
catch(IncorrectResultSizeDataAccessExceptionex){
if(ex.getActualSize()==0){
@ -151,12 +154,14 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
@@ -151,12 +154,14 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
@ -163,10 +163,10 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
@@ -163,10 +163,10 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
@ -199,7 +199,6 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
@@ -199,7 +199,6 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
@ -210,6 +209,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
@@ -210,6 +209,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
logger.debug(LogMessage.format("Retrieved authorities for user %s",userDn));
returnresult;
}
@ -218,12 +218,12 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
@@ -218,12 +218,12 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
returnnewHashSet<>();
}
Set<GrantedAuthority>authorities=newHashSet<>();
logger.debug(LogMessage.of(()->"Searching for roles for user '"+username+"', DN = "+"'"+userDn
+"', with filter "+this.groupSearchFilter+" in search base '"+getGroupSearchBase()+"'"));
logger.trace(LogMessage.of(()->"Searching for roles for user "+username+" with DN "+userDn
+" and filter "+this.groupSearchFilter+" in search base "+getGroupSearchBase()));
@ -146,30 +146,16 @@ public class LdapUserDetailsImpl implements LdapUserDetails, PasswordPolicyData
@@ -146,30 +146,16 @@ public class LdapUserDetailsImpl implements LdapUserDetails, PasswordPolicyData
@ -54,7 +54,7 @@ public class LdapUserDetailsMapper implements UserDetailsContextMapper {
@@ -54,7 +54,7 @@ public class LdapUserDetailsMapper implements UserDetailsContextMapper {
@ -67,7 +67,7 @@ public class LdapUserDetailsMapper implements UserDetailsContextMapper {
@@ -67,7 +67,7 @@ public class LdapUserDetailsMapper implements UserDetailsContextMapper {
@ -166,13 +166,13 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
@@ -166,13 +166,13 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
logger.debug(LogMessage.of(()->"Search aborted, max depth reached,"+" for roles for user '"+username
+"', DN = "+"'"+userDn+"', with filter "+getGroupSearchFilter()+" in search base '"
logger.debug(LogMessage.of(()->"Aborted search since max depth reached,"+" for roles for user '"
+username+" with DN = "+userDn+" and filter "+getGroupSearchFilter()+" in search base '"
+getGroupSearchBase()+"'"));
return;
}
logger.debug(LogMessage.of(()->"Searching for roles for user '"+username+"', DN = "+"'"+userDn
+"', with filter "+getGroupSearchFilter()+" in search base '"+getGroupSearchBase()+"'"));
logger.trace(LogMessage.of(()->"Searching for roles for user "+username+" with DN "+userDn
+" and filter "+getGroupSearchFilter()+" in search base "+getGroupSearchBase()));
if(getAttributeNames()==null){
setAttributeNames(newHashSet<>());
}
@ -182,7 +182,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
@@ -182,7 +182,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula