IDEA inspection refactorings.
This commit is contained in:
+1
-1
@@ -128,7 +128,7 @@ public class AuthenticationManagerBeanDefinitionParser implements BeanDefinition
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean supports(Class<? extends Object> authentication) {
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import org.w3c.dom.Element;
|
||||
* @author Luke Taylor
|
||||
*/
|
||||
public class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser {
|
||||
private static String ATT_USER_DETAILS_REF = "user-service-ref";
|
||||
private static final String ATT_USER_DETAILS_REF = "user-service-ref";
|
||||
|
||||
public BeanDefinition parse(Element element, ParserContext pc) {
|
||||
RootBeanDefinition authProvider = new RootBeanDefinition(DaoAuthenticationProvider.class);
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class CachingUserDetailsService implements UserDetailsService {
|
||||
private UserCache userCache = new NullUserCache();
|
||||
private UserDetailsService delegate;
|
||||
private final UserDetailsService delegate;
|
||||
|
||||
CachingUserDetailsService(UserDetailsService delegate) {
|
||||
this.delegate = delegate;
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class PasswordEncoderParser {
|
||||
ENCODER_CLASSES.put(OPT_HASH_LDAP_SSHA, LdapShaPasswordEncoder.class);
|
||||
}
|
||||
|
||||
private static Log logger = LogFactory.getLog(PasswordEncoderParser.class);
|
||||
private static final Log logger = LogFactory.getLog(PasswordEncoderParser.class);
|
||||
|
||||
private BeanMetadataElement passwordEncoder;
|
||||
private BeanMetadataElement saltSource;
|
||||
@@ -69,7 +69,7 @@ public class PasswordEncoderParser {
|
||||
boolean useBase64 = false;
|
||||
|
||||
if (StringUtils.hasText(element.getAttribute(ATT_BASE_64))) {
|
||||
useBase64 = new Boolean(element.getAttribute(ATT_BASE_64)).booleanValue();
|
||||
useBase64 = Boolean.valueOf(element.getAttribute(ATT_BASE_64)).booleanValue();
|
||||
}
|
||||
|
||||
String ref = element.getAttribute(ATT_REF);
|
||||
|
||||
+2
-2
@@ -65,8 +65,8 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
||||
|
||||
ManagedList<BeanDefinition> users = new ManagedList<BeanDefinition>();
|
||||
|
||||
for (Iterator i = userElts.iterator(); i.hasNext();) {
|
||||
Element userElt = (Element) i.next();
|
||||
for (Object elt : userElts) {
|
||||
Element userElt = (Element) elt;
|
||||
String userName = userElt.getAttribute(ATT_NAME);
|
||||
String password = userElt.getAttribute(ATT_PASSWORD);
|
||||
|
||||
|
||||
+6
-12
@@ -72,8 +72,8 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
private static final String ATT_USER_SERVICE_REF = "user-service-ref";
|
||||
|
||||
private Element httpElt;
|
||||
private ParserContext pc;
|
||||
private final Element httpElt;
|
||||
private final ParserContext pc;
|
||||
|
||||
private final boolean autoConfig;
|
||||
private final boolean allowSessionCreation;
|
||||
@@ -90,21 +90,18 @@ final class AuthenticationConfigBuilder {
|
||||
private RootBeanDefinition openIDFilter;
|
||||
private BeanDefinition openIDEntryPoint;
|
||||
private BeanReference openIDProviderRef;
|
||||
private String openIDProviderId;
|
||||
private String formFilterId = null;
|
||||
private String openIDFilterId = null;
|
||||
private BeanDefinition x509Filter;
|
||||
private BeanReference x509ProviderRef;
|
||||
private String x509ProviderId;
|
||||
private BeanDefinition jeeFilter;
|
||||
private BeanReference jeeProviderRef;
|
||||
private RootBeanDefinition preAuthEntryPoint;
|
||||
private String jeeProviderId;
|
||||
|
||||
private BeanDefinition logoutFilter;
|
||||
private BeanDefinition loginPageGenerationFilter;
|
||||
private BeanDefinition etf;
|
||||
private BeanReference requestCache;
|
||||
private final BeanReference requestCache;
|
||||
|
||||
final SecureRandom random;
|
||||
|
||||
@@ -282,8 +279,7 @@ final class AuthenticationConfigBuilder {
|
||||
openIDProviderBuilder.addPropertyValue("authenticationUserDetailsService", uds);
|
||||
|
||||
BeanDefinition openIDProvider = openIDProviderBuilder.getBeanDefinition();
|
||||
openIDProviderId = pc.getReaderContext().registerWithGeneratedName(openIDProvider);
|
||||
openIDProviderRef = new RuntimeBeanReference(openIDProviderId);
|
||||
openIDProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(openIDProvider));
|
||||
}
|
||||
|
||||
private void injectRememberMeServicesRef(RootBeanDefinition bean, String rememberMeServicesId) {
|
||||
@@ -363,8 +359,7 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
provider.getPropertyValues().addPropertyValue("preAuthenticatedUserDetailsService", uds);
|
||||
|
||||
x509ProviderId = pc.getReaderContext().registerWithGeneratedName(provider);
|
||||
x509ProviderRef = new RuntimeBeanReference(x509ProviderId);
|
||||
x509ProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(provider));
|
||||
}
|
||||
|
||||
private void createPrauthEntryPoint(Element source) {
|
||||
@@ -424,8 +419,7 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
provider.getPropertyValues().addPropertyValue("preAuthenticatedUserDetailsService", uds);
|
||||
|
||||
jeeProviderId = pc.getReaderContext().registerWithGeneratedName(provider);
|
||||
jeeProviderRef = new RuntimeBeanReference(jeeProviderId);
|
||||
jeeProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(provider));
|
||||
}
|
||||
|
||||
void createLoginPageFilterIfNeeded() {
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ public class ChannelAttributeFactory {
|
||||
private static final String OPT_REQUIRES_HTTPS = "https";
|
||||
private static final String OPT_ANY_CHANNEL = "any";
|
||||
|
||||
public static final List<ConfigAttribute> createChannelAttributes(String requiredChannel) {
|
||||
String channelConfigAttribute = null;
|
||||
public static List<ConfigAttribute> createChannelAttributes(String requiredChannel) {
|
||||
String channelConfigAttribute;
|
||||
|
||||
if (requiredChannel.equals(OPT_REQUIRES_HTTPS)) {
|
||||
channelConfigAttribute = "REQUIRES_SECURE_CHANNEL";
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.springframework.security.web.servletapi.SecurityContextHolderAwareReq
|
||||
import org.springframework.security.web.session.SessionManagementFilter;
|
||||
|
||||
public class DefaultFilterChainValidator implements FilterChainProxy.FilterChainValidator {
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public void validate(FilterChainProxy fcp) {
|
||||
for(List<Filter> filters : fcp.getFilterChainMap().values()) {
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ public class FilterChainMapBeanDefinitionDecorator implements BeanDefinitionDeco
|
||||
String[] filterBeanNames = StringUtils.tokenizeToStringArray(filters, ",");
|
||||
ManagedList filterChain = new ManagedList(filterBeanNames.length);
|
||||
|
||||
for (int i=0; i < filterBeanNames.length; i++) {
|
||||
filterChain.add(new RuntimeBeanReference(filterBeanNames[i]));
|
||||
for (String name : filterBeanNames) {
|
||||
filterChain.add(new RuntimeBeanReference(name));
|
||||
}
|
||||
|
||||
filterChainMap.put(matcher, filterChain);
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ class HttpConfigurationBuilder {
|
||||
private BeanReference sessionStrategyRef;
|
||||
private RootBeanDefinition sfpf;
|
||||
private BeanDefinition servApiFilter;
|
||||
private String portMapperName;
|
||||
private final String portMapperName;
|
||||
private BeanReference fsi;
|
||||
private BeanReference requestCache;
|
||||
|
||||
|
||||
+5
-14
@@ -54,12 +54,6 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
|
||||
private static final String ATT_REF = "ref";
|
||||
private static final String ATT_SECURED = "security";
|
||||
private static final String OPT_SECURITY_NONE = "none";
|
||||
private static final String OPT_SECURITY_CONTEXT_ONLY = "contextOnly";
|
||||
|
||||
static final String EXPRESSION_FIMDS_CLASS = "org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource";
|
||||
static final String EXPRESSION_HANDLER_CLASS = "org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler";
|
||||
|
||||
static final List<BeanMetadataElement> NO_FILTERS = Collections.emptyList();
|
||||
|
||||
public HttpSecurityBeanDefinitionParser() {
|
||||
}
|
||||
@@ -118,13 +112,13 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
final String portMapperName = createPortMapper(element, pc);
|
||||
|
||||
ManagedList<BeanReference> authenticationProviders = new ManagedList<BeanReference>();
|
||||
BeanReference authenticationManager = createAuthenticationManager(element, pc, authenticationProviders, null);
|
||||
BeanReference authenticationManager = createAuthenticationManager(element, pc, authenticationProviders);
|
||||
|
||||
HttpConfigurationBuilder httpBldr = new HttpConfigurationBuilder(element, pc, matcherType,
|
||||
portMapperName, authenticationManager);
|
||||
@@ -172,7 +166,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
|
||||
* authentication manager.
|
||||
*/
|
||||
private BeanReference createAuthenticationManager(Element element, ParserContext pc,
|
||||
ManagedList<BeanReference> authenticationProviders, BeanReference concurrencyController) {
|
||||
ManagedList<BeanReference> authenticationProviders) {
|
||||
BeanDefinitionBuilder authManager = BeanDefinitionBuilder.rootBeanDefinition(ProviderManager.class);
|
||||
authManager.addPropertyValue("parent", new RootBeanDefinition(AuthenticationManagerFactoryBean.class));
|
||||
authManager.addPropertyValue("providers", authenticationProviders);
|
||||
@@ -181,9 +175,6 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
|
||||
clearCredentials.getPropertyValues().addPropertyValue("targetMethod", "isEraseCredentialsAfterAuthentication");
|
||||
authManager.addPropertyValue("eraseCredentialsAfterAuthentication", clearCredentials);
|
||||
|
||||
if (concurrencyController != null) {
|
||||
authManager.addPropertyValue("sessionController", concurrencyController);
|
||||
}
|
||||
authManager.getRawBeanDefinition().setSource(pc.extractSource(element));
|
||||
BeanDefinition authMgrBean = authManager.getBeanDefinition();
|
||||
String id = pc.getReaderContext().generateBeanName(authMgrBean);
|
||||
@@ -291,8 +282,8 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
class OrderDecorator implements Ordered {
|
||||
BeanMetadataElement bean;
|
||||
int order;
|
||||
final BeanMetadataElement bean;
|
||||
final int order;
|
||||
|
||||
public OrderDecorator(BeanMetadataElement bean, SecurityFilters filterOrder) {
|
||||
this.bean = bean;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ class LogoutBeanDefinitionParser implements BeanDefinitionParser {
|
||||
static final String DEF_LOGOUT_URL = "/j_spring_security_logout";
|
||||
static final String ATT_LOGOUT_HANDLER = "success-handler-ref";
|
||||
|
||||
String rememberMeServices;
|
||||
final String rememberMeServices;
|
||||
|
||||
public LogoutBeanDefinitionParser(String rememberMeServices) {
|
||||
this.rememberMeServices = rememberMeServices;
|
||||
|
||||
@@ -15,8 +15,8 @@ abstract class WebConfigUtils {
|
||||
public static int countNonEmpty(String[] objects) {
|
||||
int nonNulls = 0;
|
||||
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
if (StringUtils.hasText(objects[i])) {
|
||||
for (String object : objects) {
|
||||
if (StringUtils.hasText(object)) {
|
||||
nonNulls++;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.w3c.dom.Element;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class LdapProviderBeanDefinitionParser implements BeanDefinitionParser {
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private static final String ATT_USER_DN_PATTERN = "user-dn-pattern";
|
||||
private static final String ATT_USER_PASSWORD = "password-attribute";
|
||||
@@ -81,7 +81,7 @@ public class LdapProviderBeanDefinitionParser implements BeanDefinitionParser {
|
||||
parserContext.getReaderContext().warning("Salt source information isn't valid when used with LDAP",
|
||||
passwordEncoderElement);
|
||||
}
|
||||
} else if (StringUtils.hasText(hash)) {;
|
||||
} else if (StringUtils.hasText(hash)) {
|
||||
authenticatorBuilder.addPropertyValue("passwordEncoder",
|
||||
PasswordEncoderParser.createPasswordEncoderBeanDefinition(hash, false));
|
||||
}
|
||||
|
||||
+1
-1
@@ -315,7 +315,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
}
|
||||
|
||||
if (!afterInvocationProviders.isEmpty()) {
|
||||
BeanDefinition afterInvocationManager = null;
|
||||
BeanDefinition afterInvocationManager;
|
||||
afterInvocationManager = new RootBeanDefinition(AfterInvocationProviderManager.class);
|
||||
afterInvocationManager.getPropertyValues().addPropertyValue("providers", afterInvocationProviders);
|
||||
bldr.addPropertyValue("afterInvocationManager", afterInvocationManager);
|
||||
|
||||
+1
-2
@@ -29,7 +29,7 @@ import org.w3c.dom.Node;
|
||||
*
|
||||
*/
|
||||
public class InterceptMethodsBeanDefinitionDecorator implements BeanDefinitionDecorator {
|
||||
private BeanDefinitionDecorator delegate = new InternalInterceptMethodsBeanDefinitionDecorator();
|
||||
private final BeanDefinitionDecorator delegate = new InternalInterceptMethodsBeanDefinitionDecorator();
|
||||
|
||||
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
||||
MethodConfigUtils.registerDefaultMethodAccessManagerIfNecessary(parserContext);
|
||||
@@ -66,7 +66,6 @@ class InternalInterceptMethodsBeanDefinitionDecorator extends AbstractIntercepto
|
||||
// Lookup parent bean information
|
||||
Element parent = (Element) node.getParentNode();
|
||||
String parentBeanClass = parent.getAttribute("class");
|
||||
parent = null;
|
||||
|
||||
// Parse the included methods
|
||||
List<Element> methods = DomUtils.getChildElementsByTagName(interceptMethodsElt, Elements.PROTECT);
|
||||
|
||||
+6
-6
@@ -50,10 +50,10 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ProtectPointcutPostProcessor.class);
|
||||
|
||||
private Map<String,List<ConfigAttribute>> pointcutMap = new LinkedHashMap<String,List<ConfigAttribute>>();
|
||||
private MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource;
|
||||
private Set<PointcutExpression> pointCutExpressions = new LinkedHashSet<PointcutExpression>();
|
||||
private PointcutParser parser;
|
||||
private final Map<String,List<ConfigAttribute>> pointcutMap = new LinkedHashMap<String,List<ConfigAttribute>>();
|
||||
private final MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource;
|
||||
private final Set<PointcutExpression> pointCutExpressions = new LinkedHashSet<PointcutExpression>();
|
||||
private final PointcutParser parser;
|
||||
|
||||
public ProtectPointcutPostProcessor(MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource) {
|
||||
Assert.notNull(mapBasedMethodSecurityMetadataSource, "MapBasedMethodSecurityMetadataSource to populate is required");
|
||||
@@ -88,10 +88,10 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
}
|
||||
|
||||
// Check to see if any of those methods are compatible with our pointcut expressions
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
for (Method method : methods) {
|
||||
for (PointcutExpression expression : pointCutExpressions) {
|
||||
// Try for the bean class directly
|
||||
if (attemptMatch(bean.getClass(), methods[i], expression, beanName)) {
|
||||
if (attemptMatch(bean.getClass(), method, expression, beanName)) {
|
||||
// We've found the first expression that matches this method, so move onto the next method now
|
||||
break; // the "while" loop, not the "for" loop
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user