1 19 20 package com.sslexplorer.input.validators; 21 22 import java.util.regex.Pattern ; 23 24 31 public class HostnameOrIPAddressWithReplacementsValidator extends StringValidator { 32 33 private static final int MAX_HOST_OR_IP_CHARS = 255; 34 38 final static String HOST_PATTERN = "^[a-zA-Z0-9\\.\\-\\_\\{\\}\\:\\$]*"; 39 40 43 public HostnameOrIPAddressWithReplacementsValidator() { 44 super(1, MAX_HOST_OR_IP_CHARS, HOST_PATTERN, null, true); 45 this.regExpErrCode = ErrorConstants.ERR_STRING_ISNT_HOSTNAME_OR_IPADDRESS; 46 } 47 48 54 public static boolean isValidAsHostOrIp(String value){ 55 if (value.length() > MAX_HOST_OR_IP_CHARS) 56 return false; 57 else 58 return Pattern.compile(HOST_PATTERN).matcher(value).matches(); 59 } 60 61 } 62 | Popular Tags |