2
0
Эх сурвалжийг харах

Refactored to use Spring Assert class (thanks IntelliJ :).

Luke Taylor 20 жил өмнө
parent
commit
1a78f9e15f
53 өөрчлөгдсөн 268 нэмэгдсэн , 539 устгасан
  1. 10 22
      core/src/main/java/org/acegisecurity/acl/AclProviderManager.java
  2. 6 10
      core/src/main/java/org/acegisecurity/acl/basic/AbstractBasicAclEntry.java
  3. 17 31
      core/src/main/java/org/acegisecurity/acl/basic/BasicAclProvider.java
  4. 4 4
      core/src/main/java/org/acegisecurity/acl/basic/NamedEntityObjectIdentity.java
  5. 4 6
      core/src/main/java/org/acegisecurity/acl/basic/cache/BasicAclEntryHolder.java
  6. 2 3
      core/src/main/java/org/acegisecurity/acl/basic/cache/EhCacheBasedAclEntryCache.java
  7. 2 4
      core/src/main/java/org/acegisecurity/adapters/AuthByAdapterProvider.java
  8. 4 10
      core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProvider.java
  9. 4 10
      core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationProvider.java
  10. 40 67
      core/src/main/java/org/acegisecurity/intercept/AbstractSecurityInterceptor.java
  11. 7 11
      core/src/main/java/org/acegisecurity/intercept/method/AbstractMethodDefinitionSource.java
  12. 3 3
      core/src/main/java/org/acegisecurity/providers/anonymous/AnonymousAuthenticationToken.java
  13. 6 22
      core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationProvider.java
  14. 3 3
      core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationToken.java
  15. 2 3
      core/src/main/java/org/acegisecurity/providers/cas/cache/EhCacheBasedTicketCache.java
  16. 2 4
      core/src/main/java/org/acegisecurity/providers/cas/populator/DaoCasAuthoritiesPopulator.java
  17. 2 3
      core/src/main/java/org/acegisecurity/providers/cas/proxy/AcceptAnyCasProxy.java
  18. 4 8
      core/src/main/java/org/acegisecurity/providers/cas/proxy/NamedCasProxyDecider.java
  19. 3 4
      core/src/main/java/org/acegisecurity/providers/cas/proxy/RejectProxyTickets.java
  20. 3 8
      core/src/main/java/org/acegisecurity/providers/cas/ticketvalidator/AbstractTicketValidator.java
  21. 3 8
      core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationProvider.java
  22. 3 8
      core/src/main/java/org/acegisecurity/providers/dao/PasswordDaoAuthenticationProvider.java
  23. 2 3
      core/src/main/java/org/acegisecurity/providers/dao/cache/EhCacheBasedUserCache.java
  24. 2 3
      core/src/main/java/org/acegisecurity/providers/dao/event/AuthenticationEvent.java
  25. 3 8
      core/src/main/java/org/acegisecurity/providers/jaas/JaasAuthenticationProvider.java
  26. 2 4
      core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationManagerImpl.java
  27. 2 4
      core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationProvider.java
  28. 3 3
      core/src/main/java/org/acegisecurity/providers/rememberme/RememberMeAuthenticationToken.java
  29. 2 4
      core/src/main/java/org/acegisecurity/runas/RunAsImplAuthenticationProvider.java
  30. 2 4
      core/src/main/java/org/acegisecurity/runas/RunAsManagerImpl.java
  31. 7 15
      core/src/main/java/org/acegisecurity/securechannel/ChannelProcessingFilter.java
  32. 3 7
      core/src/main/java/org/acegisecurity/securechannel/InsecureChannelProcessor.java
  33. 3 7
      core/src/main/java/org/acegisecurity/securechannel/RetryWithHttpEntryPoint.java
  34. 3 7
      core/src/main/java/org/acegisecurity/securechannel/RetryWithHttpsEntryPoint.java
  35. 4 10
      core/src/main/java/org/acegisecurity/securechannel/SecureChannelProcessor.java
  36. 3 9
      core/src/main/java/org/acegisecurity/ui/basicauth/BasicProcessingFilter.java
  37. 3 8
      core/src/main/java/org/acegisecurity/ui/cas/CasProcessingFilterEntryPoint.java
  38. 4 11
      core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterEntryPoint.java
  39. 2 3
      core/src/main/java/org/acegisecurity/userdetails/User.java
  40. 2 4
      core/src/main/java/org/acegisecurity/userdetails/memory/InMemoryDaoImpl.java
  41. 2 3
      core/src/main/java/org/acegisecurity/userdetails/memory/UserMap.java
  42. 4 12
      core/src/main/java/org/acegisecurity/util/FilterChainProxy.java
  43. 6 8
      core/src/main/java/org/acegisecurity/util/PortMapperImpl.java
  44. 2 3
      core/src/main/java/org/acegisecurity/util/PortResolverImpl.java
  45. 5 15
      core/src/main/java/org/acegisecurity/vote/BasicAclEntryVoter.java
  46. 2 4
      samples/contacts/src/main/java/sample/contact/AddPermissionController.java
  47. 3 9
      samples/contacts/src/main/java/sample/contact/AdminPermissionController.java
  48. 3 7
      samples/contacts/src/main/java/sample/contact/ContactManagerBackend.java
  49. 46 91
      samples/contacts/src/main/java/sample/contact/DataSourcePopulator.java
  50. 2 4
      samples/contacts/src/main/java/sample/contact/DeleteController.java
  51. 3 9
      samples/contacts/src/main/java/sample/contact/DeletePermissionController.java
  52. 2 4
      samples/contacts/src/main/java/sample/contact/PublicIndexController.java
  53. 2 4
      samples/contacts/src/main/java/sample/contact/SecureIndexController.java

+ 10 - 22
core/src/main/java/org/acegisecurity/acl/AclProviderManager.java

@@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.util.Iterator;
 import java.util.List;
@@ -50,10 +51,7 @@ public class AclProviderManager implements AclManager, InitializingBean {
     //~ Methods ================================================================
 
     public AclEntry[] getAcls(Object domainInstance) {
-        if (domainInstance == null) {
-            throw new IllegalArgumentException(
-                "domainInstance is null - violating interface contract");
-        }
+        Assert.notNull(domainInstance, "domainInstance is null - violating interface contract");
 
         Iterator iter = providers.iterator();
 
@@ -63,7 +61,7 @@ public class AclProviderManager implements AclManager, InitializingBean {
             if (provider.supports(domainInstance)) {
                 if (logger.isDebugEnabled()) {
                     logger.debug("ACL lookup using "
-                        + provider.getClass().getName());
+                            + provider.getClass().getName());
                 }
 
                 return provider.getAcls(domainInstance);
@@ -72,7 +70,7 @@ public class AclProviderManager implements AclManager, InitializingBean {
 
         if (logger.isDebugEnabled()) {
             logger.debug("No AclProvider found for "
-                + domainInstance.toString());
+                    + domainInstance.toString());
         }
 
         return null;
@@ -80,15 +78,8 @@ public class AclProviderManager implements AclManager, InitializingBean {
 
     public AclEntry[] getAcls(Object domainInstance,
         Authentication authentication) {
-        if (domainInstance == null) {
-            throw new IllegalArgumentException(
-                "domainInstance is null - violating interface contract");
-        }
-
-        if (authentication == null) {
-            throw new IllegalArgumentException(
-                "authentication is null - violating interface contract");
-        }
+        Assert.notNull(domainInstance, "domainInstance is null - violating interface contract");
+        Assert.notNull(authentication, "authentication is null - violating interface contract");
 
         Iterator iter = providers.iterator();
 
@@ -98,21 +89,21 @@ public class AclProviderManager implements AclManager, InitializingBean {
             if (provider.supports(domainInstance)) {
                 if (logger.isDebugEnabled()) {
                     logger.debug("ACL lookup using "
-                        + provider.getClass().getName());
+                            + provider.getClass().getName());
                 }
 
                 return provider.getAcls(domainInstance, authentication);
             } else {
                 if (logger.isDebugEnabled()) {
                     logger.debug("Provider " + provider.toString()
-                        + " does not support " + domainInstance);
+                            + " does not support " + domainInstance);
                 }
             }
         }
 
         if (logger.isDebugEnabled()) {
             logger.debug("No AclProvider found for "
-                + domainInstance.toString());
+                    + domainInstance.toString());
         }
 
         return null;
@@ -157,9 +148,6 @@ public class AclProviderManager implements AclManager, InitializingBean {
     }
 
     private void checkIfValidList(List listToCheck) {
-        if ((listToCheck == null) || (listToCheck.size() == 0)) {
-            throw new IllegalArgumentException(
-                "A list of AclManagers is required");
-        }
+        Assert.notEmpty(listToCheck, "A list of AclManagers is required");
     }
 }

+ 6 - 10
core/src/main/java/org/acegisecurity/acl/basic/AbstractBasicAclEntry.java

@@ -17,6 +17,7 @@ package net.sf.acegisecurity.acl.basic;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.springframework.util.Assert;
 
 import java.util.Arrays;
 
@@ -49,14 +50,9 @@ public abstract class AbstractBasicAclEntry implements BasicAclEntry {
     public AbstractBasicAclEntry(Object recipient,
         AclObjectIdentity aclObjectIdentity,
         AclObjectIdentity aclObjectParentIdentity, int mask) {
-        if (recipient == null) {
-            throw new IllegalArgumentException("recipient cannot be null");
-        }
+        Assert.notNull(recipient, "recipient cannot be null");
 
-        if (aclObjectIdentity == null) {
-            throw new IllegalArgumentException(
-                "aclObjectIdentity cannot be null");
-        }
+        Assert.notNull(aclObjectIdentity, "aclObjectIdentity cannot be null");
 
         validPermissions = getValidPermissions();
         Arrays.sort(validPermissions);
@@ -64,9 +60,9 @@ public abstract class AbstractBasicAclEntry implements BasicAclEntry {
         for (int i = 0; i < validPermissions.length; i++) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Valid permission:   "
-                    + printPermissionsBlock(validPermissions[i]) + " "
-                    + printBinary(validPermissions[i]) + " ("
-                    + validPermissions[i] + ")");
+                        + printPermissionsBlock(validPermissions[i]) + " "
+                        + printBinary(validPermissions[i]) + " ("
+                        + validPermissions[i] + ")");
             }
         }
 

+ 17 - 31
core/src/main/java/org/acegisecurity/acl/basic/BasicAclProvider.java

@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.lang.reflect.Constructor;
 
@@ -103,10 +104,7 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
 
         AclObjectIdentity aclIdentity = obtainIdentity(domainInstance);
 
-        if (aclIdentity == null) {
-            throw new IllegalArgumentException(
-                "domainInstance is not supported by this provider");
-        }
+        Assert.notNull(aclIdentity, "domainInstance is not supported by this provider");
 
         if (logger.isDebugEnabled()) {
             logger.debug("Looking up: " + aclIdentity.toString());
@@ -123,14 +121,14 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
         for (int i = 0; i < instanceAclEntries.length; i++) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Explicit add: "
-                    + instanceAclEntries[i].toString());
+                        + instanceAclEntries[i].toString());
             }
 
             map.put(instanceAclEntries[i].getRecipient(), instanceAclEntries[i]);
         }
 
         AclObjectIdentity parent = instanceAclEntries[0]
-            .getAclObjectParentIdentity();
+                .getAclObjectParentIdentity();
 
         while (parent != null) {
             BasicAclEntry[] parentAclEntries = lookup(parent);
@@ -153,15 +151,15 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
                 if (!map.containsKey(parentAclEntries[i].getRecipient())) {
                     if (logger.isDebugEnabled()) {
                         logger.debug("Added parent to map: "
-                            + parentAclEntries[i].toString());
+                                + parentAclEntries[i].toString());
                     }
 
                     map.put(parentAclEntries[i].getRecipient(),
-                        parentAclEntries[i]);
+                            parentAclEntries[i]);
                 } else {
                     if (logger.isDebugEnabled()) {
                         logger.debug("Did NOT add parent to map: "
-                            + parentAclEntries[i].toString());
+                                + parentAclEntries[i].toString());
                     }
                 }
             }
@@ -172,7 +170,7 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
 
         Collection collection = map.values();
 
-        return (AclEntry[]) collection.toArray(new AclEntry[] {});
+        return (AclEntry[]) collection.toArray(new AclEntry[]{});
     }
 
     public AclEntry[] getAcls(Object domainInstance,
@@ -254,31 +252,19 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
     }
 
     public void afterPropertiesSet() {
-        if (basicAclDao == null) {
-            throw new IllegalArgumentException("basicAclDao required");
-        }
-
-        if (basicAclEntryCache == null) {
-            throw new IllegalArgumentException("basicAclEntryCache required");
-        }
-
-        if (effectiveAclsResolver == null) {
-            throw new IllegalArgumentException("effectiveAclsResolver required");
-        }
-
-        if ((defaultAclObjectIdentityClass == null)
-            || (!AclObjectIdentity.class.isAssignableFrom(
-                this.defaultAclObjectIdentityClass))) {
-            throw new IllegalArgumentException(
-                "defaultAclObjectIdentityClass that implements AclObjectIdentity is required");
-        }
+        Assert.notNull(basicAclDao, "basicAclDao required");
+        Assert.notNull(basicAclEntryCache, "basicAclEntryCache required");
+        Assert.notNull(basicAclEntryCache, "basicAclEntryCache required");
+        Assert.notNull(effectiveAclsResolver, "effectiveAclsResolver required");
+        Assert.notNull(defaultAclObjectIdentityClass, "defaultAclObjectIdentityClass required");
+        Assert.isTrue(AclObjectIdentity.class.isAssignableFrom(this.defaultAclObjectIdentityClass),
+                "defaultAclObjectIdentityClass must implement AclObjectIdentity");
 
         try {
             Constructor constructor = defaultAclObjectIdentityClass
-                .getConstructor(new Class[] {Object.class});
+                    .getConstructor(new Class[]{Object.class});
         } catch (NoSuchMethodException nsme) {
-            throw new IllegalArgumentException(
-                "defaultAclObjectIdentityClass must provide a constructor that accepts the domain object instance!");
+            throw new IllegalArgumentException("defaultAclObjectIdentityClass must provide a constructor that accepts the domain object instance!");
         }
     }
 

+ 4 - 4
core/src/main/java/org/acegisecurity/acl/basic/NamedEntityObjectIdentity.java

@@ -15,6 +15,8 @@
 
 package net.sf.acegisecurity.acl.basic;
 
+import org.springframework.util.Assert;
+
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -65,9 +67,7 @@ public class NamedEntityObjectIdentity implements AclObjectIdentity {
      */
     public NamedEntityObjectIdentity(Object object)
         throws IllegalAccessException, InvocationTargetException {
-        if (object == null) {
-            throw new IllegalArgumentException("object cannot be null");
-        }
+        Assert.notNull(object, "object cannot be null");
 
         this.classname = object.getClass().getName();
 
@@ -79,7 +79,7 @@ public class NamedEntityObjectIdentity implements AclObjectIdentity {
             this.id = result.toString();
         } catch (NoSuchMethodException nsme) {
             throw new IllegalArgumentException("Object of class '" + clazz
-                + "' does not provide the required getId() method: " + object);
+                    + "' does not provide the required getId() method: " + object);
         }
     }
 

+ 4 - 6
core/src/main/java/org/acegisecurity/acl/basic/cache/BasicAclEntryHolder.java

@@ -19,6 +19,8 @@ import net.sf.acegisecurity.acl.basic.BasicAclEntry;
 
 import java.io.Serializable;
 
+import org.springframework.util.Assert;
+
 
 /**
  * Used by {@link EhCacheBasedAclEntryCache} to store the array of
@@ -57,14 +59,10 @@ public class BasicAclEntryHolder implements Serializable {
      *         passed to the constructor
      */
     public BasicAclEntryHolder(BasicAclEntry[] aclEntries) {
-        if (aclEntries == null) {
-            throw new IllegalArgumentException("aclEntries cannot be null");
-        }
+        Assert.notNull(aclEntries, "aclEntries cannot be null");
 
         for (int i = 0; i < aclEntries.length; i++) {
-            if (aclEntries[i] == null) {
-                throw new IllegalArgumentException("aclEntries cannot be null");
-            }
+            Assert.notNull(aclEntries[i], "aclEntries cannot be null");
         }
 
         this.basicAclEntries = aclEntries;

+ 2 - 3
core/src/main/java/org/acegisecurity/acl/basic/cache/EhCacheBasedAclEntryCache.java

@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.util.Assert;
 
 
 /**
@@ -89,9 +90,7 @@ public class EhCacheBasedAclEntryCache implements BasicAclEntryCache,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (cache == null) {
-            throw new IllegalArgumentException("cache mandatory");
-        }
+        Assert.notNull(cache, "cache mandatory");
     }
 
     public void putEntriesInCache(BasicAclEntry[] basicAclEntry) {

+ 2 - 4
core/src/main/java/org/acegisecurity/adapters/AuthByAdapterProvider.java

@@ -21,6 +21,7 @@ import net.sf.acegisecurity.BadCredentialsException;
 import net.sf.acegisecurity.providers.AuthenticationProvider;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -58,10 +59,7 @@ public class AuthByAdapterProvider implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (key == null) {
-            throw new IllegalArgumentException(
-                "A Key is required and should match that configured for the adapters");
-        }
+        Assert.notNull(key, "A Key is required and should match that configured for the adapters");
     }
 
     public Authentication authenticate(Authentication authentication)

+ 4 - 10
core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProvider.java

@@ -30,6 +30,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.lang.reflect.Array;
 
@@ -138,18 +139,11 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProvider
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (processConfigAttribute == null) {
-            throw new IllegalArgumentException(
-                "A processConfigAttribute is mandatory");
-        }
+        Assert.notNull(processConfigAttribute, "A processConfigAttribute is mandatory");
+        Assert.notNull(aclManager, "An aclManager is mandatory");
 
         if ((requirePermission == null) || (requirePermission.length == 0)) {
-            throw new IllegalArgumentException(
-                "One or more requirePermission entries is mandatory");
-        }
-
-        if (aclManager == null) {
-            throw new IllegalArgumentException("An aclManager is mandatory");
+            throw new IllegalArgumentException("One or more requirePermission entries is mandatory");
         }
     }
 

+ 4 - 10
core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationProvider.java

@@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.util.Iterator;
 
@@ -129,18 +130,11 @@ public class BasicAclEntryAfterInvocationProvider
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (processConfigAttribute == null) {
-            throw new IllegalArgumentException(
-                "A processConfigAttribute is mandatory");
-        }
+        Assert.notNull(processConfigAttribute, "A processConfigAttribute is mandatory");
+        Assert.notNull(aclManager, "An aclManager is mandatory");
 
         if ((requirePermission == null) || (requirePermission.length == 0)) {
-            throw new IllegalArgumentException(
-                "One or more requirePermission entries is mandatory");
-        }
-
-        if (aclManager == null) {
-            throw new IllegalArgumentException("An aclManager is mandatory");
+            throw new IllegalArgumentException("One or more requirePermission entries is mandatory");
         }
     }
 

+ 40 - 67
core/src/main/java/org/acegisecurity/intercept/AbstractSecurityInterceptor.java

@@ -43,6 +43,7 @@ import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.util.Assert;
 
 import java.util.HashSet;
 import java.util.Iterator;
@@ -221,80 +222,61 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (getSecureObjectClass() == null) {
-            throw new IllegalArgumentException(
-                "Subclass must provide a non-null response to getSecureObjectClass()");
-        }
+        Assert.notNull(getSecureObjectClass(), "Subclass must provide a non-null response to getSecureObjectClass()");
 
-        if (this.authenticationManager == null) {
-            throw new IllegalArgumentException(
-                "An AuthenticationManager is required");
-        }
+        Assert.notNull(this.authenticationManager, "An AuthenticationManager is required");
 
-        if (this.accessDecisionManager == null) {
-            throw new IllegalArgumentException(
-                "An AccessDecisionManager is required");
-        }
+        Assert.notNull(this.accessDecisionManager, "An AccessDecisionManager is required");
 
-        if (this.runAsManager == null) {
-            throw new IllegalArgumentException("A RunAsManager is required");
-        }
+        Assert.notNull(this.runAsManager, "A RunAsManager is required");
 
-        if (this.obtainObjectDefinitionSource() == null) {
-            throw new IllegalArgumentException(
-                "An ObjectDefinitionSource is required");
-        }
+        Assert.notNull(this.obtainObjectDefinitionSource(), "An ObjectDefinitionSource is required");
 
         if (!this.obtainObjectDefinitionSource().supports(getSecureObjectClass())) {
-            throw new IllegalArgumentException(
-                "ObjectDefinitionSource does not support secure object class: "
-                + getSecureObjectClass());
+            throw new IllegalArgumentException("ObjectDefinitionSource does not support secure object class: "
+                    + getSecureObjectClass());
         }
 
         if (!this.runAsManager.supports(getSecureObjectClass())) {
-            throw new IllegalArgumentException(
-                "RunAsManager does not support secure object class: "
-                + getSecureObjectClass());
+            throw new IllegalArgumentException("RunAsManager does not support secure object class: "
+                    + getSecureObjectClass());
         }
 
         if (!this.accessDecisionManager.supports(getSecureObjectClass())) {
-            throw new IllegalArgumentException(
-                "AccessDecisionManager does not support secure object class: "
-                + getSecureObjectClass());
+            throw new IllegalArgumentException("AccessDecisionManager does not support secure object class: "
+                    + getSecureObjectClass());
         }
 
         if ((this.afterInvocationManager != null)
-            && !this.afterInvocationManager.supports(getSecureObjectClass())) {
-            throw new IllegalArgumentException(
-                "AfterInvocationManager does not support secure object class: "
-                + getSecureObjectClass());
+                && !this.afterInvocationManager.supports(getSecureObjectClass())) {
+            throw new IllegalArgumentException("AfterInvocationManager does not support secure object class: "
+                    + getSecureObjectClass());
         }
 
         if (this.validateConfigAttributes) {
             Iterator iter = this.obtainObjectDefinitionSource()
-                                .getConfigAttributeDefinitions();
+                    .getConfigAttributeDefinitions();
 
             if (iter == null) {
                 if (logger.isWarnEnabled()) {
-                    logger.warn(
-                        "Could not validate configuration attributes as the MethodDefinitionSource did not return a ConfigAttributeDefinition Iterator");
+                    logger.warn("Could not validate configuration attributes as the MethodDefinitionSource did not return a ConfigAttributeDefinition Iterator");
                 }
             } else {
                 Set set = new HashSet();
 
                 while (iter.hasNext()) {
                     ConfigAttributeDefinition def = (ConfigAttributeDefinition) iter
-                        .next();
+                            .next();
                     Iterator attributes = def.getConfigAttributes();
 
                     while (attributes.hasNext()) {
                         ConfigAttribute attr = (ConfigAttribute) attributes
-                            .next();
+                                .next();
 
                         if (!this.runAsManager.supports(attr)
-                            && !this.accessDecisionManager.supports(attr)
-                            && ((this.afterInvocationManager == null)
-                            || !this.afterInvocationManager.supports(attr))) {
+                                && !this.accessDecisionManager.supports(attr)
+                                && ((this.afterInvocationManager == null)
+                                || !this.afterInvocationManager.supports(attr))) {
                             set.add(attr);
                         }
                     }
@@ -305,9 +287,8 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
                         logger.info("Validated configuration attributes");
                     }
                 } else {
-                    throw new IllegalArgumentException(
-                        "Unsupported configuration attributes: "
-                        + set.toString());
+                    throw new IllegalArgumentException("Unsupported configuration attributes: "
+                            + set.toString());
                 }
             }
         }
@@ -354,31 +335,25 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
     }
 
     protected InterceptorStatusToken beforeInvocation(Object object) {
-        if (object == null) {
-            throw new IllegalArgumentException("Object was null");
-        }
-
-        if (!getSecureObjectClass().isAssignableFrom(object.getClass())) {
-            throw new IllegalArgumentException(
-                "Security invocation attempted for object " + object
-                + " but AbstractSecurityInterceptor only configured to support secure objects of type: "
-                + getSecureObjectClass());
-        }
+        Assert.notNull(object, "Object was null");
+        Assert.isTrue(getSecureObjectClass().isAssignableFrom(object.getClass()), "Security invocation attempted for object " + object
+                    + " but AbstractSecurityInterceptor only configured to support secure objects of type: "
+                    + getSecureObjectClass());
 
         ConfigAttributeDefinition attr = this.obtainObjectDefinitionSource()
-                                             .getAttributes(object);
+                .getAttributes(object);
 
         if (attr != null) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Secure object: " + object.toString()
-                    + "; ConfigAttributes: " + attr.toString());
+                        + "; ConfigAttributes: " + attr.toString());
             }
 
             // Ensure ContextHolder presents a populated SecureContext
             if ((ContextHolder.getContext() == null)
-                || !(ContextHolder.getContext() instanceof SecureContext)) {
+                    || !(ContextHolder.getContext() instanceof SecureContext)) {
                 credentialsNotFound("A valid SecureContext was not provided in the RequestContext",
-                    object, attr);
+                        object, attr);
             }
 
             SecureContext context = (SecureContext) ContextHolder.getContext();
@@ -387,7 +362,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
             // not call Context.validate() like the ContextInterceptor)
             if (context.getAuthentication() == null) {
                 credentialsNotFound("Authentication credentials were not found in the SecureContext",
-                    object, attr);
+                        object, attr);
             }
 
             // Attempt authentication
@@ -439,23 +414,22 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
 
             if (runAs == null) {
                 if (logger.isDebugEnabled()) {
-                    logger.debug(
-                        "RunAsManager did not change Authentication object");
+                    logger.debug("RunAsManager did not change Authentication object");
                 }
 
                 return new InterceptorStatusToken(authenticated, false, attr,
-                    object); // no further work post-invocation
+                        object); // no further work post-invocation
             } else {
                 if (logger.isDebugEnabled()) {
                     logger.debug("Switching to RunAs Authentication: "
-                        + runAs.toString());
+                            + runAs.toString());
                 }
 
                 context.setAuthentication(runAs);
                 ContextHolder.setContext((Context) context);
 
                 return new InterceptorStatusToken(authenticated, true, attr,
-                    object); // revert to token.Authenticated post-invocation
+                        object); // revert to token.Authenticated post-invocation
             }
         } else {
             if (logger.isDebugEnabled()) {
@@ -466,14 +440,13 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
 
             // Set Authentication object (if it exists) to be unauthenticated
             if ((ContextHolder.getContext() != null)
-                && ContextHolder.getContext() instanceof SecureContext) {
+                    && ContextHolder.getContext() instanceof SecureContext) {
                 SecureContext context = (SecureContext) ContextHolder
-                    .getContext();
+                        .getContext();
 
                 if (context.getAuthentication() != null) {
                     if (logger.isDebugEnabled()) {
-                        logger.debug(
-                            "Authentication object detected and tagged as unauthenticated");
+                        logger.debug("Authentication object detected and tagged as unauthenticated");
                     }
 
                     Authentication authenticated = context.getAuthentication();

+ 7 - 11
core/src/main/java/org/acegisecurity/intercept/method/AbstractMethodDefinitionSource.java

@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
 
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.reflect.CodeSignature;
+import org.springframework.util.Assert;
 
 import java.lang.reflect.Method;
 
@@ -44,9 +45,7 @@ public abstract class AbstractMethodDefinitionSource
 
     public ConfigAttributeDefinition getAttributes(Object object)
         throws IllegalArgumentException {
-        if (object == null) {
-            throw new IllegalArgumentException("Object cannot be null");
-        }
+        Assert.notNull(object, "Object cannot be null");
 
         if (object instanceof MethodInvocation) {
             return this.lookupAttributes(((MethodInvocation) object).getMethod());
@@ -57,7 +56,7 @@ public abstract class AbstractMethodDefinitionSource
             Class targetClazz = jp.getTarget().getClass();
             String targetMethodName = jp.getStaticPart().getSignature().getName();
             Class[] types = ((CodeSignature) jp.getStaticPart().getSignature())
-                .getParameterTypes();
+                    .getParameterTypes();
 
             if (logger.isDebugEnabled()) {
                 logger.debug("Target Class: " + targetClazz);
@@ -66,22 +65,19 @@ public abstract class AbstractMethodDefinitionSource
                 for (int i = 0; i < types.length; i++) {
                     if (logger.isDebugEnabled()) {
                         logger.debug("Target Method Arg #" + i + ": "
-                            + types[i]);
+                                + types[i]);
                     }
                 }
             }
 
             try {
-                return this.lookupAttributes(targetClazz.getMethod(
-                        targetMethodName, types));
+                return this.lookupAttributes(targetClazz.getMethod(targetMethodName, types));
             } catch (NoSuchMethodException nsme) {
-                throw new IllegalArgumentException(
-                    "Could not obtain target method from JoinPoint: " + jp);
+                throw new IllegalArgumentException("Could not obtain target method from JoinPoint: " + jp);
             }
         }
 
-        throw new IllegalArgumentException(
-            "Object must be a MethodInvocation or JoinPoint");
+        throw new IllegalArgumentException("Object must be a MethodInvocation or JoinPoint");
     }
 
     public boolean supports(Class clazz) {

+ 3 - 3
core/src/main/java/org/acegisecurity/providers/anonymous/AnonymousAuthenticationToken.java

@@ -20,6 +20,8 @@ import net.sf.acegisecurity.providers.AbstractAuthenticationToken;
 
 import java.io.Serializable;
 
+import org.springframework.util.Assert;
+
 
 /**
  * Represents an anonymous <code>Authentication</code>.
@@ -56,11 +58,9 @@ public class AnonymousAuthenticationToken extends AbstractAuthenticationToken
         }
 
         for (int i = 0; i < authorities.length; i++) {
-            if (authorities[i] == null) {
-                throw new IllegalArgumentException("Granted authority element "
+            Assert.notNull(authorities[i], "Granted authority element "
                     + i
                     + " is null - GrantedAuthority[] cannot contain any null elements");
-            }
         }
 
         this.keyHash = key.hashCode();

+ 6 - 22
core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationProvider.java

@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -104,28 +105,11 @@ public class CasAuthenticationProvider implements AuthenticationProvider,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.casAuthoritiesPopulator == null) {
-            throw new IllegalArgumentException(
-                "A casAuthoritiesPopulator must be set");
-        }
-
-        if (this.ticketValidator == null) {
-            throw new IllegalArgumentException("A ticketValidator must be set");
-        }
-
-        if (this.casProxyDecider == null) {
-            throw new IllegalArgumentException("A casProxyDecider must be set");
-        }
-
-        if (this.statelessTicketCache == null) {
-            throw new IllegalArgumentException(
-                "A statelessTicketCache must be set");
-        }
-
-        if (key == null) {
-            throw new IllegalArgumentException(
-                "A Key is required so CasAuthenticationProvider can identify tokens it previously authenticated");
-        }
+        Assert.notNull(this.casAuthoritiesPopulator, "A casAuthoritiesPopulator must be set");
+        Assert.notNull(this.ticketValidator, "A ticketValidator must be set");
+        Assert.notNull(this.casProxyDecider, "A casProxyDecider must be set");
+        Assert.notNull(this.statelessTicketCache, "A statelessTicketCache must be set");
+        Assert.notNull(key, "A Key is required so CasAuthenticationProvider can identify tokens it previously authenticated");
     }
 
     public Authentication authenticate(Authentication authentication)

+ 3 - 3
core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationToken.java

@@ -23,6 +23,8 @@ import java.io.Serializable;
 
 import java.util.List;
 
+import org.springframework.util.Assert;
+
 
 /**
  * Represents a successful CAS <code>Authentication</code>.
@@ -77,11 +79,9 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken
         }
 
         for (int i = 0; i < authorities.length; i++) {
-            if (authorities[i] == null) {
-                throw new IllegalArgumentException("Granted authority element "
+            Assert.notNull(authorities[i], "Granted authority element "
                     + i
                     + " is null - GrantedAuthority[] cannot contain any null elements");
-            }
         }
 
         this.keyHash = key.hashCode();

+ 2 - 3
core/src/main/java/org/acegisecurity/providers/cas/cache/EhCacheBasedTicketCache.java

@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.util.Assert;
 
 
 /**
@@ -80,9 +81,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (cache == null) {
-            throw new IllegalArgumentException("cache mandatory");
-        }
+        Assert.notNull(cache, "cache mandatory");
     }
 
     public void putTicketInCache(CasAuthenticationToken token) {

+ 2 - 4
core/src/main/java/org/acegisecurity/providers/cas/populator/DaoCasAuthoritiesPopulator.java

@@ -21,6 +21,7 @@ import net.sf.acegisecurity.providers.cas.CasAuthoritiesPopulator;
 import net.sf.acegisecurity.providers.dao.AuthenticationDao;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -58,9 +59,6 @@ public class DaoCasAuthoritiesPopulator implements CasAuthoritiesPopulator,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.authenticationDao == null) {
-            throw new IllegalArgumentException(
-                "An authenticationDao must be set");
-        }
+        Assert.notNull(this.authenticationDao, "An authenticationDao must be set");
     }
 }

+ 2 - 3
core/src/main/java/org/acegisecurity/providers/cas/proxy/AcceptAnyCasProxy.java

@@ -20,6 +20,7 @@ import net.sf.acegisecurity.providers.cas.ProxyUntrustedException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.springframework.util.Assert;
 
 import java.util.List;
 
@@ -44,9 +45,7 @@ public class AcceptAnyCasProxy implements CasProxyDecider {
 
     public void confirmProxyListTrusted(List proxyList)
         throws ProxyUntrustedException {
-        if (proxyList == null) {
-            throw new IllegalArgumentException("proxyList cannot be null");
-        }
+        Assert.notNull(proxyList, "proxyList cannot be null");
 
         if (logger.isDebugEnabled()) {
             logger.debug("Always accepting proxy list: " + proxyList.toString());

+ 4 - 8
core/src/main/java/org/acegisecurity/providers/cas/proxy/NamedCasProxyDecider.java

@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.util.List;
 
@@ -58,17 +59,12 @@ public class NamedCasProxyDecider implements CasProxyDecider, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.validProxies == null) {
-            throw new IllegalArgumentException(
-                "A validProxies list must be set");
-        }
+        Assert.notNull(this.validProxies, "A validProxies list must be set");
     }
 
     public void confirmProxyListTrusted(List proxyList)
         throws ProxyUntrustedException {
-        if (proxyList == null) {
-            throw new IllegalArgumentException("proxyList cannot be null");
-        }
+        Assert.notNull(proxyList, "proxyList cannot be null");
 
         if (logger.isDebugEnabled()) {
             logger.debug("Proxy list: " + proxyList.toString());
@@ -81,7 +77,7 @@ public class NamedCasProxyDecider implements CasProxyDecider, InitializingBean {
 
         if (!validProxies.contains(proxyList.get(0))) {
             throw new ProxyUntrustedException("Nearest proxy '"
-                + proxyList.get(0) + "' is untrusted");
+                    + proxyList.get(0) + "' is untrusted");
         }
     }
 }

+ 3 - 4
core/src/main/java/org/acegisecurity/providers/cas/proxy/RejectProxyTickets.java

@@ -20,6 +20,7 @@ import net.sf.acegisecurity.providers.cas.ProxyUntrustedException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.springframework.util.Assert;
 
 import java.util.List;
 
@@ -44,9 +45,7 @@ public class RejectProxyTickets implements CasProxyDecider {
 
     public void confirmProxyListTrusted(List proxyList)
         throws ProxyUntrustedException {
-        if (proxyList == null) {
-            throw new IllegalArgumentException("proxyList cannot be null");
-        }
+        Assert.notNull(proxyList, "proxyList cannot be null");
 
         if (proxyList.size() == 0) {
             // A Service Ticket (not a Proxy Ticket)
@@ -55,7 +54,7 @@ public class RejectProxyTickets implements CasProxyDecider {
 
         if (logger.isDebugEnabled()) {
             logger.debug("Proxies are unacceptable; proxy list provided: "
-                + proxyList.toString());
+                    + proxyList.toString());
         }
 
         throw new ProxyUntrustedException("Proxy tickets are rejected");

+ 3 - 8
core/src/main/java/org/acegisecurity/providers/cas/ticketvalidator/AbstractTicketValidator.java

@@ -19,6 +19,7 @@ import net.sf.acegisecurity.providers.cas.TicketValidator;
 import net.sf.acegisecurity.ui.cas.ServiceProperties;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -80,14 +81,8 @@ public abstract class AbstractTicketValidator implements TicketValidator,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if ((this.casValidate == null) || "".equals(casValidate)) {
-            throw new IllegalArgumentException("A casValidate URL must be set");
-        }
-
-        if (serviceProperties == null) {
-            throw new IllegalArgumentException(
-                "serviceProperties must be specified");
-        }
+        Assert.hasLength(casValidate, "A casValidate URL must be set");
+        Assert.notNull(serviceProperties, "serviceProperties must be specified");
 
         if ((trustStore != null) && (!"".equals(trustStore))) {
             System.setProperty("javax.net.ssl.trustStore", trustStore);

+ 3 - 8
core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationProvider.java

@@ -45,6 +45,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
 import org.springframework.dao.DataAccessException;
+import org.springframework.util.Assert;
 
 
 /**
@@ -196,14 +197,8 @@ public class DaoAuthenticationProvider implements AuthenticationProvider,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.authenticationDao == null) {
-            throw new IllegalArgumentException(
-                "An Authentication DAO must be set");
-        }
-
-        if (this.userCache == null) {
-            throw new IllegalArgumentException("A user cache must be set");
-        }
+        Assert.notNull(this.authenticationDao, "An Authentication DAO must be set");
+        Assert.notNull(this.userCache, "A user cache must be set");
     }
 
     public Authentication authenticate(Authentication authentication)

+ 3 - 8
core/src/main/java/org/acegisecurity/providers/dao/PasswordDaoAuthenticationProvider.java

@@ -42,6 +42,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
 import org.springframework.dao.DataAccessException;
+import org.springframework.util.Assert;
 
 
 /**
@@ -141,14 +142,8 @@ public class PasswordDaoAuthenticationProvider implements AuthenticationProvider
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.authenticationDao == null) {
-            throw new IllegalArgumentException(
-                "A Password authentication DAO must be set");
-        }
-
-        if (this.userCache == null) {
-            throw new IllegalArgumentException("A user cache must be set");
-        }
+        Assert.notNull(this.authenticationDao, "A Password authentication DAO must be set");
+        Assert.notNull(this.userCache, "A user cache must be set");
     }
 
     public Authentication authenticate(Authentication authentication)

+ 2 - 3
core/src/main/java/org/acegisecurity/providers/dao/cache/EhCacheBasedUserCache.java

@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.util.Assert;
 
 
 /**
@@ -79,9 +80,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (cache == null) {
-            throw new IllegalArgumentException("cache mandatory");
-        }
+        Assert.notNull(cache, "cache mandatory");
     }
 
     public void putUserInCache(UserDetails user) {

+ 2 - 3
core/src/main/java/org/acegisecurity/providers/dao/event/AuthenticationEvent.java

@@ -20,6 +20,7 @@ import net.sf.acegisecurity.UserDetails;
 import net.sf.acegisecurity.providers.dao.User;
 
 import org.springframework.context.ApplicationEvent;
+import org.springframework.util.Assert;
 
 
 /**
@@ -53,9 +54,7 @@ public abstract class AuthenticationEvent extends ApplicationEvent {
         super(authentication);
 
         // No need to check authentication isn't null, as done by super
-        if (user == null) {
-            throw new IllegalArgumentException("User is required");
-        }
+        Assert.notNull(user, "User is required");
 
         this.user = user;
     }

+ 3 - 8
core/src/main/java/org/acegisecurity/providers/jaas/JaasAuthenticationProvider.java

@@ -259,14 +259,9 @@ public class JaasAuthenticationProvider implements AuthenticationProvider,
 
     public void afterPropertiesSet() throws Exception {
 
-        if (loginConfig == null) {
-            throw new IllegalArgumentException("loginConfig must be set on "
-                    + getClass());
-        }
-
-        if ((loginContextName == null) || "".equals(loginContextName)) {
-            throw new IllegalArgumentException("loginContextName must be set on " + getClass());
-        }
+        Assert.notNull(loginConfig, "loginConfig must be set on "
+                + getClass());
+        Assert.hasLength(loginContextName, "loginContextName must be set on " + getClass());
 
         String loginConfigStr = null;
 

+ 2 - 4
core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationManagerImpl.java

@@ -21,6 +21,7 @@ import net.sf.acegisecurity.GrantedAuthority;
 import net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -53,10 +54,7 @@ public class RemoteAuthenticationManagerImpl
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.authenticationManager == null) {
-            throw new IllegalArgumentException(
-                "authenticationManager is required");
-        }
+        Assert.notNull(this.authenticationManager, "authenticationManager is required");
     }
 
     public GrantedAuthority[] attemptAuthentication(String username,

+ 2 - 4
core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationProvider.java

@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -79,10 +80,7 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.remoteAuthenticationManager == null) {
-            throw new IllegalArgumentException(
-                "remoteAuthenticationManager is mandatory");
-        }
+        Assert.notNull(this.remoteAuthenticationManager, "remoteAuthenticationManager is mandatory");
     }
 
     public Authentication authenticate(Authentication authentication)

+ 3 - 3
core/src/main/java/org/acegisecurity/providers/rememberme/RememberMeAuthenticationToken.java

@@ -20,6 +20,8 @@ import net.sf.acegisecurity.providers.AbstractAuthenticationToken;
 
 import java.io.Serializable;
 
+import org.springframework.util.Assert;
+
 
 /**
  * Represents a remembered <code>Authentication</code>.
@@ -62,11 +64,9 @@ public class RememberMeAuthenticationToken extends AbstractAuthenticationToken
         }
 
         for (int i = 0; i < authorities.length; i++) {
-            if (authorities[i] == null) {
-                throw new IllegalArgumentException("Granted authority element "
+            Assert.notNull(authorities[i], "Granted authority element "
                     + i
                     + " is null - GrantedAuthority[] cannot contain any null elements");
-            }
         }
 
         this.keyHash = key.hashCode();

+ 2 - 4
core/src/main/java/org/acegisecurity/runas/RunAsImplAuthenticationProvider.java

@@ -21,6 +21,7 @@ import net.sf.acegisecurity.BadCredentialsException;
 import net.sf.acegisecurity.providers.AuthenticationProvider;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 
 /**
@@ -58,10 +59,7 @@ public class RunAsImplAuthenticationProvider implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (key == null) {
-            throw new IllegalArgumentException(
-                "A Key is required and should match that configured for the RunAsManagerImpl");
-        }
+        Assert.notNull(key, "A Key is required and should match that configured for the RunAsManagerImpl");
     }
 
     public Authentication authenticate(Authentication authentication)

+ 2 - 4
core/src/main/java/org/acegisecurity/runas/RunAsManagerImpl.java

@@ -23,6 +23,7 @@ import net.sf.acegisecurity.GrantedAuthorityImpl;
 import net.sf.acegisecurity.RunAsManager;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.util.Iterator;
 import java.util.List;
@@ -94,10 +95,7 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (key == null) {
-            throw new IllegalArgumentException(
-                "A Key is required and should match that configured for the RunAsImplAuthenticationProvider");
-        }
+        Assert.notNull(key, "A Key is required and should match that configured for the RunAsImplAuthenticationProvider");
     }
 
     public Authentication buildRunAs(Authentication authentication,

+ 7 - 15
core/src/main/java/org/acegisecurity/securechannel/ChannelProcessingFilter.java

@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -96,23 +97,15 @@ public class ChannelProcessingFilter implements InitializingBean, Filter {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (filterInvocationDefinitionSource == null) {
-            throw new IllegalArgumentException(
-                "filterInvocationDefinitionSource must be specified");
-        }
-
-        if (channelDecisionManager == null) {
-            throw new IllegalArgumentException(
-                "channelDecisionManager must be specified");
-        }
+        Assert.notNull(filterInvocationDefinitionSource, "filterInvocationDefinitionSource must be specified");
+        Assert.notNull(channelDecisionManager, "channelDecisionManager must be specified");
 
         Iterator iter = this.filterInvocationDefinitionSource
-            .getConfigAttributeDefinitions();
+                .getConfigAttributeDefinitions();
 
         if (iter == null) {
             if (logger.isWarnEnabled()) {
-                logger.warn(
-                    "Could not validate configuration attributes as the FilterInvocationDefinitionSource did not return a ConfigAttributeDefinition Iterator");
+                logger.warn("Could not validate configuration attributes as the FilterInvocationDefinitionSource did not return a ConfigAttributeDefinition Iterator");
             }
 
             return;
@@ -122,7 +115,7 @@ public class ChannelProcessingFilter implements InitializingBean, Filter {
 
         while (iter.hasNext()) {
             ConfigAttributeDefinition def = (ConfigAttributeDefinition) iter
-                .next();
+                    .next();
             Iterator attributes = def.getConfigAttributes();
 
             while (attributes.hasNext()) {
@@ -139,8 +132,7 @@ public class ChannelProcessingFilter implements InitializingBean, Filter {
                 logger.info("Validated configuration attributes");
             }
         } else {
-            throw new IllegalArgumentException(
-                "Unsupported configuration attributes: " + set.toString());
+            throw new IllegalArgumentException("Unsupported configuration attributes: " + set.toString());
         }
     }
 

+ 3 - 7
core/src/main/java/org/acegisecurity/securechannel/InsecureChannelProcessor.java

@@ -20,6 +20,7 @@ import net.sf.acegisecurity.ConfigAttributeDefinition;
 import net.sf.acegisecurity.intercept.web.FilterInvocation;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -77,13 +78,8 @@ public class InsecureChannelProcessor implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if ((insecureKeyword == null) || "".equals(insecureKeyword)) {
-            throw new IllegalArgumentException("insecureKeyword required");
-        }
-
-        if (entryPoint == null) {
-            throw new IllegalArgumentException("entryPoint required");
-        }
+        Assert.hasLength(insecureKeyword, "insecureKeyword required");
+        Assert.notNull(entryPoint, "entryPoint required");
     }
 
     public void decide(FilterInvocation invocation,

+ 3 - 7
core/src/main/java/org/acegisecurity/securechannel/RetryWithHttpEntryPoint.java

@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -76,13 +77,8 @@ public class RetryWithHttpEntryPoint implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (portMapper == null) {
-            throw new IllegalArgumentException("portMapper is required");
-        }
-
-        if (portResolver == null) {
-            throw new IllegalArgumentException("portResolver is required");
-        }
+        Assert.notNull(portMapper, "portMapper is required");
+        Assert.notNull(portResolver, "portResolver is required");
     }
 
     public void commence(ServletRequest request, ServletResponse response)

+ 3 - 7
core/src/main/java/org/acegisecurity/securechannel/RetryWithHttpsEntryPoint.java

@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -76,13 +77,8 @@ public class RetryWithHttpsEntryPoint implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (portMapper == null) {
-            throw new IllegalArgumentException("portMapper is required");
-        }
-
-        if (portResolver == null) {
-            throw new IllegalArgumentException("portResolver is required");
-        }
+        Assert.notNull(portMapper, "portMapper is required");
+        Assert.notNull(portResolver, "portResolver is required");
     }
 
     public void commence(ServletRequest request, ServletResponse response)

+ 4 - 10
core/src/main/java/org/acegisecurity/securechannel/SecureChannelProcessor.java

@@ -20,6 +20,7 @@ import net.sf.acegisecurity.ConfigAttributeDefinition;
 import net.sf.acegisecurity.intercept.web.FilterInvocation;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -76,20 +77,13 @@ public class SecureChannelProcessor implements InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if ((secureKeyword == null) || "".equals(secureKeyword)) {
-            throw new IllegalArgumentException("secureKeyword required");
-        }
-
-        if (entryPoint == null) {
-            throw new IllegalArgumentException("entryPoint required");
-        }
+        Assert.hasLength(secureKeyword, "secureKeyword required");
+        Assert.notNull(entryPoint, "entryPoint required");
     }
 
     public void decide(FilterInvocation invocation,
         ConfigAttributeDefinition config) throws IOException, ServletException {
-        if ((invocation == null) || (config == null)) {
-            throw new IllegalArgumentException("Nulls cannot be provided");
-        }
+        Assert.isTrue((invocation != null) && (config != null), "Nulls cannot be provided");
 
         Iterator iter = config.getConfigAttributes();
 

+ 3 - 9
core/src/main/java/org/acegisecurity/ui/basicauth/BasicProcessingFilter.java

@@ -30,6 +30,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -132,15 +133,8 @@ public class BasicProcessingFilter implements Filter, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.authenticationManager == null) {
-            throw new IllegalArgumentException(
-                "An AuthenticationManager is required");
-        }
-
-        if (this.authenticationEntryPoint == null) {
-            throw new IllegalArgumentException(
-                "An AuthenticationEntryPoint is required");
-        }
+        Assert.notNull(this.authenticationManager, "An AuthenticationManager is required");
+        Assert.notNull(this.authenticationEntryPoint, "An AuthenticationEntryPoint is required");
     }
 
     public void destroy() {}

+ 3 - 8
core/src/main/java/org/acegisecurity/ui/cas/CasProcessingFilterEntryPoint.java

@@ -19,6 +19,7 @@ import net.sf.acegisecurity.AuthenticationException;
 import net.sf.acegisecurity.intercept.web.AuthenticationEntryPoint;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -79,14 +80,8 @@ public class CasProcessingFilterEntryPoint implements AuthenticationEntryPoint,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if ((loginUrl == null) || "".equals(loginUrl)) {
-            throw new IllegalArgumentException("loginUrl must be specified");
-        }
-
-        if (serviceProperties == null) {
-            throw new IllegalArgumentException(
-                "serviceProperties must be specified");
-        }
+        Assert.hasLength(loginUrl, "loginUrl must be specified");
+        Assert.notNull(serviceProperties, "serviceProperties must be specified");
     }
 
     public void commence(ServletRequest request, ServletResponse response,

+ 4 - 11
core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterEntryPoint.java

@@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -121,17 +122,9 @@ public class AuthenticationProcessingFilterEntryPoint
     }
 
     public void afterPropertiesSet() throws Exception {
-        if ((loginFormUrl == null) || "".equals(loginFormUrl)) {
-            throw new IllegalArgumentException("loginFormUrl must be specified");
-        }
-
-        if (portMapper == null) {
-            throw new IllegalArgumentException("portMapper must be specified");
-        }
-
-        if (portResolver == null) {
-            throw new IllegalArgumentException("portResolver must be specified");
-        }
+        Assert.hasLength(loginFormUrl,"loginFormUrl must be specified");
+        Assert.notNull(portMapper, "portMapper must be specified");
+        Assert.notNull(portResolver, "portResolver must be specified");
     }
 
     public void commence(ServletRequest request, ServletResponse response,

+ 2 - 3
core/src/main/java/org/acegisecurity/userdetails/User.java

@@ -17,6 +17,7 @@ package net.sf.acegisecurity.providers.dao;
 
 import net.sf.acegisecurity.GrantedAuthority;
 import net.sf.acegisecurity.UserDetails;
+import org.springframework.util.Assert;
 
 
 /**
@@ -134,11 +135,9 @@ public class User implements UserDetails {
         }
 
         for (int i = 0; i < authorities.length; i++) {
-            if (authorities[i] == null) {
-                throw new IllegalArgumentException("Granted authority element "
+            Assert.notNull(authorities[i], "Granted authority element "
                     + i
                     + " is null - GrantedAuthority[] cannot contain any null elements");
-            }
         }
 
         this.username = username;

+ 2 - 4
core/src/main/java/org/acegisecurity/userdetails/memory/InMemoryDaoImpl.java

@@ -22,6 +22,7 @@ import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
 import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.dao.DataAccessException;
+import org.springframework.util.Assert;
 
 
 /**
@@ -46,10 +47,7 @@ public class InMemoryDaoImpl implements AuthenticationDao, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (this.userMap == null) {
-            throw new IllegalArgumentException(
-                "A list of users, passwords, enabled/disabled status and their granted authorities must be set");
-        }
+        Assert.notNull(this.userMap, "A list of users, passwords, enabled/disabled status and their granted authorities must be set");
     }
 
     public UserDetails loadUserByUsername(String username)

+ 2 - 3
core/src/main/java/org/acegisecurity/userdetails/memory/UserMap.java

@@ -21,6 +21,7 @@ import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.springframework.util.Assert;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -82,9 +83,7 @@ public class UserMap {
      * @throws IllegalArgumentException if a null User was passed
      */
     public void addUser(UserDetails user) throws IllegalArgumentException {
-        if (user == null) {
-            throw new IllegalArgumentException("Must be a valid User");
-        }
+        Assert.notNull(user, "Must be a valid User");
 
         logger.info("Adding user [" + user + "]");
         this.userMap.put(user.getUsername().toLowerCase(), user);

+ 4 - 12
core/src/main/java/org/acegisecurity/util/FilterChainProxy.java

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -133,15 +134,8 @@ public class FilterChainProxy implements Filter, InitializingBean,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (filterInvocationDefinitionSource == null) {
-            throw new IllegalArgumentException(
-                "filterInvocationDefinitionSource must be specified");
-        }
-
-        if (this.filterInvocationDefinitionSource.getConfigAttributeDefinitions() == null) {
-            throw new IllegalArgumentException(
-                "FilterChainProxy requires the FitlerInvocationDefinitionSource to return a non-null response to getConfigAttributeDefinitions()");
-        }
+        Assert.notNull(filterInvocationDefinitionSource, "filterInvocationDefinitionSource must be specified");
+        Assert.notNull(this.filterInvocationDefinitionSource.getConfigAttributeDefinitions(), "FilterChainProxy requires the FitlerInvocationDefinitionSource to return a non-null response to getConfigAttributeDefinitions()");
     }
 
     public void destroy() {
@@ -252,11 +246,9 @@ public class FilterChainProxy implements Filter, InitializingBean,
             ConfigAttribute attr = (ConfigAttribute) attributes.next();
             String filterName = attr.getAttribute();
 
-            if (filterName == null) {
-                throw new IllegalArgumentException("Configuration attribute: '"
+            Assert.notNull(filterName, "Configuration attribute: '"
                     + attr
                     + "' returned null to the getAttribute() method, which is invalid when used with FilterChainProxy");
-            }
 
             list.add(this.applicationContext.getBean(filterName, Filter.class));
         }

+ 6 - 8
core/src/main/java/org/acegisecurity/util/PortMapperImpl.java

@@ -15,6 +15,8 @@
 
 package net.sf.acegisecurity.util;
 
+import org.springframework.util.Assert;
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -75,10 +77,7 @@ public class PortMapperImpl implements PortMapper {
      *         the range 1-65535 for that mapping.
      */
     public void setPortMappings(Map newMappings) {
-        if (newMappings == null) {
-            throw new IllegalArgumentException(
-                "A valid list of HTTPS port mappings must be provided");
-        }
+        Assert.notNull(newMappings, "A valid list of HTTPS port mappings must be provided");
 
         httpsPortMappings.clear();
 
@@ -90,10 +89,9 @@ public class PortMapperImpl implements PortMapper {
             Integer httpsPort = new Integer((String) entry.getValue());
 
             if ((httpPort.intValue() < 1) || (httpPort.intValue() > 65535)
-                || (httpsPort.intValue() < 1) || (httpsPort.intValue() > 65535)) {
-                throw new IllegalArgumentException(
-                    "one or both ports out of legal range: " + httpPort + ", "
-                    + httpsPort);
+                    || (httpsPort.intValue() < 1) || (httpsPort.intValue() > 65535)) {
+                throw new IllegalArgumentException("one or both ports out of legal range: " + httpPort + ", "
+                        + httpsPort);
             }
 
             httpsPortMappings.put(httpPort, httpsPort);

+ 2 - 3
core/src/main/java/org/acegisecurity/util/PortResolverImpl.java

@@ -16,6 +16,7 @@
 package net.sf.acegisecurity.util;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import javax.servlet.ServletRequest;
 
@@ -78,8 +79,6 @@ public class PortResolverImpl implements InitializingBean, PortResolver {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (portMapper == null) {
-            throw new IllegalArgumentException("portMapper required");
-        }
+        Assert.notNull(portMapper, "portMapper required");
     }
 }

+ 5 - 15
core/src/main/java/org/acegisecurity/vote/BasicAclEntryVoter.java

@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -194,23 +195,12 @@ public class BasicAclEntryVoter implements AccessDecisionVoter,
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (processConfigAttribute == null) {
-            throw new IllegalArgumentException(
-                "A processConfigAttribute is mandatory");
-        }
+        Assert.notNull(processConfigAttribute, "A processConfigAttribute is mandatory");
+        Assert.notNull(aclManager, "An aclManager is mandatory");
+        Assert.notNull(processDomainObjectClass, "A processDomainObjectClass is mandatory");
 
         if ((requirePermission == null) || (requirePermission.length == 0)) {
-            throw new IllegalArgumentException(
-                "One or more requirePermission entries is mandatory");
-        }
-
-        if (aclManager == null) {
-            throw new IllegalArgumentException("An aclManager is mandatory");
-        }
-
-        if (processDomainObjectClass == null) {
-            throw new IllegalArgumentException(
-                "A processDomainObjectClass is mandatory");
+            throw new IllegalArgumentException("One or more requirePermission entries is mandatory");
         }
     }
 

+ 2 - 4
samples/contacts/src/main/java/sample/contact/AddPermissionController.java

@@ -27,6 +27,7 @@ import org.springframework.web.bind.RequestUtils;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.SimpleFormController;
 import org.springframework.web.servlet.view.RedirectView;
+import org.springframework.util.Assert;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -60,10 +61,7 @@ public class AddPermissionController extends SimpleFormController
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactManager == null) {
-            throw new IllegalArgumentException(
-                "A ContactManager implementation is required");
-        }
+        Assert.notNull(contactManager, "A ContactManager implementation is required");
     }
 
     protected ModelAndView disallowDuplicateFormSubmission(

+ 3 - 9
samples/contacts/src/main/java/sample/contact/AdminPermissionController.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.InitializingBean;
 import org.springframework.web.bind.RequestUtils;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -65,15 +66,8 @@ public class AdminPermissionController implements Controller, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactManager == null) {
-            throw new IllegalArgumentException(
-                "A ContactManager implementation is required");
-        }
-
-        if (aclManager == null) {
-            throw new IllegalArgumentException(
-                "An aclManager implementation is required");
-        }
+        Assert.notNull(contactManager, "A ContactManager implementation is required");
+        Assert.notNull(aclManager, "An aclManager implementation is required");
     }
 
     public ModelAndView handleRequest(HttpServletRequest request,

+ 3 - 7
samples/contacts/src/main/java/sample/contact/ContactManagerBackend.java

@@ -26,6 +26,7 @@ import net.sf.acegisecurity.context.security.SecureContextUtils;
 import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.context.support.ApplicationObjectSupport;
+import org.springframework.util.Assert;
 
 import java.util.List;
 import java.util.Random;
@@ -122,13 +123,8 @@ public class ContactManagerBackend extends ApplicationObjectSupport
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactDao == null) {
-            throw new IllegalArgumentException("contactDao required");
-        }
-
-        if (basicAclExtendedDao == null) {
-            throw new IllegalArgumentException("basicAclExtendedDao required");
-        }
+        Assert.notNull(contactDao, "contactDao required");
+        Assert.notNull(basicAclExtendedDao, "basicAclExtendedDao required");
     }
 
     public void create(Contact contact) {

+ 46 - 91
samples/contacts/src/main/java/sample/contact/DataSourcePopulator.java

@@ -18,6 +18,7 @@ package sample.contact;
 import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.util.Assert;
 
 import javax.sql.DataSource;
 
@@ -44,86 +45,47 @@ public class DataSourcePopulator implements InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (dataSource == null) {
-            throw new IllegalArgumentException("dataSource required");
-        }
+        Assert.notNull(dataSource, "dataSource required");
 
         JdbcTemplate template = new JdbcTemplate(dataSource);
 
-        template.execute(
-            "CREATE TABLE CONTACTS(ID INTEGER NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
-        template.execute(
-            "INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa
-        template.execute(
-            "INSERT INTO contacts VALUES (2, 'Michael Citizen', 'michael@xyz.com');"); // marissa
-        template.execute(
-            "INSERT INTO contacts VALUES (3, 'Joe Bloggs', 'joe@demo.com');"); // marissa
-        template.execute(
-            "INSERT INTO contacts VALUES (4, 'Karen Sutherland', 'karen@sutherland.com');"); // marissa + dianne + scott
-        template.execute(
-            "INSERT INTO contacts VALUES (5, 'Mitchell Howard', 'mitchell@abcdef.com');"); // dianne
-        template.execute(
-            "INSERT INTO contacts VALUES (6, 'Rose Costas', 'rose@xyz.com');"); // dianne + scott
-        template.execute(
-            "INSERT INTO contacts VALUES (7, 'Amanda Smith', 'amanda@abcdef.com');"); // scott
-        template.execute(
-            "INSERT INTO contacts VALUES (8, 'Cindy Smith', 'cindy@smith.com');"); // dianne + scott
-        template.execute(
-            "INSERT INTO contacts VALUES (9, 'Jonathan Citizen', 'jonathan@xyz.com');"); // scott
-        template.execute(
-            "CREATE TABLE ACL_OBJECT_IDENTITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100)  NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT INTEGER,ACL_CLASS VARCHAR_IGNORECASE(250) NOT NULL,CONSTRAINT UNIQUE_OBJECT_IDENTITY UNIQUE(OBJECT_IDENTITY),CONSTRAINT SYS_FK_3 FOREIGN KEY(PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID))");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (2, 'sample.contact.Contact:2', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (3, 'sample.contact.Contact:3', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (4, 'sample.contact.Contact:4', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (5, 'sample.contact.Contact:5', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (6, 'sample.contact.Contact:6', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (7, 'sample.contact.Contact:7', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (8, 'sample.contact.Contact:8', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "INSERT INTO acl_object_identity VALUES (9, 'sample.contact.Contact:9', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
-        template.execute(
-            "CREATE TABLE ACL_PERMISSION(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100)  NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY INTEGER NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 1, 'marissa', 1);"); // administer
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); // read
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 3, 'marissa', 22);"); // read+write+delete 
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 4, 'marissa', 1);"); // administer
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 4, 'dianne', 1);"); // administer
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 4, 'scott', 2);"); // read 
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 5, 'dianne', 2);"); // read
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 6, 'dianne', 22);"); // read+write+delete
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 6, 'scott', 2);"); // read
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 7, 'scott', 1);"); // administer
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 8, 'dianne', 2);"); // read
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 8, 'scott', 2);"); // read
-        template.execute(
-            "INSERT INTO acl_permission VALUES (null, 9, 'scott', 22);"); // read+write+delete
-        template.execute(
-            "CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(50) NOT NULL,ENABLED BOOLEAN NOT NULL);");
-        template.execute(
-            "CREATE TABLE AUTHORITIES(USERNAME VARCHAR_IGNORECASE(50) NOT NULL,AUTHORITY VARCHAR_IGNORECASE(50) NOT NULL,CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME));");
-        template.execute(
-            "CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
+        template.execute("CREATE TABLE CONTACTS(ID INTEGER NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
+        template.execute("INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa
+        template.execute("INSERT INTO contacts VALUES (2, 'Michael Citizen', 'michael@xyz.com');"); // marissa
+        template.execute("INSERT INTO contacts VALUES (3, 'Joe Bloggs', 'joe@demo.com');"); // marissa
+        template.execute("INSERT INTO contacts VALUES (4, 'Karen Sutherland', 'karen@sutherland.com');"); // marissa + dianne + scott
+        template.execute("INSERT INTO contacts VALUES (5, 'Mitchell Howard', 'mitchell@abcdef.com');"); // dianne
+        template.execute("INSERT INTO contacts VALUES (6, 'Rose Costas', 'rose@xyz.com');"); // dianne + scott
+        template.execute("INSERT INTO contacts VALUES (7, 'Amanda Smith', 'amanda@abcdef.com');"); // scott
+        template.execute("INSERT INTO contacts VALUES (8, 'Cindy Smith', 'cindy@smith.com');"); // dianne + scott
+        template.execute("INSERT INTO contacts VALUES (9, 'Jonathan Citizen', 'jonathan@xyz.com');"); // scott
+        template.execute("CREATE TABLE ACL_OBJECT_IDENTITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100)  NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT INTEGER,ACL_CLASS VARCHAR_IGNORECASE(250) NOT NULL,CONSTRAINT UNIQUE_OBJECT_IDENTITY UNIQUE(OBJECT_IDENTITY),CONSTRAINT SYS_FK_3 FOREIGN KEY(PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID))");
+        template.execute("INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (2, 'sample.contact.Contact:2', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (3, 'sample.contact.Contact:3', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (4, 'sample.contact.Contact:4', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (5, 'sample.contact.Contact:5', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (6, 'sample.contact.Contact:6', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (7, 'sample.contact.Contact:7', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (8, 'sample.contact.Contact:8', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("INSERT INTO acl_object_identity VALUES (9, 'sample.contact.Contact:9', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
+        template.execute("CREATE TABLE ACL_PERMISSION(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100)  NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY INTEGER NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
+        template.execute("INSERT INTO acl_permission VALUES (null, 1, 'marissa', 1);"); // administer
+        template.execute("INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); // read
+        template.execute("INSERT INTO acl_permission VALUES (null, 3, 'marissa', 22);"); // read+write+delete
+        template.execute("INSERT INTO acl_permission VALUES (null, 4, 'marissa', 1);"); // administer
+        template.execute("INSERT INTO acl_permission VALUES (null, 4, 'dianne', 1);"); // administer
+        template.execute("INSERT INTO acl_permission VALUES (null, 4, 'scott', 2);"); // read
+        template.execute("INSERT INTO acl_permission VALUES (null, 5, 'dianne', 2);"); // read
+        template.execute("INSERT INTO acl_permission VALUES (null, 6, 'dianne', 22);"); // read+write+delete
+        template.execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 2);"); // read
+        template.execute("INSERT INTO acl_permission VALUES (null, 7, 'scott', 1);"); // administer
+        template.execute("INSERT INTO acl_permission VALUES (null, 8, 'dianne', 2);"); // read
+        template.execute("INSERT INTO acl_permission VALUES (null, 8, 'scott', 2);"); // read
+        template.execute("INSERT INTO acl_permission VALUES (null, 9, 'scott', 22);"); // read+write+delete
+        template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(50) NOT NULL,ENABLED BOOLEAN NOT NULL);");
+        template.execute("CREATE TABLE AUTHORITIES(USERNAME VARCHAR_IGNORECASE(50) NOT NULL,AUTHORITY VARCHAR_IGNORECASE(50) NOT NULL,CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME));");
+        template.execute("CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
 
         /*
                    Passwords encoded using MD5, NOT in Base64 format, with null as salt
@@ -133,20 +95,13 @@ public class DataSourcePopulator implements InitializingBean {
                    Encoded password for peter is "opal" (but user is disabled)
         
          */
-        template.execute(
-            "INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);");
-        template.execute(
-            "INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);");
-        template.execute(
-            "INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
-        template.execute(
-            "INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
-        template.execute(
-            "INSERT INTO AUTHORITIES VALUES('marissa','ROLE_USER');");
-        template.execute(
-            "INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR');");
-        template.execute(
-            "INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
+        template.execute("INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);");
+        template.execute("INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);");
+        template.execute("INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
+        template.execute("INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
+        template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_USER');");
+        template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR');");
+        template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
         template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');");
         template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
     }

+ 2 - 4
samples/contacts/src/main/java/sample/contact/DeleteController.java

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.InitializingBean;
 import org.springframework.web.bind.RequestUtils;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -50,10 +51,7 @@ public class DeleteController implements Controller, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactManager == null) {
-            throw new IllegalArgumentException(
-                "A ContactManager implementation is required");
-        }
+        Assert.notNull(contactManager, "A ContactManager implementation is required");
     }
 
     public ModelAndView handleRequest(HttpServletRequest request,

+ 3 - 9
samples/contacts/src/main/java/sample/contact/DeletePermissionController.java

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.InitializingBean;
 import org.springframework.web.bind.RequestUtils;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -64,15 +65,8 @@ public class DeletePermissionController implements Controller, InitializingBean
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactManager == null) {
-            throw new IllegalArgumentException(
-                "A ContactManager implementation is required");
-        }
-
-        if (aclManager == null) {
-            throw new IllegalArgumentException(
-                "An aclManager implementation is required");
-        }
+        Assert.notNull(contactManager, "A ContactManager implementation is required");
+        Assert.notNull(aclManager, "An aclManager implementation is required");
     }
 
     public ModelAndView handleRequest(HttpServletRequest request,

+ 2 - 4
samples/contacts/src/main/java/sample/contact/PublicIndexController.java

@@ -19,6 +19,7 @@ import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -49,10 +50,7 @@ public class PublicIndexController implements Controller, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactManager == null) {
-            throw new IllegalArgumentException(
-                "A ContactManager implementation is required");
-        }
+        Assert.notNull(contactManager, "A ContactManager implementation is required");
     }
 
     public ModelAndView handleRequest(HttpServletRequest request,

+ 2 - 4
samples/contacts/src/main/java/sample/contact/SecureIndexController.java

@@ -19,6 +19,7 @@ import org.springframework.beans.factory.InitializingBean;
 
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
+import org.springframework.util.Assert;
 
 import java.io.IOException;
 
@@ -53,10 +54,7 @@ public class SecureIndexController implements Controller, InitializingBean {
     }
 
     public void afterPropertiesSet() throws Exception {
-        if (contactManager == null) {
-            throw new IllegalArgumentException(
-                "A ContactManager implementation is required");
-        }
+        Assert.notNull(contactManager, "A ContactManager implementation is required");
     }
 
     public ModelAndView handleRequest(HttpServletRequest request,