class RedirectUrlValidator {

    public boolean isRedirectUrlValid(final String url, final T configInfo) {
        if (StringUtils.isEmpty(url)) {
            return false;
        }
        final Collection<String> patterns = domainExtractor.extractValidDomains(configInfo);
        DEBUG.message("RedirectUrlValidator.isRedirectUrlValid: Validating goto URL {} against patterns: {}",
                url, patterns);

        if (url.length() > MAX_URL_LENGTH) {
            DEBUG.message("RedirectUrlValidator.isRedirectUrlValid:"
                    + " The url was length {} which is longer than the allowed maximum of {}",
                    url.length(), MAX_URL_LENGTH);
            return false;
        }

        try {
            final URI uri = new URI(url);
            // Both Absolute and scheme relative URLs should be validated.
            if (!uri.isAbsolute() && !url.startsWith("//")) {
                return true;
            }

            if (uri.getScheme() != null && !uri.getScheme().equals("http") && !uri.getScheme().equals("https")) {
                return false;
            }
        } catch (final URISyntaxException urise) {
            DEBUG.message("RedirectUrlValidator.isRedirectUrlValid: The goto URL {} is not a valid URI", url, urise);
            return false;
        }

        if (patterns == null || patterns.isEmpty()) {
            DEBUG.message("RedirectUrlValidator.isRedirectUrlValid:"
                    + " There are no patterns to validate the URL against, the goto URL {} is considered valid", url);
            return true;
        }

        final URLPatternMatcher patternMatcher = new URLPatternMatcher();
        try {
            return patternMatcher.match(url, patterns, true);
        } catch (MalformedURLException murle) {
            DEBUG.error("RedirectUrlValidator.isRedirectUrlValid: An error occurred while validating goto URL: {}",
                    url, murle);
            return false;
        }
    }

    public  RedirectUrlValidator(final ValidDomainExtractor<T> domainExtractor);

}