1
0
mirror of synced 2026-08-05 09:47:05 +00:00

IDEA inspection refactorings.

This commit is contained in:
Luke Taylor
2010-08-05 22:47:42 +01:00
parent a3d27a9863
commit 85c4c91e0e
175 changed files with 428 additions and 551 deletions
@@ -11,8 +11,8 @@ import org.springframework.ldap.core.DistinguishedName;
* @author Luke Taylor
*/
public class DefaultLdapUsernameToDnMapper implements LdapUsernameToDnMapper {
private String userDnBase;
private String usernameAttribute;
private final String userDnBase;
private final String usernameAttribute;
/**
* @param userDnBase the base name of the DN
@@ -164,7 +164,7 @@ public final class LdapUtils {
public static String parseRootDnFromUrl(String url) {
Assert.hasLength(url);
String urlRootDn = "";
String urlRootDn;
if (url.startsWith("ldap:") || url.startsWith("ldaps:")) {
URI uri = parseLdapUrl(url);
@@ -38,7 +38,7 @@ import java.util.List;
public abstract class AbstractLdapAuthenticator implements LdapAuthenticator, InitializingBean, MessageSourceAware {
//~ Instance fields ================================================================================================
private ContextSource contextSource;
private final ContextSource contextSource;
/** Optional search object which can be used to locate a user when a simple DN match isn't sufficient */
private LdapUserSearch userSearch;
@@ -94,8 +94,8 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator, In
String[] args = new String[] {username};
synchronized (userDnFormat) {
for (int i = 0; i < userDnFormat.length; i++) {
userDns.add(userDnFormat[i].format(args));
for (MessageFormat formatter : userDnFormat) {
userDns.add(formatter.format(args));
}
}
@@ -293,7 +293,7 @@ public class LdapAuthenticationProvider implements AuthenticationProvider, Messa
return result;
}
public boolean supports(Class<? extends Object> authentication) {
public boolean supports(Class<?> authentication) {
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
}
}
@@ -17,7 +17,7 @@ import org.springframework.util.Assert;
* @since 2.0
*/
public class UserDetailsServiceLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator {
private UserDetailsService userDetailsService;
private final UserDetailsService userDetailsService;
public UserDetailsServiceLdapAuthoritiesPopulator(UserDetailsService userService) {
Assert.notNull(userService, "userDetailsService cannot be null");
@@ -39,7 +39,7 @@ public class PasswordPolicyControl implements Control {
//~ Instance fields ================================================================================================
private boolean critical;
private final boolean critical;
//~ Constructors ===================================================================================================
@@ -35,8 +35,8 @@ public enum PasswordPolicyErrorStatus {
PASSWORD_TOO_YOUNG ("ppolicy.password.too.young", "Your password was changed too recently to be changed again"),
PASSWORD_IN_HISTORY ("ppolicy.password.in.history", "The supplied password has already been used");
private String errorCode;
private String defaultMessage;
private final String errorCode;
private final String defaultMessage;
private PasswordPolicyErrorStatus(String errorCode, String defaultMessage) {
this.errorCode = errorCode;
@@ -9,7 +9,7 @@ package org.springframework.security.ldap.ppolicy;
* @since 3.0
*/
public class PasswordPolicyException extends RuntimeException {
private PasswordPolicyErrorStatus status;
private final PasswordPolicyErrorStatus status;
public PasswordPolicyException(PasswordPolicyErrorStatus status) {
super(status.getDefaultMessage());
@@ -55,7 +55,7 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
//~ Instance fields ================================================================================================
private byte[] encodedValue;
private final byte[] encodedValue;
private PasswordPolicyErrorStatus errorStatus;
@@ -279,7 +279,7 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
}
private void setInChoice(boolean inChoice) {
this.inChoice = new Boolean(inChoice);
this.inChoice = Boolean.valueOf(inChoice);
}
}
}
@@ -48,13 +48,13 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
//~ Instance fields ================================================================================================
private ContextSource contextSource;
private final ContextSource contextSource;
/**
* The LDAP SearchControls object used for the search. Shared between searches so shouldn't be modified
* once the bean has been configured.
*/
private SearchControls searchControls = new SearchControls();
private final SearchControls searchControls = new SearchControls();
/** Context name to search in, relative to the base of the configured ContextSource. */
private String searchBase = "";
@@ -70,7 +70,7 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
* <li>(uid={0}) - this would search for a username match on the uid attribute.</li>
* </ul>
*/
private String searchFilter;
private final String searchFilter;
//~ Constructors ===================================================================================================
@@ -50,18 +50,18 @@ import org.springframework.util.Assert;
* @author Luke Taylor
*/
public class ApacheDSContainer implements InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
DefaultDirectoryService service;
final DefaultDirectoryService service;
LdapServer server;
private ApplicationContext ctxt;
private File workingDir;
private boolean running;
private String ldifResources;
private JdbmPartition partition;
private String root;
private final String ldifResources;
private final JdbmPartition partition;
private final String root;
private int port = 53389;
public ApacheDSContainer(String root, String ldifs) throws Exception {
@@ -241,8 +241,8 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
private boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
for (String child : children) {
boolean success = deleteDir(new File(dir, child));
if (!success) {
return false;
}
@@ -102,13 +102,13 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
*/
private GrantedAuthority defaultRole;
private SpringSecurityLdapTemplate ldapTemplate;
private final SpringSecurityLdapTemplate ldapTemplate;
/**
* Controls used to determine whether group searches should be performed over the full sub-tree from the
* base DN. Modified by searchSubTree property
*/
private SearchControls searchControls = new SearchControls();
private final SearchControls searchControls = new SearchControls();
/**
* The ID of the attribute which contains the role name for a group
@@ -89,7 +89,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
/** The attribute which contains members of a group */
private String groupMemberAttributeName = "uniquemember";
private String rolePrefix = "ROLE_";
private final String rolePrefix = "ROLE_";
/** The pattern to be used for the user search. {0} is the user's DN */
private String groupSearchFilter = "(uniquemember={0})";
@@ -99,7 +99,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
*/
private UserDetailsContextMapper userDetailsMapper = new InetOrgPersonContextMapper();
private LdapTemplate template;
private final LdapTemplate template;
/** Default context mapper used to create a set of roles from a list of attributes */
private AttributesMapper roleMapper = new AttributesMapper() {
@@ -70,8 +70,8 @@ public class LdapUserDetailsMapper implements UserDetailsContextMapper {
continue;
}
for (int j = 0; j < rolesForAttribute.length; j++) {
GrantedAuthority authority = createAuthority(rolesForAttribute[j]);
for (String role : rolesForAttribute) {
GrantedAuthority authority = createAuthority(role);
if (authority != null) {
essence.addAuthority(authority);