<email>bigbird@cspace.org</email>\r
<phone>1234567890</phone>\r
<userId>bigbird2010</userId>\r
+ <!-- Password is bigbird2010 base 64 encoded -->\r
<password>YmlnYmlyZDIwMTA=</password>\r
<tenants>\r
<tenant_id>1</tenant_id>\r
<email>elmo@cspace.org</email>\r
<phone>1234567890</phone>\r
<userId>elmo2010</userId>\r
+ <!-- Pass word is elmo2010, base64 encoded -->\r
<password>ZWxtbzIwMTA=</password>\r
<tenants>\r
<tenant_id>1</tenant_id>\r
private static final Logger logger = LoggerFactory.getLogger(SecurityUtils.class);
public static final String URI_PATH_SEPARATOR = "/";
+ public static final int MIN_PASSWORD_LENGTH = 8;
+ public static final int MAX_PASSWORD_LENGTH = 24;
/**
* createPasswordHash creates password has using configured digest algorithm
* @param password
*/
public static void validatePassword(String password) {
- //TODO: externalize password length
if (password == null) {
String msg = "Password missing ";
logger.error(msg);
throw new IllegalArgumentException(msg);
}
- if (password.length() < 8 || password.length() > 24) {
- String msg = "Password length should be >8 and <24";
+ if (password.length() < MIN_PASSWORD_LENGTH
+ || password.length() > MAX_PASSWORD_LENGTH) {
+ String msg = "Bad password: '"+password+"': length should be >= "
+ + MIN_PASSWORD_LENGTH + " and <= " + MAX_PASSWORD_LENGTH;
logger.error(msg);
throw new IllegalArgumentException(msg);
}