{"size": 2571, "ext": "js", "max_stars_repo_path": "src/exasol_jdbc/connectionBuilder.js", "max_stars_repo_name": "exasol/tableau-connector", "max_stars_repo_stars_event_min_datetime": "2021-09-30T05:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-06T18:20:54.000Z", "max_issues_repo_path": "src/exasol_jdbc/connectionBuilder.js", "max_issues_repo_name": "exasol/tableau-connector", "max_issues_repo_issues_event_min_datetime": "2021-01-29T12:11:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-23T13:45:42.000Z", "max_forks_repo_path": "src/exasol_jdbc/connectionBuilder.js", "max_forks_repo_name": "exasol/tableau-connector", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 27, "max_forks_count": null, "avg_line_length": 42.1475409836, "max_line_length": 112, "alphanum_fraction": 0.6682224815}
(function dsbuilder(attr) {
    "use strict";
    const jdbcDriverDebugEnabled = false;
    const jdbcDriverLogDir = "C:\\tmp"; // Windows
    //const jdbcDriverLogDir = "/tmp"; // Linux
    const kerberosServiceName = "exasol";

    function log(str) {
        logging.Log("[connectionBuilder.js] " + str)
    }

    function isEmpty(str) {
        return (!str || 0 === str.trim().length);
    }

    const hostName = attr[connectionHelper.attributeServer];
    const port = attr[connectionHelper.attributePort];
    const authentication = attr[connectionHelper.attributeAuthentication];
    const serverAuthMode = attr[connectionHelper.attributeTableauServerAuthMode];
    const fingerprint = attr["v-fingerprint"];
    const validateServerCertificate = attr["v-validateservercertificate"];
    const clientVersion = attr["v-clientversion"];
    const user = attr[connectionHelper.attributeUsername];
    const serverUser = attr[connectionHelper.attributeTableauServerUser];
    const runningOnServer = !isEmpty(serverUser);

    const fingerprintArg = !isEmpty(fingerprint) ? (";fingerprint=" + fingerprint.trim()) : "";

    const useKerberos = authentication === connectionHelper.valueAuthIntegrated;

    log(connectionHelper.attributeAuthentication + "=" + authentication + ", "
        + connectionHelper.attributeTableauServerAuthMode + "='" + serverAuthMode + "', "
        + connectionHelper.attributeUsername + "='" + user + "', "
        + connectionHelper.attributeTableauServerUser + "='" + serverUser + "', "
        + "useKerberos=" + useKerberos);

    let kerberosArg = "";
    if (useKerberos) {
        // Required to activate Kerberos authentication
        // https://www.exasol.com/support/browse/SUPPORT-26947
        kerberosArg = ";kerberoshostname=" + hostName + ";kerberosservicename=" + kerberosServiceName;
    }
    const clientName = runningOnServer ? "Tableau Server" : "Tableau Desktop";
    const clientVersionArg = !isEmpty(clientVersion) ? ";clientversion=" + clientVersion : "";

    const debugArg = (jdbcDriverDebugEnabled || attr['v-debug']) ? (";debug=1;logdir=" + jdbcDriverLogDir) : "";
    const portArg = isEmpty(port) ? "" : ":" + port;
    // See https://docs.exasol.com/connect_exasol/drivers/jdbc.htm
    const url = "jdbc:exa:"
        + hostName
        + portArg
        + ";validateservercertificate=" + validateServerCertificate
        + fingerprintArg
        + ";feedbackinterval=1"
        + ";clientname=" + clientName
        + clientVersionArg
        + kerberosArg
        + debugArg;
    return [url];
})
