public static URI getCallBackUri(HiveConf conf) throws Exception {
    String callbackUrl = conf.getVar(ConfVars.HIVE_SERVER2_SAML_CALLBACK_URL);
    try {
      URI uri = new URI(callbackUrl);
      int port = uri.getPort();
      int httpPort = conf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT);
      // we only support the callback url to be at the same port as the http
      // server. In case the port is not provided we default to using http port.
      Preconditions.checkArgument(port == -1 || port == httpPort,
          "Callback url " + callbackUrl + " must be at the same port " + httpPort
              + " defined by " + ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT.varname);
      return uri;
    } catch (URISyntaxException e) {
      throw new Exception("Invalid callback url configuration: "
          + ConfVars.HIVE_SERVER2_SAML_CALLBACK_URL.varname + " = " + callbackUrl);
    }
  }
Gets the configured callback url path for the SAML service provider. Also, makes sure
that the port number is same as the HTTP thrift port.
@param conf Hive server configuration.
@return the Callback URL http path.
@throws Exception In case the URL is invalid or if the port doesn't match http port.
service/src/java/org/apache/hive/service/auth/saml/HiveSamlUtils.java