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

This commit is contained in:
Luke Taylor 2005-04-15 01:21:41 +00:00
parent fdf5c63033
commit 1a78f9e15f
53 changed files with 268 additions and 539 deletions

View File

@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -50,10 +51,7 @@ public class AclProviderManager implements AclManager, InitializingBean {
//~ Methods ================================================================ //~ Methods ================================================================
public AclEntry[] getAcls(Object domainInstance) { public AclEntry[] getAcls(Object domainInstance) {
if (domainInstance == null) { Assert.notNull(domainInstance, "domainInstance is null - violating interface contract");
throw new IllegalArgumentException(
"domainInstance is null - violating interface contract");
}
Iterator iter = providers.iterator(); Iterator iter = providers.iterator();
@ -80,15 +78,8 @@ public class AclProviderManager implements AclManager, InitializingBean {
public AclEntry[] getAcls(Object domainInstance, public AclEntry[] getAcls(Object domainInstance,
Authentication authentication) { Authentication authentication) {
if (domainInstance == null) { Assert.notNull(domainInstance, "domainInstance is null - violating interface contract");
throw new IllegalArgumentException( Assert.notNull(authentication, "authentication is null - violating interface contract");
"domainInstance is null - violating interface contract");
}
if (authentication == null) {
throw new IllegalArgumentException(
"authentication is null - violating interface contract");
}
Iterator iter = providers.iterator(); Iterator iter = providers.iterator();
@ -157,9 +148,6 @@ public class AclProviderManager implements AclManager, InitializingBean {
} }
private void checkIfValidList(List listToCheck) { private void checkIfValidList(List listToCheck) {
if ((listToCheck == null) || (listToCheck.size() == 0)) { Assert.notEmpty(listToCheck, "A list of AclManagers is required");
throw new IllegalArgumentException(
"A list of AclManagers is required");
}
} }
} }

View File

@ -17,6 +17,7 @@ package net.sf.acegisecurity.acl.basic;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
import java.util.Arrays; import java.util.Arrays;
@ -49,14 +50,9 @@ public abstract class AbstractBasicAclEntry implements BasicAclEntry {
public AbstractBasicAclEntry(Object recipient, public AbstractBasicAclEntry(Object recipient,
AclObjectIdentity aclObjectIdentity, AclObjectIdentity aclObjectIdentity,
AclObjectIdentity aclObjectParentIdentity, int mask) { AclObjectIdentity aclObjectParentIdentity, int mask) {
if (recipient == null) { Assert.notNull(recipient, "recipient cannot be null");
throw new IllegalArgumentException("recipient cannot be null");
}
if (aclObjectIdentity == null) { Assert.notNull(aclObjectIdentity, "aclObjectIdentity cannot be null");
throw new IllegalArgumentException(
"aclObjectIdentity cannot be null");
}
validPermissions = getValidPermissions(); validPermissions = getValidPermissions();
Arrays.sort(validPermissions); Arrays.sort(validPermissions);

View File

@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -103,10 +104,7 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
AclObjectIdentity aclIdentity = obtainIdentity(domainInstance); AclObjectIdentity aclIdentity = obtainIdentity(domainInstance);
if (aclIdentity == null) { Assert.notNull(aclIdentity, "domainInstance is not supported by this provider");
throw new IllegalArgumentException(
"domainInstance is not supported by this provider");
}
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Looking up: " + aclIdentity.toString()); logger.debug("Looking up: " + aclIdentity.toString());
@ -172,7 +170,7 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
Collection collection = map.values(); Collection collection = map.values();
return (AclEntry[]) collection.toArray(new AclEntry[] {}); return (AclEntry[]) collection.toArray(new AclEntry[]{});
} }
public AclEntry[] getAcls(Object domainInstance, public AclEntry[] getAcls(Object domainInstance,
@ -254,31 +252,19 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
} }
public void afterPropertiesSet() { public void afterPropertiesSet() {
if (basicAclDao == null) { Assert.notNull(basicAclDao, "basicAclDao required");
throw new IllegalArgumentException("basicAclDao required"); Assert.notNull(basicAclEntryCache, "basicAclEntryCache required");
} Assert.notNull(basicAclEntryCache, "basicAclEntryCache required");
Assert.notNull(effectiveAclsResolver, "effectiveAclsResolver required");
if (basicAclEntryCache == null) { Assert.notNull(defaultAclObjectIdentityClass, "defaultAclObjectIdentityClass required");
throw new IllegalArgumentException("basicAclEntryCache required"); Assert.isTrue(AclObjectIdentity.class.isAssignableFrom(this.defaultAclObjectIdentityClass),
} "defaultAclObjectIdentityClass must implement AclObjectIdentity");
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");
}
try { try {
Constructor constructor = defaultAclObjectIdentityClass Constructor constructor = defaultAclObjectIdentityClass
.getConstructor(new Class[] {Object.class}); .getConstructor(new Class[]{Object.class});
} catch (NoSuchMethodException nsme) { } catch (NoSuchMethodException nsme) {
throw new IllegalArgumentException( throw new IllegalArgumentException("defaultAclObjectIdentityClass must provide a constructor that accepts the domain object instance!");
"defaultAclObjectIdentityClass must provide a constructor that accepts the domain object instance!");
} }
} }

View File

@ -15,6 +15,8 @@
package net.sf.acegisecurity.acl.basic; package net.sf.acegisecurity.acl.basic;
import org.springframework.util.Assert;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -65,9 +67,7 @@ public class NamedEntityObjectIdentity implements AclObjectIdentity {
*/ */
public NamedEntityObjectIdentity(Object object) public NamedEntityObjectIdentity(Object object)
throws IllegalAccessException, InvocationTargetException { throws IllegalAccessException, InvocationTargetException {
if (object == null) { Assert.notNull(object, "object cannot be null");
throw new IllegalArgumentException("object cannot be null");
}
this.classname = object.getClass().getName(); this.classname = object.getClass().getName();

View File

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

View File

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

View File

@ -21,6 +21,7 @@ import net.sf.acegisecurity.BadCredentialsException;
import net.sf.acegisecurity.providers.AuthenticationProvider; import net.sf.acegisecurity.providers.AuthenticationProvider;
import org.springframework.beans.factory.InitializingBean; 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 { public void afterPropertiesSet() throws Exception {
if (key == null) { Assert.notNull(key, "A Key is required and should match that configured for the adapters");
throw new IllegalArgumentException(
"A Key is required and should match that configured for the adapters");
}
} }
public Authentication authenticate(Authentication authentication) public Authentication authenticate(Authentication authentication)

View File

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

View File

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

View File

@ -43,6 +43,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.util.Assert;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -221,52 +222,34 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
} }
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
if (getSecureObjectClass() == null) { Assert.notNull(getSecureObjectClass(), "Subclass must provide a non-null response to getSecureObjectClass()");
throw new IllegalArgumentException(
"Subclass must provide a non-null response to getSecureObjectClass()");
}
if (this.authenticationManager == null) { Assert.notNull(this.authenticationManager, "An AuthenticationManager is required");
throw new IllegalArgumentException(
"An AuthenticationManager is required");
}
if (this.accessDecisionManager == null) { Assert.notNull(this.accessDecisionManager, "An AccessDecisionManager is required");
throw new IllegalArgumentException(
"An AccessDecisionManager is required");
}
if (this.runAsManager == null) { Assert.notNull(this.runAsManager, "A RunAsManager is required");
throw new IllegalArgumentException("A RunAsManager is required");
}
if (this.obtainObjectDefinitionSource() == null) { Assert.notNull(this.obtainObjectDefinitionSource(), "An ObjectDefinitionSource is required");
throw new IllegalArgumentException(
"An ObjectDefinitionSource is required");
}
if (!this.obtainObjectDefinitionSource().supports(getSecureObjectClass())) { if (!this.obtainObjectDefinitionSource().supports(getSecureObjectClass())) {
throw new IllegalArgumentException( throw new IllegalArgumentException("ObjectDefinitionSource does not support secure object class: "
"ObjectDefinitionSource does not support secure object class: "
+ getSecureObjectClass()); + getSecureObjectClass());
} }
if (!this.runAsManager.supports(getSecureObjectClass())) { if (!this.runAsManager.supports(getSecureObjectClass())) {
throw new IllegalArgumentException( throw new IllegalArgumentException("RunAsManager does not support secure object class: "
"RunAsManager does not support secure object class: "
+ getSecureObjectClass()); + getSecureObjectClass());
} }
if (!this.accessDecisionManager.supports(getSecureObjectClass())) { if (!this.accessDecisionManager.supports(getSecureObjectClass())) {
throw new IllegalArgumentException( throw new IllegalArgumentException("AccessDecisionManager does not support secure object class: "
"AccessDecisionManager does not support secure object class: "
+ getSecureObjectClass()); + getSecureObjectClass());
} }
if ((this.afterInvocationManager != null) if ((this.afterInvocationManager != null)
&& !this.afterInvocationManager.supports(getSecureObjectClass())) { && !this.afterInvocationManager.supports(getSecureObjectClass())) {
throw new IllegalArgumentException( throw new IllegalArgumentException("AfterInvocationManager does not support secure object class: "
"AfterInvocationManager does not support secure object class: "
+ getSecureObjectClass()); + getSecureObjectClass());
} }
@ -276,8 +259,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
if (iter == null) { if (iter == null) {
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn( logger.warn("Could not validate configuration attributes as the MethodDefinitionSource did not return a ConfigAttributeDefinition Iterator");
"Could not validate configuration attributes as the MethodDefinitionSource did not return a ConfigAttributeDefinition Iterator");
} }
} else { } else {
Set set = new HashSet(); Set set = new HashSet();
@ -305,8 +287,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
logger.info("Validated configuration attributes"); logger.info("Validated configuration attributes");
} }
} else { } else {
throw new IllegalArgumentException( throw new IllegalArgumentException("Unsupported configuration attributes: "
"Unsupported configuration attributes: "
+ set.toString()); + set.toString());
} }
} }
@ -354,16 +335,10 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
} }
protected InterceptorStatusToken beforeInvocation(Object object) { protected InterceptorStatusToken beforeInvocation(Object object) {
if (object == null) { Assert.notNull(object, "Object was null");
throw new IllegalArgumentException("Object was null"); Assert.isTrue(getSecureObjectClass().isAssignableFrom(object.getClass()), "Security invocation attempted for object " + object
}
if (!getSecureObjectClass().isAssignableFrom(object.getClass())) {
throw new IllegalArgumentException(
"Security invocation attempted for object " + object
+ " but AbstractSecurityInterceptor only configured to support secure objects of type: " + " but AbstractSecurityInterceptor only configured to support secure objects of type: "
+ getSecureObjectClass()); + getSecureObjectClass());
}
ConfigAttributeDefinition attr = this.obtainObjectDefinitionSource() ConfigAttributeDefinition attr = this.obtainObjectDefinitionSource()
.getAttributes(object); .getAttributes(object);
@ -439,8 +414,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
if (runAs == null) { if (runAs == null) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug( logger.debug("RunAsManager did not change Authentication object");
"RunAsManager did not change Authentication object");
} }
return new InterceptorStatusToken(authenticated, false, attr, return new InterceptorStatusToken(authenticated, false, attr,
@ -472,8 +446,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
if (context.getAuthentication() != null) { if (context.getAuthentication() != null) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug( logger.debug("Authentication object detected and tagged as unauthenticated");
"Authentication object detected and tagged as unauthenticated");
} }
Authentication authenticated = context.getAuthentication(); Authentication authenticated = context.getAuthentication();

View File

@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.CodeSignature; import org.aspectj.lang.reflect.CodeSignature;
import org.springframework.util.Assert;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -44,9 +45,7 @@ public abstract class AbstractMethodDefinitionSource
public ConfigAttributeDefinition getAttributes(Object object) public ConfigAttributeDefinition getAttributes(Object object)
throws IllegalArgumentException { throws IllegalArgumentException {
if (object == null) { Assert.notNull(object, "Object cannot be null");
throw new IllegalArgumentException("Object cannot be null");
}
if (object instanceof MethodInvocation) { if (object instanceof MethodInvocation) {
return this.lookupAttributes(((MethodInvocation) object).getMethod()); return this.lookupAttributes(((MethodInvocation) object).getMethod());
@ -72,16 +71,13 @@ public abstract class AbstractMethodDefinitionSource
} }
try { try {
return this.lookupAttributes(targetClazz.getMethod( return this.lookupAttributes(targetClazz.getMethod(targetMethodName, types));
targetMethodName, types));
} catch (NoSuchMethodException nsme) { } catch (NoSuchMethodException nsme) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Could not obtain target method from JoinPoint: " + jp);
"Could not obtain target method from JoinPoint: " + jp);
} }
} }
throw new IllegalArgumentException( throw new IllegalArgumentException("Object must be a MethodInvocation or JoinPoint");
"Object must be a MethodInvocation or JoinPoint");
} }
public boolean supports(Class clazz) { public boolean supports(Class clazz) {

View File

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

View File

@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; 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 { public void afterPropertiesSet() throws Exception {
if (this.casAuthoritiesPopulator == null) { Assert.notNull(this.casAuthoritiesPopulator, "A casAuthoritiesPopulator must be set");
throw new IllegalArgumentException( Assert.notNull(this.ticketValidator, "A ticketValidator must be set");
"A casAuthoritiesPopulator 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");
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");
}
} }
public Authentication authenticate(Authentication authentication) public Authentication authenticate(Authentication authentication)

View File

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

View File

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

View File

@ -21,6 +21,7 @@ import net.sf.acegisecurity.providers.cas.CasAuthoritiesPopulator;
import net.sf.acegisecurity.providers.dao.AuthenticationDao; import net.sf.acegisecurity.providers.dao.AuthenticationDao;
import org.springframework.beans.factory.InitializingBean; 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 { public void afterPropertiesSet() throws Exception {
if (this.authenticationDao == null) { Assert.notNull(this.authenticationDao, "An authenticationDao must be set");
throw new IllegalArgumentException(
"An authenticationDao must be set");
}
} }
} }

View File

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

View File

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

View File

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

View File

@ -19,6 +19,7 @@ import net.sf.acegisecurity.providers.cas.TicketValidator;
import net.sf.acegisecurity.ui.cas.ServiceProperties; import net.sf.acegisecurity.ui.cas.ServiceProperties;
import org.springframework.beans.factory.InitializingBean; 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 { public void afterPropertiesSet() throws Exception {
if ((this.casValidate == null) || "".equals(casValidate)) { Assert.hasLength(casValidate, "A casValidate URL must be set");
throw new IllegalArgumentException("A casValidate URL must be set"); Assert.notNull(serviceProperties, "serviceProperties must be specified");
}
if (serviceProperties == null) {
throw new IllegalArgumentException(
"serviceProperties must be specified");
}
if ((trustStore != null) && (!"".equals(trustStore))) { if ((trustStore != null) && (!"".equals(trustStore))) {
System.setProperty("javax.net.ssl.trustStore", trustStore); System.setProperty("javax.net.ssl.trustStore", trustStore);

View File

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

View File

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

View File

@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataRetrievalFailureException; 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 { public void afterPropertiesSet() throws Exception {
if (cache == null) { Assert.notNull(cache, "cache mandatory");
throw new IllegalArgumentException("cache mandatory");
}
} }
public void putUserInCache(UserDetails user) { public void putUserInCache(UserDetails user) {

View File

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

View File

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

View File

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

View File

@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; 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 { public void afterPropertiesSet() throws Exception {
if (this.remoteAuthenticationManager == null) { Assert.notNull(this.remoteAuthenticationManager, "remoteAuthenticationManager is mandatory");
throw new IllegalArgumentException(
"remoteAuthenticationManager is mandatory");
}
} }
public Authentication authenticate(Authentication authentication) public Authentication authenticate(Authentication authentication)

View File

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

View File

@ -21,6 +21,7 @@ import net.sf.acegisecurity.BadCredentialsException;
import net.sf.acegisecurity.providers.AuthenticationProvider; import net.sf.acegisecurity.providers.AuthenticationProvider;
import org.springframework.beans.factory.InitializingBean; 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 { public void afterPropertiesSet() throws Exception {
if (key == null) { Assert.notNull(key, "A Key is required and should match that configured for the RunAsManagerImpl");
throw new IllegalArgumentException(
"A Key is required and should match that configured for the RunAsManagerImpl");
}
} }
public Authentication authenticate(Authentication authentication) public Authentication authenticate(Authentication authentication)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,6 +18,7 @@ package sample.contact;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.Assert;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -44,86 +45,47 @@ public class DataSourcePopulator implements InitializingBean {
} }
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
if (dataSource == null) { Assert.notNull(dataSource, "dataSource required");
throw new IllegalArgumentException("dataSource required");
}
JdbcTemplate template = new JdbcTemplate(dataSource); JdbcTemplate template = new JdbcTemplate(dataSource);
template.execute( template.execute("CREATE TABLE CONTACTS(ID INTEGER NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
"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( template.execute("INSERT INTO contacts VALUES (2, 'Michael Citizen', 'michael@xyz.com');"); // marissa
"INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa template.execute("INSERT INTO contacts VALUES (3, 'Joe Bloggs', 'joe@demo.com');"); // marissa
template.execute( template.execute("INSERT INTO contacts VALUES (4, 'Karen Sutherland', 'karen@sutherland.com');"); // marissa + dianne + scott
"INSERT INTO contacts VALUES (2, 'Michael Citizen', 'michael@xyz.com');"); // marissa template.execute("INSERT INTO contacts VALUES (5, 'Mitchell Howard', 'mitchell@abcdef.com');"); // dianne
template.execute( template.execute("INSERT INTO contacts VALUES (6, 'Rose Costas', 'rose@xyz.com');"); // dianne + scott
"INSERT INTO contacts VALUES (3, 'Joe Bloggs', 'joe@demo.com');"); // marissa template.execute("INSERT INTO contacts VALUES (7, 'Amanda Smith', 'amanda@abcdef.com');"); // scott
template.execute( template.execute("INSERT INTO contacts VALUES (8, 'Cindy Smith', 'cindy@smith.com');"); // dianne + scott
"INSERT INTO contacts VALUES (4, 'Karen Sutherland', 'karen@sutherland.com');"); // marissa + dianne + scott template.execute("INSERT INTO contacts VALUES (9, 'Jonathan Citizen', 'jonathan@xyz.com');"); // scott
template.execute( 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))");
"INSERT INTO contacts VALUES (5, 'Mitchell Howard', 'mitchell@abcdef.com');"); // dianne template.execute("INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
template.execute( template.execute("INSERT INTO acl_object_identity VALUES (2, 'sample.contact.Contact:2', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
"INSERT INTO contacts VALUES (6, 'Rose Costas', 'rose@xyz.com');"); // dianne + scott template.execute("INSERT INTO acl_object_identity VALUES (3, 'sample.contact.Contact:3', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
template.execute( template.execute("INSERT INTO acl_object_identity VALUES (4, 'sample.contact.Contact:4', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
"INSERT INTO contacts VALUES (7, 'Amanda Smith', 'amanda@abcdef.com');"); // scott template.execute("INSERT INTO acl_object_identity VALUES (5, 'sample.contact.Contact:5', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
template.execute( template.execute("INSERT INTO acl_object_identity VALUES (6, 'sample.contact.Contact:6', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
"INSERT INTO contacts VALUES (8, 'Cindy Smith', 'cindy@smith.com');"); // dianne + scott template.execute("INSERT INTO acl_object_identity VALUES (7, 'sample.contact.Contact:7', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
template.execute( template.execute("INSERT INTO acl_object_identity VALUES (8, 'sample.contact.Contact:8', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
"INSERT INTO contacts VALUES (9, 'Jonathan Citizen', 'jonathan@xyz.com');"); // scott template.execute("INSERT INTO acl_object_identity VALUES (9, 'sample.contact.Contact:9', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
template.execute( 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))");
"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_permission VALUES (null, 1, 'marissa', 1);"); // administer
template.execute( template.execute("INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); // read
"INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); template.execute("INSERT INTO acl_permission VALUES (null, 3, 'marissa', 22);"); // read+write+delete
template.execute( template.execute("INSERT INTO acl_permission VALUES (null, 4, 'marissa', 1);"); // administer
"INSERT INTO acl_object_identity VALUES (2, 'sample.contact.Contact:2', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); template.execute("INSERT INTO acl_permission VALUES (null, 4, 'dianne', 1);"); // administer
template.execute( template.execute("INSERT INTO acl_permission VALUES (null, 4, 'scott', 2);"); // read
"INSERT INTO acl_object_identity VALUES (3, 'sample.contact.Contact:3', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); template.execute("INSERT INTO acl_permission VALUES (null, 5, 'dianne', 2);"); // read
template.execute( template.execute("INSERT INTO acl_permission VALUES (null, 6, 'dianne', 22);"); // read+write+delete
"INSERT INTO acl_object_identity VALUES (4, 'sample.contact.Contact:4', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); template.execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 2);"); // read
template.execute( template.execute("INSERT INTO acl_permission VALUES (null, 7, 'scott', 1);"); // administer
"INSERT INTO acl_object_identity VALUES (5, 'sample.contact.Contact:5', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); template.execute("INSERT INTO acl_permission VALUES (null, 8, 'dianne', 2);"); // read
template.execute( template.execute("INSERT INTO acl_permission VALUES (null, 8, 'scott', 2);"); // read
"INSERT INTO acl_object_identity VALUES (6, 'sample.contact.Contact:6', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); template.execute("INSERT INTO acl_permission VALUES (null, 9, 'scott', 22);"); // read+write+delete
template.execute( template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(50) NOT NULL,ENABLED BOOLEAN NOT NULL);");
"INSERT INTO acl_object_identity VALUES (7, 'sample.contact.Contact:7', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');"); 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( template.execute("CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
"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 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) Encoded password for peter is "opal" (but user is disabled)
*/ */
template.execute( template.execute("INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);");
"INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);"); template.execute("INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);");
template.execute( template.execute("INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
"INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);"); template.execute("INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
template.execute( template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_USER');");
"INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);"); template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR');");
template.execute( template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
"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('scott','ROLE_USER');");
template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');"); template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
} }

View File

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

View File

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

View File

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

View File

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