/** * Returns the input if valid over the given white list and black list patterns else throws an * IdentityValidationException * * @param input input * @param whiteListPatterns a String array of white list pattern keys * @param blackListPatterns a String array of black list pattern keys * @return input if valid over the given white list and black list patterns else throws an * IdentityValidationException * @throws IdentityValidationException if input is invalid for the he given white list and black list patterns */ public static String getValidInput(String input, String[] whiteListPatterns, String[] blackListPatterns) throws IdentityValidationException { if (StringUtils.isEmpty(input) || isValid(input, whiteListPatterns, blackListPatterns)) { return input; } StringBuilder message = new StringBuilder(); message.append(msgSection1); message.append(String.format(msgSection2, getPatternString(whiteListPatterns))); message.append(msgSection4); message.append(String.format(msgSection3, getPatternString(blackListPatterns))); throw new IdentityValidationException(message.toString()); }
/** * Returns the input if valid over the given white list and black list patterns else throws an * IdentityValidationException * * @param input input * @param whiteListPatterns a String array of white list pattern keys * @param blackListPatterns a String array of black list pattern keys * @return input if valid over the given white list and black list patterns else throws an * IdentityValidationException */ public static String getValidInput(String input, String[] whiteListPatterns, String[] blackListPatterns) throws IdentityValidationException { if (StringUtils.isEmpty(input) || isValid(input, whiteListPatterns, blackListPatterns)) { return input; } StringBuilder message = new StringBuilder(); message.append(msgSection1); message.append(String.format(msgSection2, getPatternString(whiteListPatterns))); message.append(msgSection4); message.append(String.format(msgSection3, getPatternString(blackListPatterns))); throw new IdentityValidationException(message.toString()); }
/** * Returns the input if valid over the given white list patterns else throws an IdentityValidationException * * @param input input * @param whiteListPatterns a String array of white list pattern keys * @return input if valid over the given white list patterns else throws an IdentityValidationException */ public static String getValidInputOverWhiteListPatterns(String input, String... whiteListPatterns) throws IdentityValidationException { if (StringUtils.isEmpty(input) || isValidOverWhiteListPatterns(input, whiteListPatterns)) { return input; } throw new IdentityValidationException( msgSection1 + String.format(msgSection2, getPatternString(whiteListPatterns))); }
/** * Returns the input if valid over the given black list patterns else throws an IdentityValidationException * * @param input input * @param blackListPatterns a String array of black list pattern keys * @return input if valid over the given black list patterns else throws an IdentityValidationException */ public static String getValidInputOverBlackListPatterns(String input, String... blackListPatterns) throws IdentityValidationException { if (StringUtils.isEmpty(input) || isValidOverBlackListPatterns(input, blackListPatterns)) { return input; } throw new IdentityValidationException( msgSection1 + String.format(msgSection3, getPatternString(blackListPatterns))); }
/** * Returns the input if valid over the given black list patterns else throws an IdentityValidationException * * @param input input * @param blackListPatterns a String array of black list pattern keys * @return input if valid over the given black list patterns else throws an IdentityValidationException * @throws IdentityValidationException if a black list pattern key provided does not correspond to a registered * regex. */ public static String getValidInputOverBlackListPatterns(String input, String... blackListPatterns) throws IdentityValidationException { if (StringUtils.isEmpty(input) || isValidOverBlackListPatterns(input, blackListPatterns)) { return input; } throw new IdentityValidationException( msgSection1 + String.format(msgSection3, getPatternString(blackListPatterns))); }
/** * Returns the input if valid over the given white list patterns else throws an IdentityValidationException * * @param input input * @param whiteListPatterns a String array of white list pattern keys * @return input if valid over the given white list patterns else throws an IdentityValidationException * @throws IdentityValidationException if a white list pattern key provided does not correspond to a registered * regex. */ public static String getValidInputOverWhiteListPatterns(String input, String... whiteListPatterns) throws IdentityValidationException { if (StringUtils.isEmpty(input) || isValidOverWhiteListPatterns(input, whiteListPatterns)) { return input; } throw new IdentityValidationException( msgSection1 + String.format(msgSection2, getPatternString(whiteListPatterns))); }