@Test public void isHostAuthorized_shouldBeTrueIfInList() { assertThat(isHostAuthorized(List.of("A", "B"), "A")).isTrue(); assertThat(isHostAuthorized(List.of("A", "B"), "B")).isTrue(); }
static boolean isHostAuthorized(final List<String> allowlist, String hostHeader) { Optional<String> optionalHost = getAndValidateHostHeader(hostHeader); if (allowlist.contains("*") || (optionalHost.isPresent() && hostIsInAllowlist(allowlist, optionalHost.get()))) { return true; } else { return false; } }
HostAllowlistUtils { static boolean isHostAuthorized(final List<String> allowlist, String hostHeader) { Optional<String> optionalHost = getAndValidateHostHeader(hostHeader); if (allowlist.contains("*") || (optionalHost.isPresent() && hostIsInAllowlist(allowlist, optionalHost.get()))) { return true; } else { return false; } } }
HostAllowlistUtils { static boolean isHostAuthorized(final List<String> allowlist, String hostHeader) { Optional<String> optionalHost = getAndValidateHostHeader(hostHeader); if (allowlist.contains("*") || (optionalHost.isPresent() && hostIsInAllowlist(allowlist, optionalHost.get()))) { return true; } else { return false; } }  }
HostAllowlistUtils { static boolean isHostAuthorized(final List<String> allowlist, String hostHeader) { Optional<String> optionalHost = getAndValidateHostHeader(hostHeader); if (allowlist.contains("*") || (optionalHost.isPresent() && hostIsInAllowlist(allowlist, optionalHost.get()))) { return true; } else { return false; } }   }
HostAllowlistUtils { static boolean isHostAuthorized(final List<String> allowlist, String hostHeader) { Optional<String> optionalHost = getAndValidateHostHeader(hostHeader); if (allowlist.contains("*") || (optionalHost.isPresent() && hostIsInAllowlist(allowlist, optionalHost.get()))) { return true; } else { return false; } }    }