org.apache.commons.validator.routines.UrlValidator Java Examples

The following examples show how to use org.apache.commons.validator.routines.UrlValidator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigArgs.java    From quarantyne with Apache License 2.0 6 votes vote down vote up
public EgressUrl getEgress() {
  EgressUrl egressUrl = null;
  try {
    if (!UrlValidator.getInstance().isValid(egress) || egress.startsWith("https")) {
      throw new Exception();
    }
    URL url = new URL(egress);
    int port = 80;
    if (url.getPort() != -1) {
      port = url.getPort();
    }
    egressUrl = new EgressUrl(url.getProtocol(), url.getHost(), port);
  } catch (Exception e) {
    log.error("Cannot start because egress ("+egress+") is not a valid HTTP URL. HTTPS is not supported");
    System.exit(-1);
  }
  return egressUrl;
}
 
Example #2
Source File: CommonsURLValidator.java    From cxf-fediz with Apache License 2.0 6 votes vote down vote up
public boolean isValid(RequestContext context, String endpointAddress)
    throws Exception {
    if (endpointAddress == null) {
        return true;
    }

    // The endpointAddress address must be a valid URL + start with http(s)
    // Validate it first using commons-validator
    UrlValidator urlValidator = new UrlValidator(new String[] {"http", "https"}, UrlValidator.ALLOW_LOCAL_URLS);
    if (!urlValidator.isValid(endpointAddress)) {
        LOG.warn("The given endpointAddress parameter {} is not a valid URL", endpointAddress);
        return false;
    }

    return true;
}
 
Example #3
Source File: GetDiagnosticsDataCmd.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException {
    try {
        String downloadUrl = diagnosticsService.getDiagnosticsDataCommand(this);
        UrlValidator urlValidator = new UrlValidator();
        if (StringUtils.isEmpty(downloadUrl)) {
            throw new CloudRuntimeException("Failed to retrieve diagnostics files");
        }
        GetDiagnosticsDataResponse response = new GetDiagnosticsDataResponse();
        if (urlValidator.isValid(downloadUrl)){
            response.setUrl(downloadUrl);
            response.setObjectName("diagnostics");
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new CloudRuntimeException("failed to generate valid download url: " + downloadUrl);
        }
    } catch (ServerApiException e) {
        throw new CloudRuntimeException("Internal exception caught while retrieving diagnostics files: ", e);
    }
}
 
Example #4
Source File: TripleIndex.java    From AGDISTIS with GNU Affero General Public License v3.0 6 votes vote down vote up
public TripleIndex() throws IOException {
	Properties prop = new Properties();
	InputStream input = TripleIndex.class.getResourceAsStream("/config/agdistis.properties");
	prop.load(input);

	String envIndex = System.getenv("AGDISTIS_INDEX");
	String index = envIndex != null ? envIndex : prop.getProperty("index");
	log.info("The index will be here: " + index);

	directory = new MMapDirectory(new File(index));
	ireader = DirectoryReader.open(directory);
	isearcher = new IndexSearcher(ireader);
	this.urlValidator = new UrlValidator();

	cache = CacheBuilder.newBuilder().maximumSize(50000).build();
}
 
Example #5
Source File: TripleIndexContext.java    From AGDISTIS with GNU Affero General Public License v3.0 6 votes vote down vote up
public TripleIndexContext() throws IOException {
	Properties prop = new Properties();
	InputStream input = TripleIndexContext.class.getResourceAsStream("/config/agdistis.properties");
	prop.load(input);

	String envIndex = System.getenv("AGDISTIS_INDEX_BY_CONTEXT");
	String index = envIndex != null ? envIndex : prop.getProperty("index_bycontext");
	log.info("The index will be here: " + index);

	directory = new MMapDirectory(new File(index));
	ireader = DirectoryReader.open(directory);
	isearcher = new IndexSearcher(ireader);
	new UrlValidator();

	cache = CacheBuilder.newBuilder().maximumSize(50000).build();
}
 
Example #6
Source File: CreateUserFormValidator.java    From Asqatasun with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * @param userSubscriptionCommand
 * @param errors
 * @return
 */
private boolean checkSiteUrl(CreateUserCommand userSubscriptionCommand, Errors errors) {
    if (!checkSiteUrl) {
        return true;
    }
    if (userSubscriptionCommand.getSiteUrl() == null ||
            userSubscriptionCommand.getSiteUrl().trim().isEmpty()) {
        errors.rejectValue(SITE_URL_KEY, MISSING_URL_KEY);
        return false;
    } else {
        String url = userSubscriptionCommand.getSiteUrl().trim();
        String[] schemes = {"http","https"};
        UrlValidator urlValidator = new UrlValidator (schemes, UrlValidator.ALLOW_2_SLASHES);
        if (!urlValidator.isValid(url)) {
            errors.rejectValue(SITE_URL_KEY, INVALID_URL_KEY);
            return false;
        }
    }
    return true;
}
 
Example #7
Source File: CreateContractFormValidator.java    From Asqatasun with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * @param userSubscriptionCommand
 * @param errors
 * @return
 */
private boolean checkContractUrl(CreateContractCommand createContractCommand, Errors errors) {
    String url = createContractCommand.getContractUrl().trim();
    if (StringUtils.isBlank(url)) {
        // forbid contract without URL and with website audit enabled
        Map<String, Boolean> functionalityMap = createContractCommand.getFunctionalityMap();
        for (Entry<String, Boolean> it : functionalityMap.entrySet()) {
            if (it.getKey().equals("DOMAIN") && it.getValue() != null) {
                errors.rejectValue(CONTRACT_URL_KEY, MISSING_URL_KEY);
                return false;
            }
        }
        return true;
    }

    String[] schemes = {"http","https"};
    long validatorOptions = UrlValidator.ALLOW_2_SLASHES + UrlValidator.ALLOW_LOCAL_URLS;
    UrlValidator urlValidator = new UrlValidator (schemes, new RegexValidator(".*"), validatorOptions);
    if (!urlValidator.isValid(url)) {
        errors.rejectValue(CONTRACT_URL_KEY, INVALID_URL_KEY);
        return false;
    }
    return true;
}
 
Example #8
Source File: SignUpFormValidator.java    From Asqatasun with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * @param userSubscriptionCommand
 * @param errors
 * @return
 */
private boolean checkSiteUrl(CreateUserCommand userSubscriptionCommand, Errors errors) {
    if (!checkSiteUrl) {
        return true;
    }
    if (userSubscriptionCommand.getSiteUrl() == null ||
            userSubscriptionCommand.getSiteUrl().trim().isEmpty()) {
        errors.rejectValue(SITE_URL_KEY, MISSING_URL_KEY);
        return false;
    } else {
        String url = userSubscriptionCommand.getSiteUrl().trim();
        String[] schemes = {"http","https"};
        UrlValidator urlValidator = new UrlValidator (schemes, UrlValidator.ALLOW_2_SLASHES);
        if (!urlValidator.isValid(url)) {
            errors.rejectValue(SITE_URL_KEY, INVALID_URL_KEY);
            return false;
        }
    }
    return true;
}
 
Example #9
Source File: NSDUtils.java    From NFVO with Apache License 2.0 6 votes vote down vote up
private void checkIntegrityVNFPackage(
    VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor) {
  if (virtualNetworkFunctionDescriptor.getVnfPackageLocation() != null) {
    UrlValidator urlValidator = new UrlValidator();
    if (urlValidator.isValid(
        virtualNetworkFunctionDescriptor.getVnfPackageLocation())) { // this is a script link
      VNFPackage vnfPackage = new VNFPackage();
      vnfPackage.setScriptsLink(virtualNetworkFunctionDescriptor.getVnfPackageLocation());
      vnfPackage.setName(virtualNetworkFunctionDescriptor.getName());
      vnfPackage.setProjectId(virtualNetworkFunctionDescriptor.getProjectId());
      if (vnfPackage.getId() == null) vnfPackage = vnfPackageRepository.save(vnfPackage);
      virtualNetworkFunctionDescriptor.setVnfPackageLocation(vnfPackage.getId());
    }
  } else {
    log.warn("vnfPackageLocation is null. Are you sure?");
  }
}
 
Example #10
Source File: CSARParser.java    From NFVO with Apache License 2.0 6 votes vote down vote up
public VirtualNetworkFunctionDescriptor onboardVNFD(byte[] bytes, String projectId)
    throws NotFoundException, PluginException, VimException, IOException, IncompatibleVNFPackage,
        org.openbaton.tosca.exceptions.NotFoundException, BadRequestException,
        AlreadyExistingException, BadFormatException, InterruptedException,
        EntityUnreachableException, ExecutionException {

  InputStream input = new ByteArrayInputStream(bytes);

  readFiles(input);

  VNFDTemplate vnfdt = Utils.bytesToVNFDTemplate(this.template);
  VirtualNetworkFunctionDescriptor vnfd = toscaParser.parseVNFDTemplate(vnfdt);

  String scriptsLink = null;
  UrlValidator urlValidator = new UrlValidator();
  if (urlValidator.isValid(vnfd.getVnfPackageLocation())) {
    scriptsLink = vnfd.getVnfPackageLocation();
  }
  saveVNFD(vnfd, projectId, scripts, scriptsLink);

  input.close();
  this.template.close();
  this.metadata.close();

  return vnfd;
}
 
Example #11
Source File: SPARQLRepositoryWrapper.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void validateConfig(Map<String, Object> props) {
    super.validateConfig(props);
    SPARQLRepositoryConfig config = Configurable.createConfigurable(SPARQLRepositoryConfig.class, props);

    String[] schemes = {"http","https"};
    UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_LOCAL_URLS);
    if (!urlValidator.isValid(config.endpointUrl())) {
        throw new RepositoryConfigException(
                new IllegalArgumentException("Repository endpointUrl is not a valid URL: " + config.endpointUrl())
        );
    }

    if (config.updateEndpointUrl() != null && !urlValidator.isValid(config.updateEndpointUrl())) {
        throw new RepositoryConfigException(
                new IllegalArgumentException("Repository updateEndpointUrl is not a valid URL: "
                        + config.updateEndpointUrl())
        );
    }
}
 
Example #12
Source File: URLsTest.java    From mockneat with Apache License 2.0 6 votes vote down vote up
@Test
public void testURLAuth() {
    loop(
            URL_CYCLES,
            MOCKS,
            mockNeat -> mockNeat.urls().auth().val(),
            url -> {
                assertNotNull(url);
                try {
                    URL urlObj = new URL(url);
                    String[] userInfo = urlObj.getUserInfo().split(":");

                    assertTrue(userInfo.length == 2);
                    assertTrue(StringUtils.isNotEmpty(userInfo[0]));
                    assertTrue(StringUtils.isNotEmpty(userInfo[1]));

                    assertTrue(UrlValidator.getInstance().isValid(url));

                } catch (MalformedURLException e) {
                    Assert.fail();
                }
            }
    );
}
 
Example #13
Source File: FormattedTextImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public boolean validateURL(String urlToValidate) {
      if (StringUtils.isBlank(urlToValidate)) return false;

if ( ABOUT_BLANK.equals(urlToValidate) ) return true;

      // Check if the url is "Escapable" - run through the URL-URI-URL gauntlet
      String escapedURL = sanitizeHrefURL(urlToValidate);
      if ( escapedURL == null ) return false;

      // For a protocol-relative URL, we validate with protocol attached 
      // RFC 1808 Section 4
      if ((urlToValidate.startsWith("//")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = PROTOCOL_PREFIX + urlToValidate;
      }

      // For a site-relative URL, we validate with host name and protocol attached 
      // SAK-13787 SAK-23752
      if ((urlToValidate.startsWith("/")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = HOST_PREFIX + urlToValidate;
      }

      // Validate the url
      UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
      return urlValidator.isValid(urlToValidate);
  }
 
Example #14
Source File: FormattedTextImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public boolean validateURL(String urlToValidate) {
      if (StringUtils.isBlank(urlToValidate)) return false;

if ( ABOUT_BLANK.equals(urlToValidate) ) return true;

      // Check if the url is "Escapable" - run through the URL-URI-URL gauntlet
      String escapedURL = sanitizeHrefURL(urlToValidate);
      if ( escapedURL == null ) return false;

      // For a protocol-relative URL, we validate with protocol attached 
      // RFC 1808 Section 4
      if ((urlToValidate.startsWith("//")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = PROTOCOL_PREFIX + urlToValidate;
      }

      // For a site-relative URL, we validate with host name and protocol attached 
      // SAK-13787 SAK-23752
      if ((urlToValidate.startsWith("/")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = HOST_PREFIX + urlToValidate;
      }

      // Validate the url
      UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
      return urlValidator.isValid(urlToValidate);
  }
 
Example #15
Source File: PortletIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public boolean validateURL(String urlToValidate) {
// return FormattedText.validateURL(urlToValidate); // KNL-1105
      if (StringUtils.isBlank(urlToValidate)) return false;

if ( ABOUT_BLANK.equals(urlToValidate) ) return true;

      // Check if the url is "Escapable" - run through the URL-URI-URL gauntlet
      String escapedURL = sanitizeHrefURL(urlToValidate);
      if ( escapedURL == null ) return false;

      // For a protocol-relative URL, we validate with protocol attached 
      // RFC 1808 Section 4
      if ((urlToValidate.startsWith("//")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = PROTOCOL_PREFIX + urlToValidate;
      }

      // For a site-relative URL, we validate with host name and protocol attached 
      // SAK-13787 SAK-23752
      if ((urlToValidate.startsWith("/")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = HOST_PREFIX + urlToValidate;
      }

      // Validate the url
      UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
      return urlValidator.isValid(urlToValidate);
  }
 
Example #16
Source File: WidgetValidatorTest.java    From attic-rave with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidation() throws Exception {
     RegexValidator regex = new RegexValidator(new String[]{"http","https","((localhost)(:[0-9]+))",".*\\.linux-server(:[0-9]+)"});
     UrlValidator validator = new UrlValidator(regex, 0);
     assertTrue("localhost URL should validate",
               validator.isValid("http://localhost:8080/demogadgets/CTSSResourcesMapView.xml"));
       assertTrue("127.0.0.1 should validate",
               validator.isValid("http://127.0.0.1:8080/demogadgets/CTSSResourcesMapView.xml"));
       assertTrue("my.linux-server should validate",
               validator.isValid("http://my.linux-server:8080/demogadgets/CTSSResourcesMapView.xml"));

       assertFalse("broke.my-test should not validate",
               validator.isValid("http://broke.my-test/test/index.html"));

       assertTrue("www.apache.org should still validate",
               validator.isValid("http://www.apache.org/test/index.html"));
   }
 
Example #17
Source File: R2MVerifyHelper.java    From r2m-plugin-android with Apache License 2.0 5 votes vote down vote up
public static boolean isValidUrl(String url) {
    String templateURL = url;
    templateURL = templateURL.replaceAll(R2MConstants.START_TEMPLATE_VARIABLE_REGEX, "");
    templateURL = templateURL.replaceAll(R2MConstants.END_TEMPLATE_VARIABLE_REGEX, "");
    UrlValidator urlValidator = new UrlValidator(SUPPORTED_PROTOCOL_SCHEMES, URL_VALIDATION_OPTIONS);
    return urlValidator.isValid(templateURL);
}
 
Example #18
Source File: Validator.java    From mangooio with Apache License 2.0 5 votes vote down vote up
/**
 * Validates field to be a valid URL
 *
 * @param name The field to check
 * @param message A custom error message instead of the default one
 */
public void expectUrl(String name, String message) {
    String value = Optional.ofNullable(get(name)).orElse("");

    if (!UrlValidator.getInstance().isValid(value)) {
        addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.URL_KEY.name(), name)));
    }
}
 
Example #19
Source File: SimpleURLValidator.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Override
public boolean validate(URI url) {
    String[] schemes = {"http", "https"};
    UrlValidator validator = new UrlValidator(schemes);

    return validator.isValid(url.toString());
}
 
Example #20
Source File: PortletIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public boolean validateURL(String urlToValidate) {
// return FormattedText.validateURL(urlToValidate); // KNL-1105
      if (StringUtils.isBlank(urlToValidate)) return false;

if ( ABOUT_BLANK.equals(urlToValidate) ) return true;

      // Check if the url is "Escapable" - run through the URL-URI-URL gauntlet
      String escapedURL = sanitizeHrefURL(urlToValidate);
      if ( escapedURL == null ) return false;

      // For a protocol-relative URL, we validate with protocol attached 
      // RFC 1808 Section 4
      if ((urlToValidate.startsWith("//")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = PROTOCOL_PREFIX + urlToValidate;
      }

      // For a site-relative URL, we validate with host name and protocol attached 
      // SAK-13787 SAK-23752
      if ((urlToValidate.startsWith("/")) && (urlToValidate.indexOf("://") == -1))
      {
          urlToValidate = HOST_PREFIX + urlToValidate;
      }

      // Validate the url
      UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
      return urlValidator.isValid(urlToValidate);
  }
 
Example #21
Source File: VkSubscriptionServiceImpl.java    From JuniperBot with GNU General Public License v3.0 5 votes vote down vote up
private void setPhoto(VkConnection connection, Set<String> images, WebhookEmbedBuilder builder, CallbackMessage<Wallpost> message, Photo photo, boolean showText) {
    String imageUrl = coalesce(photo.getPhoto2560(),
            photo.getPhoto1280(),
            photo.getPhoto807(),
            photo.getPhoto604(),
            photo.getPhoto130(),
            photo.getPhoto75());
    if (!UrlValidator.getInstance().isValid(imageUrl)) {
        return;
    }
    if (images.add(imageUrl)) {
        String url = String.format(PHOTO_URL,
                Math.abs(message.getGroupId()),
                message.getObject().getId(),
                Math.abs(photo.getOwnerId()),
                photo.getId());

        if (showText) {
            setText(connection, builder, photo.getText(), url);
        }

        builder.setImageUrl(imageUrl);
        if (connection.isShowDate() && photo.getDate() != null) {
            builder.setTimestamp(new Date(((long) photo.getDate()) * 1000).toInstant());
        }
    }
}
 
Example #22
Source File: DiscordUtils.java    From JuniperBot with GNU General Public License v3.0 5 votes vote down vote up
public static Icon createIcon(String iconUrl) {
    if (UrlValidator.getInstance().isValid(iconUrl)) {
        try {
            return Icon.from(new URL(iconUrl).openStream());
        } catch (Exception e) {
            // fall down
        }
    }
    return null;
}
 
Example #23
Source File: FormUtils.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
public static boolean isUrlValid(String value) {
    if (StringUtils.isBlank(value)) {
        return false;
    }
    if (value.startsWith("$") && value.length() > 1) {
        return true;
    }

    return UrlValidator.getInstance().isValid(value);
}
 
Example #24
Source File: HTTPRepositoryWrapper.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void validateConfig(Map<String, Object> props) {
    super.validateConfig(props);
    HTTPRepositoryConfig config = Configurable.createConfigurable(HTTPRepositoryConfig.class, props);

    String[] schemes = {"http","https"};
    UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_LOCAL_URLS);
    if (!urlValidator.isValid(config.serverUrl())) {
        throw new RepositoryConfigException(
                new IllegalArgumentException("Repository serverUrl is not a valid URL: " + config.serverUrl())
        );
    }
}
 
Example #25
Source File: SaltApiNodeStepPlugin.java    From salt-step with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void validate(String user, String password, INodeEntry entry) throws SaltStepValidationException {
    checkNotEmpty(SALT_API_END_POINT_OPTION_NAME, saltEndpoint, SaltApiNodeStepFailureReason.ARGUMENTS_MISSING,
            entry);
    checkNotEmpty(SALT_API_FUNCTION_OPTION_NAME, function, SaltApiNodeStepFailureReason.ARGUMENTS_MISSING, entry);
    checkNotEmpty(SALT_API_EAUTH_OPTION_NAME, eAuth, SaltApiNodeStepFailureReason.ARGUMENTS_MISSING, entry);
    checkNotEmpty(SALT_USER_OPTION_NAME, user, SaltApiNodeStepFailureReason.ARGUMENTS_MISSING, entry);
    checkNotEmpty(SALT_PASSWORD_OPTION_NAME, password, SaltApiNodeStepFailureReason.ARGUMENTS_MISSING, entry);

    UrlValidator urlValidator = new UrlValidator(endPointSchemes, UrlValidator.ALLOW_LOCAL_URLS);
    if (!urlValidator.isValid(saltEndpoint)) {
        throw new SaltStepValidationException(SALT_API_END_POINT_OPTION_NAME, String.format(
                "%s is not a valid endpoint.", saltEndpoint), SaltApiNodeStepFailureReason.ARGUMENTS_INVALID,
                entry.getNodename());
    }
}
 
Example #26
Source File: JWTPolicyBean.java    From apiman-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Signing Key
 * <p>
 * To validate JWT. Must be Base-64 encoded.
 *
 * @param signingKeyString
 *            The signingKeyString
 * @throws Exception key parsing exceptions
 */
@JsonProperty("signingKeyString")
public void setSigningKeyString(String signingKeyString) throws Exception {
    if (signingKey == null) {
        String[] schemes = {"http","https"};
        UrlValidator urlValidator = new UrlValidator(schemes);
        // If it is a jwk(s) url we don't set the signingKey
        if (!urlValidator.isValid(signingKeyString)){
            signingKey = PemUtils.decodePublicKey(signingKeyString);
        }
    }
    this.signingKeyString = signingKeyString;
}
 
Example #27
Source File: MailService.java    From pacbot with Apache License 2.0 4 votes vote down vote up
private boolean isHttpUrl(String url) {
	return new UrlValidator().isValid(url);
}
 
Example #28
Source File: GitPluginImpl.java    From go-plugins with Apache License 2.0 4 votes vote down vote up
private boolean isValidURL(String url) {
    return new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS).isValid(url);
}
 
Example #29
Source File: HIPAAMatcherAttributeValue.java    From arx with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(String value) {
    UrlValidator validator = UrlValidator.getInstance();
    return validator.isValid(value);
}
 
Example #30
Source File: WidgetValidator.java    From attic-rave with Apache License 2.0 4 votes vote down vote up
public WidgetValidator() {
    super();
    RegexValidator regex = new RegexValidator(new String[] {"http", "https","((localhost)(:[0-9]+))"});
    urlValidator = new UrlValidator(regex, 0);
}