private def createBasicSecuredConnection()

in common/src/main/scala/com/gerritforge/analytics/common/api/gerritApiConnectivity.scala [45:65]


  private def createBasicSecuredConnection(
      url: String,
      username: String,
      password: String
  ): BufferedSource = {
    try {
      if (ignoreSSLCert) trustAllSSLCerts()

      val unsecureURL  = new URL(url)
      val endPointPath = unsecureURL.getFile
      val basicAuthURL = unsecureURL.toString.replace(endPointPath, s"/a$endPointPath")

      logger.info(s"Connecting to API $basicAuthURL with basic auth")

      val connection = new URL(basicAuthURL).openConnection
      connection.setRequestProperty(AUTHORIZATION, getHeader(username, password))
      Source.fromInputStream(connection.getInputStream, Codec.UTF8.name)
    } catch {
      case e: Exception => throw new Exception(s"Unable to connect to $url. $e")
    }
  }