SEC-1465: Change DelegatingMethodSecurityMetadataSource to use constructor injection to get round the problem of it being invoked before it has been initialized properly. Also changed the contacts tests to use the same app context and loading order as the actual webapp, to give better reassurance that the app will run successfully.
This commit is contained in:
+8
-11
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.security.access.ConfigAttribute;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -21,19 +20,22 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Ben Alex
|
||||
* @author Luke Taylor
|
||||
*/
|
||||
public final class DelegatingMethodSecurityMetadataSource extends AbstractMethodSecurityMetadataSource implements InitializingBean {
|
||||
public final class DelegatingMethodSecurityMetadataSource extends AbstractMethodSecurityMetadataSource {
|
||||
private final static List<ConfigAttribute> NULL_CONFIG_ATTRIBUTE = Collections.emptyList();
|
||||
|
||||
private List<MethodSecurityMetadataSource> methodSecurityMetadataSources;
|
||||
private final List<MethodSecurityMetadataSource> methodSecurityMetadataSources;
|
||||
private final Map<DefaultCacheKey, Collection<ConfigAttribute>> attributeCache =
|
||||
new HashMap<DefaultCacheKey, Collection<ConfigAttribute>>();
|
||||
|
||||
//~ Methods ========================================================================================================
|
||||
//~ Constructor ====================================================================================================
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(methodSecurityMetadataSources, "A list of MethodSecurityMetadataSources is required");
|
||||
public DelegatingMethodSecurityMetadataSource(List<MethodSecurityMetadataSource> methodSecurityMetadataSources) {
|
||||
Assert.notEmpty(methodSecurityMetadataSources, "MethodSecurityMetadataSources cannot be null or empty");
|
||||
this.methodSecurityMetadataSources = methodSecurityMetadataSources;
|
||||
}
|
||||
|
||||
//~ Methods ========================================================================================================
|
||||
|
||||
public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass) {
|
||||
DefaultCacheKey cacheKey = new DefaultCacheKey(method, targetClass);
|
||||
synchronized (attributeCache) {
|
||||
@@ -83,11 +85,6 @@ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethod
|
||||
return set;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setMethodSecurityMetadataSources(List methodSecurityMetadataSources) {
|
||||
this.methodSecurityMetadataSources = methodSecurityMetadataSources;
|
||||
}
|
||||
|
||||
//~ Inner Classes ==================================================================================================
|
||||
|
||||
private static class DefaultCacheKey {
|
||||
|
||||
Reference in New Issue
Block a user