Move InputValidator.java to usermanagement project

This commit is contained in:
Sofia Baltzi 2018-05-09 13:59:32 +00:00
parent ba73a96e30
commit a3f607bf09
1 changed files with 0 additions and 71 deletions

View File

@ -1,71 +0,0 @@
package eu.dnetlib.openaire.usermanagement.utils;
import org.apache.log4j.Logger;
/**
* Created by sofia on 20/4/2018.
*/
public class InputValidator {
private static Logger logger = Logger.getLogger(eu.dnetlib.openaire.user.utils.InputValidator.class);
/*
^ # start-of-string
(?=.*[0-9]) # a digit must occur at least once
(?=.*[a-z]) # a lower case letter must occur at least once
(?=.*[A-Z]) # an upper case letter must occur at least once
(?=.*[@#$%^&+=]) # a special character must occur at least once. This has been removed.
# Please add if special character is needed.
(?=\S+$) # no whitespace allowed in the entire string
.{6,} # anything, at least six places though
$ # end-of-string
*/
public static String validPassword = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=\\S+$).{6,}$";
/*
^[a-zA-Z0-9] # starts with character or digit
^[a-zA-Z0-9\\.\\_\\-] # contains only characters, numbers, underscores, hyphens, periods
{4,150} # anything, at least eight places though
$ # end-of-string
*/
public static String validUsername = "^[a-zA-Z0-9][a-zA-Z0-9\\.\\_\\-]{4,150}";
/*
^[a-zA-Z0-9] # starts with character or digit
*/
public static String startsWith = "^[a-zA-Z0-9].*";
/*
"^[a-zA-Z0-9\\.\\_\\-]" #contains only characters, numbers, underscores, hyphens, periods
*/
public static String allowedChars = "^[a-zA-Z0-9\\.\\_\\-]";
public static boolean isFilled(String input) {
return (input != null && !input.isEmpty());
}
public static boolean isValidPassword(String password) {
return password.matches(validPassword);
}
public static boolean isValidUsername(String username) {
return username.matches(validUsername);
}
public static boolean startsWithLetterOrDigit(String username) {
return username.matches(startsWith);
}
public static boolean containsOnlyAllowedChars(String username) {
return username.matches(allowedChars);
}
public static boolean containsLessCharsThan(int count, String input) {
return (input.length() < count);
}
public static boolean containsMoreCharsThan(int count, String input) {
return (input.length() > count);
}
}