1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Use message in all Assert

This ensures compatibility with Spring 5.

Fixes gh-4193
This commit is contained in:
Rob Winch
2017-01-30 19:58:24 -06:00
parent 4c79107e01
commit 9c03571bbb
25 changed files with 67 additions and 67 deletions
@@ -132,7 +132,7 @@ final class DefaultServiceAuthenticationDetails extends WebAuthenticationDetails
* @return * @return
*/ */
static Pattern createArtifactPattern(String artifactParameterName) { static Pattern createArtifactPattern(String artifactParameterName) {
Assert.hasLength(artifactParameterName); Assert.hasLength(artifactParameterName, "artifactParameterName is expected to have a length");
return Pattern.compile("&?" + Pattern.quote(artifactParameterName) + "=[^&]*"); return Pattern.compile("&?" + Pattern.quote(artifactParameterName) + "=[^&]*");
} }
@@ -481,7 +481,7 @@ final class AuthenticationConfigBuilder {
SimpleAttributes2GrantedAuthoritiesMapper.class)); SimpleAttributes2GrantedAuthoritiesMapper.class));
String roles = jeeElt.getAttribute(ATT_MAPPABLE_ROLES); String roles = jeeElt.getAttribute(ATT_MAPPABLE_ROLES);
Assert.state(StringUtils.hasText(roles)); Assert.hasLength(roles, "roles is expected to have length");
BeanDefinitionBuilder rolesBuilder = BeanDefinitionBuilder BeanDefinitionBuilder rolesBuilder = BeanDefinitionBuilder
.rootBeanDefinition(StringUtils.class); .rootBeanDefinition(StringUtils.class);
rolesBuilder.addConstructorArgValue(roles); rolesBuilder.addConstructorArgValue(roles);
@@ -163,7 +163,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
} }
public void setPointcutMap(Map<String, List<ConfigAttribute>> map) { public void setPointcutMap(Map<String, List<ConfigAttribute>> map) {
Assert.notEmpty(map); Assert.notEmpty(map, "configAttributes cannot be empty");
for (String expression : map.keySet()) { for (String expression : map.keySet()) {
List<ConfigAttribute> value = map.get(expression); List<ConfigAttribute> value = map.get(expression);
addPointcut(expression, value); addPointcut(expression, value);
@@ -49,7 +49,7 @@ public class SecuredAnnotationSecurityMetadataSource extends
public SecuredAnnotationSecurityMetadataSource( public SecuredAnnotationSecurityMetadataSource(
AnnotationMetadataExtractor annotationMetadataExtractor) { AnnotationMetadataExtractor annotationMetadataExtractor) {
Assert.notNull(annotationMetadataExtractor); Assert.notNull(annotationMetadataExtractor, "annotationMetadataExtractor cannot be null");
annotationExtractor = annotationMetadataExtractor; annotationExtractor = annotationMetadataExtractor;
annotationType = (Class<? extends Annotation>) GenericTypeResolver annotationType = (Class<? extends Annotation>) GenericTypeResolver
.resolveTypeArgument(annotationExtractor.getClass(), .resolveTypeArgument(annotationExtractor.getClass(),
@@ -41,7 +41,7 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider,
private String key; private String key;
public RememberMeAuthenticationProvider(String key) { public RememberMeAuthenticationProvider(String key) {
Assert.hasLength(key); Assert.hasLength(key, "key must have a length");
this.key = key; this.key = key;
} }
@@ -45,7 +45,7 @@ public class InteractiveAuthenticationSuccessEvent extends AbstractAuthenticatio
public InteractiveAuthenticationSuccessEvent(Authentication authentication, public InteractiveAuthenticationSuccessEvent(Authentication authentication,
Class<?> generatedBy) { Class<?> generatedBy) {
super(authentication); super(authentication);
Assert.notNull(generatedBy); Assert.notNull(generatedBy, "generatedBy cannot be null");
this.generatedBy = generatedBy; this.generatedBy = generatedBy;
} }
@@ -76,7 +76,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager {
} }
public void createUser(UserDetails user) { public void createUser(UserDetails user) {
Assert.isTrue(!userExists(user.getUsername())); Assert.isTrue(!userExists(user.getUsername()), "user should not exist");
users.put(user.getUsername().toLowerCase(), new MutableUser(user)); users.put(user.getUsername().toLowerCase(), new MutableUser(user));
} }
@@ -86,7 +86,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager {
} }
public void updateUser(UserDetails user) { public void updateUser(UserDetails user) {
Assert.isTrue(userExists(user.getUsername())); Assert.isTrue(userExists(user.getUsername()), "user should exist");
users.put(user.getUsername().toLowerCase(), new MutableUser(user)); users.put(user.getUsername().toLowerCase(), new MutableUser(user));
} }
@@ -258,15 +258,15 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
} }
public List<String> findUsersInGroup(String groupName) { public List<String> findUsersInGroup(String groupName) {
Assert.hasText(groupName); Assert.hasText(groupName, "groupName should have text");
return getJdbcTemplate().queryForList(findUsersInGroupSql, return getJdbcTemplate().queryForList(findUsersInGroupSql,
new String[] { groupName }, String.class); new String[] { groupName }, String.class);
} }
public void createGroup(final String groupName, public void createGroup(final String groupName,
final List<GrantedAuthority> authorities) { final List<GrantedAuthority> authorities) {
Assert.hasText(groupName); Assert.hasText(groupName, "groupName should have text");
Assert.notNull(authorities); Assert.notNull(authorities, "authorities cannot be null");
logger.debug("Creating new group '" + groupName + "' with authorities " logger.debug("Creating new group '" + groupName + "' with authorities "
+ AuthorityUtils.authorityListToSet(authorities)); + AuthorityUtils.authorityListToSet(authorities));
@@ -289,7 +289,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void deleteGroup(String groupName) { public void deleteGroup(String groupName) {
logger.debug("Deleting group '" + groupName + "'"); logger.debug("Deleting group '" + groupName + "'");
Assert.hasText(groupName); Assert.hasText(groupName, "groupName should have text");
final int id = findGroupId(groupName); final int id = findGroupId(groupName);
PreparedStatementSetter groupIdPSS = new PreparedStatementSetter() { PreparedStatementSetter groupIdPSS = new PreparedStatementSetter() {
@@ -304,16 +304,16 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void renameGroup(String oldName, String newName) { public void renameGroup(String oldName, String newName) {
logger.debug("Changing group name from '" + oldName + "' to '" + newName + "'"); logger.debug("Changing group name from '" + oldName + "' to '" + newName + "'");
Assert.hasText(oldName); Assert.hasText(oldName,"oldName should have text");;
Assert.hasText(newName); Assert.hasText(newName,"newName should have text");;
getJdbcTemplate().update(renameGroupSql, newName, oldName); getJdbcTemplate().update(renameGroupSql, newName, oldName);
} }
public void addUserToGroup(final String username, final String groupName) { public void addUserToGroup(final String username, final String groupName) {
logger.debug("Adding user '" + username + "' to group '" + groupName + "'"); logger.debug("Adding user '" + username + "' to group '" + groupName + "'");
Assert.hasText(username); Assert.hasText(username,"username should have text");;
Assert.hasText(groupName); Assert.hasText(groupName,"groupName should have text");;
final int id = findGroupId(groupName); final int id = findGroupId(groupName);
getJdbcTemplate().update(insertGroupMemberSql, new PreparedStatementSetter() { getJdbcTemplate().update(insertGroupMemberSql, new PreparedStatementSetter() {
@@ -328,8 +328,8 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void removeUserFromGroup(final String username, final String groupName) { public void removeUserFromGroup(final String username, final String groupName) {
logger.debug("Removing user '" + username + "' to group '" + groupName + "'"); logger.debug("Removing user '" + username + "' to group '" + groupName + "'");
Assert.hasText(username); Assert.hasText(username,"username should have text");;
Assert.hasText(groupName); Assert.hasText(groupName,"groupName should have text");;
final int id = findGroupId(groupName); final int id = findGroupId(groupName);
@@ -345,7 +345,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public List<GrantedAuthority> findGroupAuthorities(String groupName) { public List<GrantedAuthority> findGroupAuthorities(String groupName) {
logger.debug("Loading authorities for group '" + groupName + "'"); logger.debug("Loading authorities for group '" + groupName + "'");
Assert.hasText(groupName); Assert.hasText(groupName,"groupName should have text");;
return getJdbcTemplate().query(groupAuthoritiesSql, new String[] { groupName }, return getJdbcTemplate().query(groupAuthoritiesSql, new String[] { groupName },
new RowMapper<GrantedAuthority>() { new RowMapper<GrantedAuthority>() {
@@ -361,8 +361,8 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void removeGroupAuthority(String groupName, final GrantedAuthority authority) { public void removeGroupAuthority(String groupName, final GrantedAuthority authority) {
logger.debug("Removing authority '" + authority + "' from group '" + groupName logger.debug("Removing authority '" + authority + "' from group '" + groupName
+ "'"); + "'");
Assert.hasText(groupName); Assert.hasText(groupName,"groupName should have text");
Assert.notNull(authority); Assert.notNull(authority, "authority cannot be null");
final int id = findGroupId(groupName); final int id = findGroupId(groupName);
@@ -377,8 +377,8 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void addGroupAuthority(final String groupName, final GrantedAuthority authority) { public void addGroupAuthority(final String groupName, final GrantedAuthority authority) {
logger.debug("Adding authority '" + authority + "' to group '" + groupName + "'"); logger.debug("Adding authority '" + authority + "' to group '" + groupName + "'");
Assert.hasText(groupName); Assert.hasText(groupName,"groupName should have text");;
Assert.notNull(authority); Assert.notNull(authority, "authority cannot be null");
final int id = findGroupId(groupName); final int id = findGroupId(groupName);
getJdbcTemplate().update(insertGroupAuthoritySql, new PreparedStatementSetter() { getJdbcTemplate().update(insertGroupAuthoritySql, new PreparedStatementSetter() {
@@ -398,102 +398,102 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
} }
public void setCreateUserSql(String createUserSql) { public void setCreateUserSql(String createUserSql) {
Assert.hasText(createUserSql); Assert.hasText(createUserSql,"createUserSql should have text");;
this.createUserSql = createUserSql; this.createUserSql = createUserSql;
} }
public void setDeleteUserSql(String deleteUserSql) { public void setDeleteUserSql(String deleteUserSql) {
Assert.hasText(deleteUserSql); Assert.hasText(deleteUserSql,"deleteUserSql should have text");;
this.deleteUserSql = deleteUserSql; this.deleteUserSql = deleteUserSql;
} }
public void setUpdateUserSql(String updateUserSql) { public void setUpdateUserSql(String updateUserSql) {
Assert.hasText(updateUserSql); Assert.hasText(updateUserSql,"updateUserSql should have text");;
this.updateUserSql = updateUserSql; this.updateUserSql = updateUserSql;
} }
public void setCreateAuthoritySql(String createAuthoritySql) { public void setCreateAuthoritySql(String createAuthoritySql) {
Assert.hasText(createAuthoritySql); Assert.hasText(createAuthoritySql,"createAuthoritySql should have text");;
this.createAuthoritySql = createAuthoritySql; this.createAuthoritySql = createAuthoritySql;
} }
public void setDeleteUserAuthoritiesSql(String deleteUserAuthoritiesSql) { public void setDeleteUserAuthoritiesSql(String deleteUserAuthoritiesSql) {
Assert.hasText(deleteUserAuthoritiesSql); Assert.hasText(deleteUserAuthoritiesSql,"deleteUserAuthoritiesSql should have text");;
this.deleteUserAuthoritiesSql = deleteUserAuthoritiesSql; this.deleteUserAuthoritiesSql = deleteUserAuthoritiesSql;
} }
public void setUserExistsSql(String userExistsSql) { public void setUserExistsSql(String userExistsSql) {
Assert.hasText(userExistsSql); Assert.hasText(userExistsSql,"userExistsSql should have text");;
this.userExistsSql = userExistsSql; this.userExistsSql = userExistsSql;
} }
public void setChangePasswordSql(String changePasswordSql) { public void setChangePasswordSql(String changePasswordSql) {
Assert.hasText(changePasswordSql); Assert.hasText(changePasswordSql,"changePasswordSql should have text");;
this.changePasswordSql = changePasswordSql; this.changePasswordSql = changePasswordSql;
} }
public void setFindAllGroupsSql(String findAllGroupsSql) { public void setFindAllGroupsSql(String findAllGroupsSql) {
Assert.hasText(findAllGroupsSql); Assert.hasText(findAllGroupsSql,"findAllGroupsSql should have text");;
this.findAllGroupsSql = findAllGroupsSql; this.findAllGroupsSql = findAllGroupsSql;
} }
public void setFindUsersInGroupSql(String findUsersInGroupSql) { public void setFindUsersInGroupSql(String findUsersInGroupSql) {
Assert.hasText(findUsersInGroupSql); Assert.hasText(findUsersInGroupSql,"findUsersInGroupSql should have text");;
this.findUsersInGroupSql = findUsersInGroupSql; this.findUsersInGroupSql = findUsersInGroupSql;
} }
public void setInsertGroupSql(String insertGroupSql) { public void setInsertGroupSql(String insertGroupSql) {
Assert.hasText(insertGroupSql); Assert.hasText(insertGroupSql,"insertGroupSql should have text");;
this.insertGroupSql = insertGroupSql; this.insertGroupSql = insertGroupSql;
} }
public void setFindGroupIdSql(String findGroupIdSql) { public void setFindGroupIdSql(String findGroupIdSql) {
Assert.hasText(findGroupIdSql); Assert.hasText(findGroupIdSql,"findGroupIdSql should have text");;
this.findGroupIdSql = findGroupIdSql; this.findGroupIdSql = findGroupIdSql;
} }
public void setInsertGroupAuthoritySql(String insertGroupAuthoritySql) { public void setInsertGroupAuthoritySql(String insertGroupAuthoritySql) {
Assert.hasText(insertGroupAuthoritySql); Assert.hasText(insertGroupAuthoritySql,"insertGroupAuthoritySql should have text");;
this.insertGroupAuthoritySql = insertGroupAuthoritySql; this.insertGroupAuthoritySql = insertGroupAuthoritySql;
} }
public void setDeleteGroupSql(String deleteGroupSql) { public void setDeleteGroupSql(String deleteGroupSql) {
Assert.hasText(deleteGroupSql); Assert.hasText(deleteGroupSql,"deleteGroupSql should have text");;
this.deleteGroupSql = deleteGroupSql; this.deleteGroupSql = deleteGroupSql;
} }
public void setDeleteGroupAuthoritiesSql(String deleteGroupAuthoritiesSql) { public void setDeleteGroupAuthoritiesSql(String deleteGroupAuthoritiesSql) {
Assert.hasText(deleteGroupAuthoritiesSql); Assert.hasText(deleteGroupAuthoritiesSql,"deleteGroupAuthoritiesSql should have text");;
this.deleteGroupAuthoritiesSql = deleteGroupAuthoritiesSql; this.deleteGroupAuthoritiesSql = deleteGroupAuthoritiesSql;
} }
public void setDeleteGroupMembersSql(String deleteGroupMembersSql) { public void setDeleteGroupMembersSql(String deleteGroupMembersSql) {
Assert.hasText(deleteGroupMembersSql); Assert.hasText(deleteGroupMembersSql,"deleteGroupMembersSql should have text");;
this.deleteGroupMembersSql = deleteGroupMembersSql; this.deleteGroupMembersSql = deleteGroupMembersSql;
} }
public void setRenameGroupSql(String renameGroupSql) { public void setRenameGroupSql(String renameGroupSql) {
Assert.hasText(renameGroupSql); Assert.hasText(renameGroupSql,"renameGroupSql should have text");;
this.renameGroupSql = renameGroupSql; this.renameGroupSql = renameGroupSql;
} }
public void setInsertGroupMemberSql(String insertGroupMemberSql) { public void setInsertGroupMemberSql(String insertGroupMemberSql) {
Assert.hasText(insertGroupMemberSql); Assert.hasText(insertGroupMemberSql,"insertGroupMemberSql should have text");;
this.insertGroupMemberSql = insertGroupMemberSql; this.insertGroupMemberSql = insertGroupMemberSql;
} }
public void setDeleteGroupMemberSql(String deleteGroupMemberSql) { public void setDeleteGroupMemberSql(String deleteGroupMemberSql) {
Assert.hasText(deleteGroupMemberSql); Assert.hasText(deleteGroupMemberSql,"deleteGroupMemberSql should have text");;
this.deleteGroupMemberSql = deleteGroupMemberSql; this.deleteGroupMemberSql = deleteGroupMemberSql;
} }
public void setGroupAuthoritiesSql(String groupAuthoritiesSql) { public void setGroupAuthoritiesSql(String groupAuthoritiesSql) {
Assert.hasText(groupAuthoritiesSql); Assert.hasText(groupAuthoritiesSql,"groupAuthoritiesSql should have text");;
this.groupAuthoritiesSql = groupAuthoritiesSql; this.groupAuthoritiesSql = groupAuthoritiesSql;
} }
public void setDeleteGroupAuthoritySql(String deleteGroupAuthoritySql) { public void setDeleteGroupAuthoritySql(String deleteGroupAuthoritySql) {
Assert.hasText(deleteGroupAuthoritySql); Assert.hasText(deleteGroupAuthoritySql,"deleteGroupAuthoritySql should have text");;
this.deleteGroupAuthoritySql = deleteGroupAuthoritySql; this.deleteGroupAuthoritySql = deleteGroupAuthoritySql;
} }
@@ -52,7 +52,7 @@ public class InMemoryResource extends AbstractResource {
} }
public InMemoryResource(byte[] source, String description) { public InMemoryResource(byte[] source, String description) {
Assert.notNull(source); Assert.notNull(source, "source cannot be null");
this.source = source; this.source = source;
this.description = description; this.description = description;
} }
@@ -157,7 +157,7 @@ public final class LdapUtils {
* @return the root DN * @return the root DN
*/ */
public static String parseRootDnFromUrl(String url) { public static String parseRootDnFromUrl(String url) {
Assert.hasLength(url); Assert.hasLength(url, "url must have length");
String urlRootDn; String urlRootDn;
@@ -187,7 +187,7 @@ public final class LdapUtils {
*/ */
private static URI parseLdapUrl(String url) { private static URI parseLdapUrl(String url) {
Assert.hasLength(url); Assert.hasLength(url, "url must have length");
try { try {
return new URI(url); return new URI(url);
@@ -119,7 +119,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator,
} }
public void setMessageSource(MessageSource messageSource) { public void setMessageSource(MessageSource messageSource) {
Assert.notNull("Message source must not be null"); Assert.notNull(messageSource, "Message source must not be null");
this.messages = new MessageSourceAccessor(messageSource); this.messages = new MessageSourceAccessor(messageSource);
} }
@@ -159,7 +159,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
} }
public void setWorkingDirectory(File workingDir) { public void setWorkingDirectory(File workingDir) {
Assert.notNull(workingDir); Assert.notNull(workingDir, "workingDir cannot be null");
logger.info("Setting working directory for LDAP_PROVIDER: " logger.info("Setting working directory for LDAP_PROVIDER: "
+ workingDir.getAbsolutePath()); + workingDir.getAbsolutePath());
@@ -239,7 +239,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
catch (LdapNameNotFoundException e) { catch (LdapNameNotFoundException e) {
try { try {
LdapDN dn = new LdapDN(root); LdapDN dn = new LdapDN(root);
Assert.isTrue(root.startsWith("dc=")); Assert.isTrue(root.startsWith("dc="), "root must start with dc=");
String dc = root.substring(3, root.indexOf(',')); String dc = root.substring(3, root.indexOf(','));
ServerEntry entry = service.newEntry(dn); ServerEntry entry = service.newEntry(dn);
entry.add("objectClass", "top", "domain", "extensibleObject"); entry.add("objectClass", "top", "domain", "extensibleObject");
@@ -387,7 +387,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
} }
public void setAttributesToRetrieve(String[] attributesToRetrieve) { public void setAttributesToRetrieve(String[] attributesToRetrieve) {
Assert.notNull(attributesToRetrieve); Assert.notNull(attributesToRetrieve, "attributesToRetrieve cannot be null");
this.attributesToRetrieve = attributesToRetrieve; this.attributesToRetrieve = attributesToRetrieve;
} }
@@ -406,7 +406,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
* members. * members.
*/ */
public void setGroupMemberAttributeName(String groupMemberAttributeName) { public void setGroupMemberAttributeName(String groupMemberAttributeName) {
Assert.hasText(groupMemberAttributeName); Assert.hasText(groupMemberAttributeName, "groupMemberAttributeName should have text");
this.groupMemberAttributeName = groupMemberAttributeName; this.groupMemberAttributeName = groupMemberAttributeName;
this.groupSearchFilter = "(" + groupMemberAttributeName + "={0})"; this.groupSearchFilter = "(" + groupMemberAttributeName + "={0})";
} }
@@ -139,8 +139,8 @@ public class Person extends LdapUserDetailsImpl {
public LdapUserDetails createUserDetails() { public LdapUserDetails createUserDetails() {
Person p = (Person) super.createUserDetails(); Person p = (Person) super.createUserDetails();
Assert.notNull(p.cn); Assert.notNull(p.cn, "person.sn cannot be null");
Assert.notEmpty(p.cn); Assert.notEmpty(p.cn, "person.cn cannot be empty");
// TODO: Check contents for null entries // TODO: Check contents for null entries
return p; return p;
} }
@@ -45,7 +45,7 @@ public class OpenIDAttribute implements Serializable {
} }
public OpenIDAttribute(String name, String type, List<String> values) { public OpenIDAttribute(String name, String type, List<String> values) {
Assert.notEmpty(values); Assert.notEmpty(values, "values cannot be empty");
this.name = name; this.name = name;
this.typeIdentifier = type; this.typeIdentifier = type;
this.values = values; this.values = values;
@@ -39,7 +39,7 @@ public class InMemoryUserRegistry implements UserRegistry {
public void registerUser(GaeUser newUser) { public void registerUser(GaeUser newUser) {
logger.debug("Attempting to create new user " + newUser); logger.debug("Attempting to create new user " + newUser);
Assert.state(!users.containsKey(newUser.getUserId())); Assert.isTrue(!users.containsKey(newUser.getUserId()), "user should not exist");
users.put(newUser.getUserId(), newUser); users.put(newUser.getUserId(), newUser);
} }
@@ -21,7 +21,7 @@ public class BankServiceImpl implements BankService {
private final BankDao bankDao; private final BankDao bankDao;
public BankServiceImpl(BankDao bankDao) { public BankServiceImpl(BankDao bankDao) {
Assert.notNull(bankDao); Assert.notNull(bankDao, "bankDao cannot be null");
this.bankDao = bankDao; this.bankDao = bankDao;
} }
@@ -30,7 +30,7 @@ public class BankServiceImpl implements BankService {
} }
public Account post(Account account, double amount) { public Account post(Account account, double amount) {
Assert.notNull(account); Assert.notNull(account, "account cannot be null");
// We read account back from DAO so it reflects the latest balance // We read account back from DAO so it reflects the latest balance
Account a = bankDao.readAccount(account.getId()); Account a = bankDao.readAccount(account.getId());
@@ -22,7 +22,7 @@ public class SeedData implements InitializingBean {
private BankDao bankDao; private BankDao bankDao;
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
Assert.notNull(bankDao); Assert.notNull(bankDao, "bankDao cannot be null");
bankDao.createOrUpdateAccount(new Account("rod")); bankDao.createOrUpdateAccount(new Account("rod"));
bankDao.createOrUpdateAccount(new Account("dianne")); bankDao.createOrUpdateAccount(new Account("dianne"));
bankDao.createOrUpdateAccount(new Account("scott")); bankDao.createOrUpdateAccount(new Account("scott"));
@@ -29,7 +29,7 @@ public class ListAccounts implements Controller {
private final BankService bankService; private final BankService bankService;
public ListAccounts(BankService bankService) { public ListAccounts(BankService bankService) {
Assert.notNull(bankService); Assert.notNull(bankService, "bankService cannot be null");
this.bankService = bankService; this.bankService = bankService;
} }
@@ -31,7 +31,7 @@ public class PostAccounts implements Controller {
private final BankService bankService; private final BankService bankService;
public PostAccounts(BankService bankService) { public PostAccounts(BankService bankService) {
Assert.notNull(bankService); Assert.notNull(bankService, "bankService cannot be null");
this.bankService = bankService; this.bankService = bankService;
} }
@@ -286,7 +286,7 @@ public final class SecurityMockMvcRequestPostProcessors {
private final X509Certificate[] certificates; private final X509Certificate[] certificates;
private X509RequestPostProcessor(X509Certificate... certificates) { private X509RequestPostProcessor(X509Certificate... certificates) {
Assert.notNull("X509Certificate cannot be null"); Assert.notNull(certificates, "X509Certificate cannot be null");
this.certificates = certificates; this.certificates = certificates;
} }
@@ -84,7 +84,7 @@ public class AnonymousAuthenticationFilter extends GenericFilterBean implements
@Override @Override
public void afterPropertiesSet() { public void afterPropertiesSet() {
Assert.hasLength(key); Assert.hasLength(key, "key must have length");
Assert.notNull(principal, "Anonymous authentication principal must be set"); Assert.notNull(principal, "Anonymous authentication principal must be set");
Assert.notNull(authorities, "Anonymous authorities must be set"); Assert.notNull(authorities, "Anonymous authorities must be set");
} }
@@ -54,7 +54,7 @@ public class PreAuthenticatedGrantedAuthoritiesUserDetailsService implements
*/ */
public final UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) public final UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token)
throws AuthenticationException { throws AuthenticationException {
Assert.notNull(token.getDetails()); Assert.notNull(token.getDetails(), "token.getDetails() cannot be null");
Assert.isInstanceOf(GrantedAuthoritiesContainer.class, token.getDetails()); Assert.isInstanceOf(GrantedAuthoritiesContainer.class, token.getDetails());
Collection<? extends GrantedAuthority> authorities = ((GrantedAuthoritiesContainer) token Collection<? extends GrantedAuthority> authorities = ((GrantedAuthoritiesContainer) token
.getDetails()).getGrantedAuthorities(); .getDetails()).getGrantedAuthorities();
@@ -48,8 +48,8 @@ public class SessionFixationProtectionEvent extends AbstractAuthenticationEvent
public SessionFixationProtectionEvent(Authentication authentication, public SessionFixationProtectionEvent(Authentication authentication,
String oldSessionId, String newSessionId) { String oldSessionId, String newSessionId) {
super(authentication); super(authentication);
Assert.hasLength(oldSessionId); Assert.hasLength(oldSessionId, "oldSessionId must have length");
Assert.hasLength(newSessionId); Assert.hasLength(newSessionId, "newSessionId must have length");
this.oldSessionId = oldSessionId; this.oldSessionId = oldSessionId;
this.newSessionId = newSessionId; this.newSessionId = newSessionId;
} }
@@ -68,8 +68,8 @@ public class RedirectUrlBuilder {
public String getUrl() { public String getUrl() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Assert.notNull(scheme); Assert.notNull(scheme, "scheme cannot be null");
Assert.notNull(serverName); Assert.notNull(serverName, "serverName cannot be null");
sb.append(scheme).append("://").append(serverName); sb.append(scheme).append("://").append(serverName);