Apply updated Code Style
Closes gh-13881
This commit is contained in:
@@ -43,7 +43,7 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
|
||||
private static final Log log = LogFactory.getLog(SpringSecurityAuthenticationSource.class);
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
/**
|
||||
* Get the principals of the logged in user, in this case the distinguished name.
|
||||
|
||||
@@ -233,8 +233,8 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
|
||||
this.logger.debug("Failed to locate AD-specific sub-error code in message");
|
||||
return;
|
||||
}
|
||||
this.logger.info(
|
||||
LogMessage.of(() -> "Active Directory authentication failed: " + subCodeToLogMessage(subErrorCode)));
|
||||
this.logger
|
||||
.info(LogMessage.of(() -> "Active Directory authentication failed: " + subCodeToLogMessage(subErrorCode)));
|
||||
if (this.convertSubErrorCodesToExceptions) {
|
||||
raiseExceptionForErrorCode(subErrorCode, exception);
|
||||
}
|
||||
@@ -260,41 +260,42 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
|
||||
String hexString = Integer.toHexString(code);
|
||||
Throwable cause = new ActiveDirectoryAuthenticationException(hexString, exception.getMessage(), exception);
|
||||
switch (code) {
|
||||
case PASSWORD_EXPIRED:
|
||||
throw new CredentialsExpiredException(this.messages.getMessage(
|
||||
"LdapAuthenticationProvider.credentialsExpired", "User credentials have expired"), cause);
|
||||
case ACCOUNT_DISABLED:
|
||||
throw new DisabledException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.disabled", "User is disabled"), cause);
|
||||
case ACCOUNT_EXPIRED:
|
||||
throw new AccountExpiredException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.expired", "User account has expired"), cause);
|
||||
case ACCOUNT_LOCKED:
|
||||
throw new LockedException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.locked", "User account is locked"), cause);
|
||||
default:
|
||||
throw badCredentials(cause);
|
||||
case PASSWORD_EXPIRED:
|
||||
throw new CredentialsExpiredException(this.messages.getMessage(
|
||||
"LdapAuthenticationProvider.credentialsExpired", "User credentials have expired"), cause);
|
||||
case ACCOUNT_DISABLED:
|
||||
throw new DisabledException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.disabled", "User is disabled"), cause);
|
||||
case ACCOUNT_EXPIRED:
|
||||
throw new AccountExpiredException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.expired", "User account has expired"),
|
||||
cause);
|
||||
case ACCOUNT_LOCKED:
|
||||
throw new LockedException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.locked", "User account is locked"), cause);
|
||||
default:
|
||||
throw badCredentials(cause);
|
||||
}
|
||||
}
|
||||
|
||||
private String subCodeToLogMessage(int code) {
|
||||
switch (code) {
|
||||
case USERNAME_NOT_FOUND:
|
||||
return "User was not found in directory";
|
||||
case INVALID_PASSWORD:
|
||||
return "Supplied password was invalid";
|
||||
case NOT_PERMITTED:
|
||||
return "User not permitted to logon at this time";
|
||||
case PASSWORD_EXPIRED:
|
||||
return "Password has expired";
|
||||
case ACCOUNT_DISABLED:
|
||||
return "Account is disabled";
|
||||
case ACCOUNT_EXPIRED:
|
||||
return "Account expired";
|
||||
case PASSWORD_NEEDS_RESET:
|
||||
return "User must reset password";
|
||||
case ACCOUNT_LOCKED:
|
||||
return "Account locked";
|
||||
case USERNAME_NOT_FOUND:
|
||||
return "User was not found in directory";
|
||||
case INVALID_PASSWORD:
|
||||
return "Supplied password was invalid";
|
||||
case NOT_PERMITTED:
|
||||
return "User not permitted to logon at this time";
|
||||
case PASSWORD_EXPIRED:
|
||||
return "Password has expired";
|
||||
case ACCOUNT_DISABLED:
|
||||
return "Account is disabled";
|
||||
case ACCOUNT_EXPIRED:
|
||||
return "Account expired";
|
||||
case PASSWORD_NEEDS_RESET:
|
||||
return "User must reset password";
|
||||
case ACCOUNT_LOCKED:
|
||||
return "Account locked";
|
||||
}
|
||||
return "Unknown (error code " + Integer.toHexString(code) + ")";
|
||||
}
|
||||
@@ -309,8 +310,8 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
|
||||
}
|
||||
|
||||
private InternalAuthenticationServiceException badLdapConnection(Throwable cause) {
|
||||
return new InternalAuthenticationServiceException(this.messages.getMessage(
|
||||
"LdapAuthenticationProvider.badLdapConnection", "Connection to LDAP server failed."), cause);
|
||||
return new InternalAuthenticationServiceException(this.messages
|
||||
.getMessage("LdapAuthenticationProvider.badLdapConnection", "Connection to LDAP server failed."), cause);
|
||||
}
|
||||
|
||||
private DirContextOperations searchForUser(DirContext context, String username) throws NamingException {
|
||||
|
||||
@@ -215,7 +215,7 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
|
||||
else if (tag == 1) {
|
||||
BERIntegral error = (BERIntegral) elt.getValue();
|
||||
PasswordPolicyResponseControl.this.errorStatus = PasswordPolicyErrorStatus.values()[error
|
||||
.getValue()];
|
||||
.getValue()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
|
||||
*/
|
||||
public void setSearchSubtree(boolean searchSubtree) {
|
||||
this.searchControls
|
||||
.setSearchScope(searchSubtree ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);
|
||||
.setSearchScope(searchSubtree ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,9 +157,9 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
|
||||
sb.append(getClass().getSimpleName()).append(" [");
|
||||
sb.append("searchFilter=").append(this.searchFilter).append("; ");
|
||||
sb.append("searchBase=").append(this.searchBase).append("; ");
|
||||
sb.append("scope=").append(
|
||||
(this.searchControls.getSearchScope() != SearchControls.SUBTREE_SCOPE) ? "single-level" : "subtree")
|
||||
.append("; ");
|
||||
sb.append("scope=")
|
||||
.append((this.searchControls.getSearchScope() != SearchControls.SUBTREE_SCOPE) ? "single-level" : "subtree")
|
||||
.append("; ");
|
||||
sb.append("searchTimeLimit=").append(this.searchControls.getTimeLimit()).append("; ");
|
||||
sb.append("derefLinkFlag=").append(this.searchControls.getDerefLinkFlag()).append(" ]");
|
||||
return sb.toString();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
private final Log logger = LogFactory.getLog(LdapUserDetailsManager.class);
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
/**
|
||||
* The strategy for mapping usernames to LDAP distinguished names. This will be used
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LdapUserDetailsMapper implements UserDetailsContextMapper {
|
||||
}
|
||||
// Check for PPolicy data
|
||||
PasswordPolicyResponseControl ppolicy = (PasswordPolicyResponseControl) ctx
|
||||
.getObjectAttribute(PasswordPolicyControl.OID);
|
||||
.getObjectAttribute(PasswordPolicyControl.OID);
|
||||
if (ppolicy != null) {
|
||||
essence.setTimeBeforeExpiration(ppolicy.getTimeBeforeExpiration());
|
||||
essence.setGraceLoginsRemaining(ppolicy.getGraceLoginsRemaining());
|
||||
|
||||
Reference in New Issue
Block a user