package net.mindoverflow.webmarker.utils.security; public class SafetyCheck { public static boolean isSafeUsername(String username) { // todo: allow configuration if(!username.matches("[a-zA-Z0-9]*")) return false; if(username.length() > 15) return false; if(username.length() < 3) return false; if(username.equalsIgnoreCase("null")) return false; return true; } public static boolean isSafePassword(String password) { if(password.length() < 6) return false; if(password.getBytes().length > 71) return false; // see https://github.com/patrickfav/bcrypt#handling-for-overlong-passwords // todo: more password security return true; } public static boolean isValidEncoding(String encoding) { if(encoding.equalsIgnoreCase("base64")) return true; if(encoding.equalsIgnoreCase("plaintext")) return true; return false; } }