@Test public void passCase2() { VerifierResult result = hostHeaderVerifier.verify("www.hostname.com"); Assert.assertTrue(result.passed()); }
@Override public VerifierResult verify(String hostHeader) { List<ValidationResult> validationResults = new ArrayList<ValidationResult>(); String hostNameRegex = "^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"; try { Pattern p = Pattern.compile(hostNameRegex); Matcher m = p.matcher(hostHeader); boolean matchFound = m.matches(); if (matchFound) { return new VerifierResult(true); } else if (!matchFound) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } } catch (PatternSyntaxException exception) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } return new VerifierResult(true, validationResults); }
HostHeaderVerifier implements Verifier<String> { @Override public VerifierResult verify(String hostHeader) { List<ValidationResult> validationResults = new ArrayList<ValidationResult>(); String hostNameRegex = "^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"; try { Pattern p = Pattern.compile(hostNameRegex); Matcher m = p.matcher(hostHeader); boolean matchFound = m.matches(); if (matchFound) { return new VerifierResult(true); } else if (!matchFound) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } } catch (PatternSyntaxException exception) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } return new VerifierResult(true, validationResults); } }
HostHeaderVerifier implements Verifier<String> { @Override public VerifierResult verify(String hostHeader) { List<ValidationResult> validationResults = new ArrayList<ValidationResult>(); String hostNameRegex = "^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"; try { Pattern p = Pattern.compile(hostNameRegex); Matcher m = p.matcher(hostHeader); boolean matchFound = m.matches(); if (matchFound) { return new VerifierResult(true); } else if (!matchFound) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } } catch (PatternSyntaxException exception) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } return new VerifierResult(true, validationResults); }  }
HostHeaderVerifier implements Verifier<String> { @Override public VerifierResult verify(String hostHeader) { List<ValidationResult> validationResults = new ArrayList<ValidationResult>(); String hostNameRegex = "^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"; try { Pattern p = Pattern.compile(hostNameRegex); Matcher m = p.matcher(hostHeader); boolean matchFound = m.matches(); if (matchFound) { return new VerifierResult(true); } else if (!matchFound) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } } catch (PatternSyntaxException exception) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } return new VerifierResult(true, validationResults); }  @Override VerifierResult verify(String hostHeader); }
HostHeaderVerifier implements Verifier<String> { @Override public VerifierResult verify(String hostHeader) { List<ValidationResult> validationResults = new ArrayList<ValidationResult>(); String hostNameRegex = "^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"; try { Pattern p = Pattern.compile(hostNameRegex); Matcher m = p.matcher(hostHeader); boolean matchFound = m.matches(); if (matchFound) { return new VerifierResult(true); } else if (!matchFound) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } } catch (PatternSyntaxException exception) { validationResults.add(new ValidationResult(false, "Must provide a valid host header name.")); return new VerifierResult(false, validationResults); } return new VerifierResult(true, validationResults); }  @Override VerifierResult verify(String hostHeader);  }