code: private boolean isInWhiteList(URL url) {
          final String host = url.getHost();
          final int port = url.getPort();
          final String protocol = url.getProtocol();
  
          final int portToTest = (port != -1) ? port : (StringUtils.equalsIgnoreCase(protocol, "https") ? 443 : 80);
  
          List<String> matchingWhiteListEntries = proxyWhiteList.stream().filter((String whitelistEntry) -> {
              String whitelistHost;
              int whitelistPort;
              if (StringUtils.contains(whitelistEntry, ":")) {
                  whitelistHost = whitelistEntry.split(":")[0];
                  whitelistPort = Integer.parseInt(whitelistEntry.split(":")[1]);
              } else {
                  whitelistHost = whitelistEntry;
                  whitelistPort = -1;
              }
              final int portToTestAgainst = (whitelistPort != -1) ? whitelistPort : (StringUtils.equalsIgnoreCase(protocol, "https") ? 443 : 80);
              final boolean portIsMatching = portToTestAgainst == portToTest;
              final boolean domainIsMatching = StringUtils.equalsIgnoreCase(host, whitelistHost) || StringUtils.endsWith(host, whitelistHost);
              return (portIsMatching && domainIsMatching);
          }).collect(Collectors.toList());
          boolean isAllowed = !matchingWhiteListEntries.isEmpty();
  
          return isAllowed;
      }
docs: Helper method to check whether the URI is contained in the host whitelist provided in list of whitelisted hosts
  
  @param url {@link URI} to check
  @return true if contained, false otherwise