public static boolean isValidOrigin(String sourceHost, ZeppelinConfiguration zConf)
      throws UnknownHostException, URISyntaxException {

    String sourceUriHost = "";

    if (sourceHost != null && !sourceHost.isEmpty()) {
      sourceUriHost = new URI(sourceHost).getHost();
      sourceUriHost = (sourceUriHost == null) ? "" : sourceUriHost.toLowerCase();
    }

    sourceUriHost = sourceUriHost.toLowerCase();
    String currentHost = InetAddress.getLocalHost().getHostName().toLowerCase();

    return zConf.getAllowedOrigins().contains("*")
        || currentHost.equals(sourceUriHost)
        || "localhost".equals(sourceUriHost)
        || zConf.getAllowedOrigins().contains(sourceHost);
  }
@Test
  void isLocalMachine() throws URISyntaxException, UnknownHostException {
    String origin = "http://" + InetAddress.getLocalHost().getHostName();
    assertTrue(CorsUtils.isValidOrigin(origin, ZeppelinConfiguration.load()),
      "Origin " + origin + " is not allowed. Please check your hostname.");
  }