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

View File

@ -132,7 +132,7 @@ final class DefaultServiceAuthenticationDetails extends WebAuthenticationDetails
* @return
*/
static Pattern createArtifactPattern(String artifactParameterName) {
Assert.hasLength(artifactParameterName);
Assert.hasLength(artifactParameterName, "artifactParameterName is expected to have a length");
return Pattern.compile("&?" + Pattern.quote(artifactParameterName) + "=[^&]*");
}

View File

@ -481,7 +481,7 @@ final class AuthenticationConfigBuilder {
SimpleAttributes2GrantedAuthoritiesMapper.class));
String roles = jeeElt.getAttribute(ATT_MAPPABLE_ROLES);
Assert.state(StringUtils.hasText(roles));
Assert.hasLength(roles, "roles is expected to have length");
BeanDefinitionBuilder rolesBuilder = BeanDefinitionBuilder
.rootBeanDefinition(StringUtils.class);
rolesBuilder.addConstructorArgValue(roles);

View File

@ -163,7 +163,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
}
public void setPointcutMap(Map<String, List<ConfigAttribute>> map) {
Assert.notEmpty(map);
Assert.notEmpty(map, "configAttributes cannot be empty");
for (String expression : map.keySet()) {
List<ConfigAttribute> value = map.get(expression);
addPointcut(expression, value);

View File

@ -49,7 +49,7 @@ public class SecuredAnnotationSecurityMetadataSource extends
public SecuredAnnotationSecurityMetadataSource(
AnnotationMetadataExtractor annotationMetadataExtractor) {
Assert.notNull(annotationMetadataExtractor);
Assert.notNull(annotationMetadataExtractor, "annotationMetadataExtractor cannot be null");
annotationExtractor = annotationMetadataExtractor;
annotationType = (Class<? extends Annotation>) GenericTypeResolver
.resolveTypeArgument(annotationExtractor.getClass(),

View File

@ -41,7 +41,7 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider,
private String key;
public RememberMeAuthenticationProvider(String key) {
Assert.hasLength(key);
Assert.hasLength(key, "key must have a length");
this.key = key;
}

View File

@ -45,7 +45,7 @@ public class InteractiveAuthenticationSuccessEvent extends AbstractAuthenticatio
public InteractiveAuthenticationSuccessEvent(Authentication authentication,
Class<?> generatedBy) {
super(authentication);
Assert.notNull(generatedBy);
Assert.notNull(generatedBy, "generatedBy cannot be null");
this.generatedBy = generatedBy;
}

View File

@ -76,7 +76,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager {
}
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));
}
@ -86,7 +86,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager {
}
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));
}

View File

@ -258,15 +258,15 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
}
public List<String> findUsersInGroup(String groupName) {
Assert.hasText(groupName);
Assert.hasText(groupName, "groupName should have text");
return getJdbcTemplate().queryForList(findUsersInGroupSql,
new String[] { groupName }, String.class);
}
public void createGroup(final String groupName,
final List<GrantedAuthority> authorities) {
Assert.hasText(groupName);
Assert.notNull(authorities);
Assert.hasText(groupName, "groupName should have text");
Assert.notNull(authorities, "authorities cannot be null");
logger.debug("Creating new group '" + groupName + "' with authorities "
+ AuthorityUtils.authorityListToSet(authorities));
@ -289,7 +289,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void deleteGroup(String groupName) {
logger.debug("Deleting group '" + groupName + "'");
Assert.hasText(groupName);
Assert.hasText(groupName, "groupName should have text");
final int id = findGroupId(groupName);
PreparedStatementSetter groupIdPSS = new PreparedStatementSetter() {
@ -304,16 +304,16 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void renameGroup(String oldName, String newName) {
logger.debug("Changing group name from '" + oldName + "' to '" + newName + "'");
Assert.hasText(oldName);
Assert.hasText(newName);
Assert.hasText(oldName,"oldName should have text");;
Assert.hasText(newName,"newName should have text");;
getJdbcTemplate().update(renameGroupSql, newName, oldName);
}
public void addUserToGroup(final String username, final String groupName) {
logger.debug("Adding user '" + username + "' to group '" + groupName + "'");
Assert.hasText(username);
Assert.hasText(groupName);
Assert.hasText(username,"username should have text");;
Assert.hasText(groupName,"groupName should have text");;
final int id = findGroupId(groupName);
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) {
logger.debug("Removing user '" + username + "' to group '" + groupName + "'");
Assert.hasText(username);
Assert.hasText(groupName);
Assert.hasText(username,"username should have text");;
Assert.hasText(groupName,"groupName should have text");;
final int id = findGroupId(groupName);
@ -345,7 +345,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public List<GrantedAuthority> findGroupAuthorities(String 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 },
new RowMapper<GrantedAuthority>() {
@ -361,8 +361,8 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
public void removeGroupAuthority(String groupName, final GrantedAuthority authority) {
logger.debug("Removing authority '" + authority + "' from group '" + groupName
+ "'");
Assert.hasText(groupName);
Assert.notNull(authority);
Assert.hasText(groupName,"groupName should have text");
Assert.notNull(authority, "authority cannot be null");
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) {
logger.debug("Adding authority '" + authority + "' to group '" + groupName + "'");
Assert.hasText(groupName);
Assert.notNull(authority);
Assert.hasText(groupName,"groupName should have text");;
Assert.notNull(authority, "authority cannot be null");
final int id = findGroupId(groupName);
getJdbcTemplate().update(insertGroupAuthoritySql, new PreparedStatementSetter() {
@ -398,102 +398,102 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
}
public void setCreateUserSql(String createUserSql) {
Assert.hasText(createUserSql);
Assert.hasText(createUserSql,"createUserSql should have text");;
this.createUserSql = createUserSql;
}
public void setDeleteUserSql(String deleteUserSql) {
Assert.hasText(deleteUserSql);
Assert.hasText(deleteUserSql,"deleteUserSql should have text");;
this.deleteUserSql = deleteUserSql;
}
public void setUpdateUserSql(String updateUserSql) {
Assert.hasText(updateUserSql);
Assert.hasText(updateUserSql,"updateUserSql should have text");;
this.updateUserSql = updateUserSql;
}
public void setCreateAuthoritySql(String createAuthoritySql) {
Assert.hasText(createAuthoritySql);
Assert.hasText(createAuthoritySql,"createAuthoritySql should have text");;
this.createAuthoritySql = createAuthoritySql;
}
public void setDeleteUserAuthoritiesSql(String deleteUserAuthoritiesSql) {
Assert.hasText(deleteUserAuthoritiesSql);
Assert.hasText(deleteUserAuthoritiesSql,"deleteUserAuthoritiesSql should have text");;
this.deleteUserAuthoritiesSql = deleteUserAuthoritiesSql;
}
public void setUserExistsSql(String userExistsSql) {
Assert.hasText(userExistsSql);
Assert.hasText(userExistsSql,"userExistsSql should have text");;
this.userExistsSql = userExistsSql;
}
public void setChangePasswordSql(String changePasswordSql) {
Assert.hasText(changePasswordSql);
Assert.hasText(changePasswordSql,"changePasswordSql should have text");;
this.changePasswordSql = changePasswordSql;
}
public void setFindAllGroupsSql(String findAllGroupsSql) {
Assert.hasText(findAllGroupsSql);
Assert.hasText(findAllGroupsSql,"findAllGroupsSql should have text");;
this.findAllGroupsSql = findAllGroupsSql;
}
public void setFindUsersInGroupSql(String findUsersInGroupSql) {
Assert.hasText(findUsersInGroupSql);
Assert.hasText(findUsersInGroupSql,"findUsersInGroupSql should have text");;
this.findUsersInGroupSql = findUsersInGroupSql;
}
public void setInsertGroupSql(String insertGroupSql) {
Assert.hasText(insertGroupSql);
Assert.hasText(insertGroupSql,"insertGroupSql should have text");;
this.insertGroupSql = insertGroupSql;
}
public void setFindGroupIdSql(String findGroupIdSql) {
Assert.hasText(findGroupIdSql);
Assert.hasText(findGroupIdSql,"findGroupIdSql should have text");;
this.findGroupIdSql = findGroupIdSql;
}
public void setInsertGroupAuthoritySql(String insertGroupAuthoritySql) {
Assert.hasText(insertGroupAuthoritySql);
Assert.hasText(insertGroupAuthoritySql,"insertGroupAuthoritySql should have text");;
this.insertGroupAuthoritySql = insertGroupAuthoritySql;
}
public void setDeleteGroupSql(String deleteGroupSql) {
Assert.hasText(deleteGroupSql);
Assert.hasText(deleteGroupSql,"deleteGroupSql should have text");;
this.deleteGroupSql = deleteGroupSql;
}
public void setDeleteGroupAuthoritiesSql(String deleteGroupAuthoritiesSql) {
Assert.hasText(deleteGroupAuthoritiesSql);
Assert.hasText(deleteGroupAuthoritiesSql,"deleteGroupAuthoritiesSql should have text");;
this.deleteGroupAuthoritiesSql = deleteGroupAuthoritiesSql;
}
public void setDeleteGroupMembersSql(String deleteGroupMembersSql) {
Assert.hasText(deleteGroupMembersSql);
Assert.hasText(deleteGroupMembersSql,"deleteGroupMembersSql should have text");;
this.deleteGroupMembersSql = deleteGroupMembersSql;
}
public void setRenameGroupSql(String renameGroupSql) {
Assert.hasText(renameGroupSql);
Assert.hasText(renameGroupSql,"renameGroupSql should have text");;
this.renameGroupSql = renameGroupSql;
}
public void setInsertGroupMemberSql(String insertGroupMemberSql) {
Assert.hasText(insertGroupMemberSql);
Assert.hasText(insertGroupMemberSql,"insertGroupMemberSql should have text");;
this.insertGroupMemberSql = insertGroupMemberSql;
}
public void setDeleteGroupMemberSql(String deleteGroupMemberSql) {
Assert.hasText(deleteGroupMemberSql);
Assert.hasText(deleteGroupMemberSql,"deleteGroupMemberSql should have text");;
this.deleteGroupMemberSql = deleteGroupMemberSql;
}
public void setGroupAuthoritiesSql(String groupAuthoritiesSql) {
Assert.hasText(groupAuthoritiesSql);
Assert.hasText(groupAuthoritiesSql,"groupAuthoritiesSql should have text");;
this.groupAuthoritiesSql = groupAuthoritiesSql;
}
public void setDeleteGroupAuthoritySql(String deleteGroupAuthoritySql) {
Assert.hasText(deleteGroupAuthoritySql);
Assert.hasText(deleteGroupAuthoritySql,"deleteGroupAuthoritySql should have text");;
this.deleteGroupAuthoritySql = deleteGroupAuthoritySql;
}

View File

@ -52,7 +52,7 @@ public class InMemoryResource extends AbstractResource {
}
public InMemoryResource(byte[] source, String description) {
Assert.notNull(source);
Assert.notNull(source, "source cannot be null");
this.source = source;
this.description = description;
}

View File

@ -157,7 +157,7 @@ public final class LdapUtils {
* @return the root DN
*/
public static String parseRootDnFromUrl(String url) {
Assert.hasLength(url);
Assert.hasLength(url, "url must have length");
String urlRootDn;
@ -187,7 +187,7 @@ public final class LdapUtils {
*/
private static URI parseLdapUrl(String url) {
Assert.hasLength(url);
Assert.hasLength(url, "url must have length");
try {
return new URI(url);

View File

@ -119,7 +119,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator,
}
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);
}

View File

@ -159,7 +159,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
}
public void setWorkingDirectory(File workingDir) {
Assert.notNull(workingDir);
Assert.notNull(workingDir, "workingDir cannot be null");
logger.info("Setting working directory for LDAP_PROVIDER: "
+ workingDir.getAbsolutePath());
@ -239,7 +239,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
catch (LdapNameNotFoundException e) {
try {
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(','));
ServerEntry entry = service.newEntry(dn);
entry.add("objectClass", "top", "domain", "extensibleObject");

View File

@ -387,7 +387,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
}
public void setAttributesToRetrieve(String[] attributesToRetrieve) {
Assert.notNull(attributesToRetrieve);
Assert.notNull(attributesToRetrieve, "attributesToRetrieve cannot be null");
this.attributesToRetrieve = attributesToRetrieve;
}
@ -406,7 +406,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
* members.
*/
public void setGroupMemberAttributeName(String groupMemberAttributeName) {
Assert.hasText(groupMemberAttributeName);
Assert.hasText(groupMemberAttributeName, "groupMemberAttributeName should have text");
this.groupMemberAttributeName = groupMemberAttributeName;
this.groupSearchFilter = "(" + groupMemberAttributeName + "={0})";
}

View File

@ -139,8 +139,8 @@ public class Person extends LdapUserDetailsImpl {
public LdapUserDetails createUserDetails() {
Person p = (Person) super.createUserDetails();
Assert.notNull(p.cn);
Assert.notEmpty(p.cn);
Assert.notNull(p.cn, "person.sn cannot be null");
Assert.notEmpty(p.cn, "person.cn cannot be empty");
// TODO: Check contents for null entries
return p;
}

View File

@ -45,7 +45,7 @@ public class OpenIDAttribute implements Serializable {
}
public OpenIDAttribute(String name, String type, List<String> values) {
Assert.notEmpty(values);
Assert.notEmpty(values, "values cannot be empty");
this.name = name;
this.typeIdentifier = type;
this.values = values;

View File

@ -39,7 +39,7 @@ public class InMemoryUserRegistry implements UserRegistry {
public void registerUser(GaeUser 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);
}

View File

@ -21,7 +21,7 @@ public class BankServiceImpl implements BankService {
private final BankDao bankDao;
public BankServiceImpl(BankDao bankDao) {
Assert.notNull(bankDao);
Assert.notNull(bankDao, "bankDao cannot be null");
this.bankDao = bankDao;
}
@ -30,7 +30,7 @@ public class BankServiceImpl implements BankService {
}
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
Account a = bankDao.readAccount(account.getId());

View File

@ -22,7 +22,7 @@ public class SeedData implements InitializingBean {
private BankDao bankDao;
public void afterPropertiesSet() throws Exception {
Assert.notNull(bankDao);
Assert.notNull(bankDao, "bankDao cannot be null");
bankDao.createOrUpdateAccount(new Account("rod"));
bankDao.createOrUpdateAccount(new Account("dianne"));
bankDao.createOrUpdateAccount(new Account("scott"));

View File

@ -29,7 +29,7 @@ public class ListAccounts implements Controller {
private final BankService bankService;
public ListAccounts(BankService bankService) {
Assert.notNull(bankService);
Assert.notNull(bankService, "bankService cannot be null");
this.bankService = bankService;
}

View File

@ -31,7 +31,7 @@ public class PostAccounts implements Controller {
private final BankService bankService;
public PostAccounts(BankService bankService) {
Assert.notNull(bankService);
Assert.notNull(bankService, "bankService cannot be null");
this.bankService = bankService;
}

View File

@ -286,7 +286,7 @@ public final class SecurityMockMvcRequestPostProcessors {
private final X509Certificate[] certificates;
private X509RequestPostProcessor(X509Certificate... certificates) {
Assert.notNull("X509Certificate cannot be null");
Assert.notNull(certificates, "X509Certificate cannot be null");
this.certificates = certificates;
}

View File

@ -84,7 +84,7 @@ public class AnonymousAuthenticationFilter extends GenericFilterBean implements
@Override
public void afterPropertiesSet() {
Assert.hasLength(key);
Assert.hasLength(key, "key must have length");
Assert.notNull(principal, "Anonymous authentication principal must be set");
Assert.notNull(authorities, "Anonymous authorities must be set");
}

View File

@ -54,7 +54,7 @@ public class PreAuthenticatedGrantedAuthoritiesUserDetailsService implements
*/
public final UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token)
throws AuthenticationException {
Assert.notNull(token.getDetails());
Assert.notNull(token.getDetails(), "token.getDetails() cannot be null");
Assert.isInstanceOf(GrantedAuthoritiesContainer.class, token.getDetails());
Collection<? extends GrantedAuthority> authorities = ((GrantedAuthoritiesContainer) token
.getDetails()).getGrantedAuthorities();

View File

@ -48,8 +48,8 @@ public class SessionFixationProtectionEvent extends AbstractAuthenticationEvent
public SessionFixationProtectionEvent(Authentication authentication,
String oldSessionId, String newSessionId) {
super(authentication);
Assert.hasLength(oldSessionId);
Assert.hasLength(newSessionId);
Assert.hasLength(oldSessionId, "oldSessionId must have length");
Assert.hasLength(newSessionId, "newSessionId must have length");
this.oldSessionId = oldSessionId;
this.newSessionId = newSessionId;
}

View File

@ -68,8 +68,8 @@ public class RedirectUrlBuilder {
public String getUrl() {
StringBuilder sb = new StringBuilder();
Assert.notNull(scheme);
Assert.notNull(serverName);
Assert.notNull(scheme, "scheme cannot be null");
Assert.notNull(serverName, "serverName cannot be null");
sb.append(scheme).append("://").append(serverName);