@Test(dataProvider = "wildcardInPort") public void testWildcardInPort(String url, boolean result) { RedirectUrlValidator<String> validator = getValidator(asSet("http: assertThat(validator.isRedirectUrlValid(url, null)).isEqualTo(result); }
public boolean isRedirectUrlValid(final String url, final T configInfo) { if (url == null || url.isEmpty()) { return false; } final Collection<String> patterns = domainExtractor.extractValidDomains(configInfo); if (DEBUG.messageEnabled()) { DEBUG.message("Validating goto URL " + url + " against patterns:\n" + patterns); } if (url.length() > MAX_URL_LENGTH) { return false; } try { final URI uri = new URI(url); 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) { if (DEBUG.messageEnabled()) { DEBUG.message("The goto URL " + url + " is not a valid URI", urise); } return false; } if (patterns == null || patterns.isEmpty()) { if (DEBUG.messageEnabled()) { DEBUG.message("There are no patterns to validate the URL against, the goto URL is considered valid"); } return true; } final URLPatternMatcher patternMatcher = new URLPatternMatcher(); try { return patternMatcher.match(url, patterns, true); } catch (MalformedURLException murle) { DEBUG.error("An error occurred while validating goto URL: " + url, murle); return false; } }
RedirectUrlValidator { public boolean isRedirectUrlValid(final String url, final T configInfo) { if (url == null || url.isEmpty()) { return false; } final Collection<String> patterns = domainExtractor.extractValidDomains(configInfo); if (DEBUG.messageEnabled()) { DEBUG.message("Validating goto URL " + url + " against patterns:\n" + patterns); } if (url.length() > MAX_URL_LENGTH) { return false; } try { final URI uri = new URI(url); 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) { if (DEBUG.messageEnabled()) { DEBUG.message("The goto URL " + url + " is not a valid URI", urise); } return false; } if (patterns == null || patterns.isEmpty()) { if (DEBUG.messageEnabled()) { DEBUG.message("There are no patterns to validate the URL against, the goto URL is considered valid"); } return true; } final URLPatternMatcher patternMatcher = new URLPatternMatcher(); try { return patternMatcher.match(url, patterns, true); } catch (MalformedURLException murle) { DEBUG.error("An error occurred while validating goto URL: " + url, murle); return false; } } }
RedirectUrlValidator { public boolean isRedirectUrlValid(final String url, final T configInfo) { if (url == null || url.isEmpty()) { return false; } final Collection<String> patterns = domainExtractor.extractValidDomains(configInfo); if (DEBUG.messageEnabled()) { DEBUG.message("Validating goto URL " + url + " against patterns:\n" + patterns); } if (url.length() > MAX_URL_LENGTH) { return false; } try { final URI uri = new URI(url); 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) { if (DEBUG.messageEnabled()) { DEBUG.message("The goto URL " + url + " is not a valid URI", urise); } return false; } if (patterns == null || patterns.isEmpty()) { if (DEBUG.messageEnabled()) { DEBUG.message("There are no patterns to validate the URL against, the goto URL is considered valid"); } return true; } final URLPatternMatcher patternMatcher = new URLPatternMatcher(); try { return patternMatcher.match(url, patterns, true); } catch (MalformedURLException murle) { DEBUG.error("An error occurred while validating goto URL: " + url, murle); return false; } } RedirectUrlValidator(final ValidDomainExtractor<T> domainExtractor); }
RedirectUrlValidator { public boolean isRedirectUrlValid(final String url, final T configInfo) { if (url == null || url.isEmpty()) { return false; } final Collection<String> patterns = domainExtractor.extractValidDomains(configInfo); if (DEBUG.messageEnabled()) { DEBUG.message("Validating goto URL " + url + " against patterns:\n" + patterns); } if (url.length() > MAX_URL_LENGTH) { return false; } try { final URI uri = new URI(url); 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) { if (DEBUG.messageEnabled()) { DEBUG.message("The goto URL " + url + " is not a valid URI", urise); } return false; } if (patterns == null || patterns.isEmpty()) { if (DEBUG.messageEnabled()) { DEBUG.message("There are no patterns to validate the URL against, the goto URL is considered valid"); } return true; } final URLPatternMatcher patternMatcher = new URLPatternMatcher(); try { return patternMatcher.match(url, patterns, true); } catch (MalformedURLException murle) { DEBUG.error("An error occurred while validating goto URL: " + url, murle); return false; } } RedirectUrlValidator(final ValidDomainExtractor<T> domainExtractor); boolean isRedirectUrlValid(final String url, final T configInfo); }
RedirectUrlValidator { public boolean isRedirectUrlValid(final String url, final T configInfo) { if (url == null || url.isEmpty()) { return false; } final Collection<String> patterns = domainExtractor.extractValidDomains(configInfo); if (DEBUG.messageEnabled()) { DEBUG.message("Validating goto URL " + url + " against patterns:\n" + patterns); } if (url.length() > MAX_URL_LENGTH) { return false; } try { final URI uri = new URI(url); 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) { if (DEBUG.messageEnabled()) { DEBUG.message("The goto URL " + url + " is not a valid URI", urise); } return false; } if (patterns == null || patterns.isEmpty()) { if (DEBUG.messageEnabled()) { DEBUG.message("There are no patterns to validate the URL against, the goto URL is considered valid"); } return true; } final URLPatternMatcher patternMatcher = new URLPatternMatcher(); try { return patternMatcher.match(url, patterns, true); } catch (MalformedURLException murle) { DEBUG.error("An error occurred while validating goto URL: " + url, murle); return false; } } RedirectUrlValidator(final ValidDomainExtractor<T> domainExtractor); boolean isRedirectUrlValid(final String url, final T configInfo); final static String GOTO; final static String GOTO_ON_FAIL; }