Esempio n. 1
0
        internal void open()
        {
            logger.Debug("Open Session");

            // build uri
            UriBuilder uriBuilder = new UriBuilder();

            uriBuilder.Scheme = properties[SFSessionProperty.SCHEME];
            uriBuilder.Host   = properties[SFSessionProperty.HOST];
            uriBuilder.Port   = Int32.Parse(properties[SFSessionProperty.PORT]);
            uriBuilder.Path   = SF_LOGIN_PATH;
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            string value;

            queryString[SF_QUERY_WAREHOUSE]  = properties.TryGetValue(SFSessionProperty.WAREHOUSE, out value) ? value : "";
            queryString[SF_QUERY_DB]         = properties.TryGetValue(SFSessionProperty.DB, out value) ? value : "";
            queryString[SF_QUERY_SCHEMA]     = properties.TryGetValue(SFSessionProperty.SCHEMA, out value) ? value : "";
            queryString[SF_QUERY_REQUEST_ID] = Guid.NewGuid().ToString();
            uriBuilder.Query = queryString.ToString();

            // build post body
            AuthnRequestClientEnv clientEnv = new AuthnRequestClientEnv()
            {
                application = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
                osVersion   = System.Environment.OSVersion.VersionString
            };

            AuthnRequestData data = new AuthnRequestData()
            {
                loginName        = properties[SFSessionProperty.USER],
                password         = properties[SFSessionProperty.PASSWORD],
                clientAppId      = ".NET",
                clientAppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                accountName      = properties[SFSessionProperty.ACCOUNT],
                clientEnv        = clientEnv
            };

            // build request
            int           connectionTimeoutSec = Int32.Parse(properties[SFSessionProperty.CONNECTION_TIMEOUT]);
            SFRestRequest loginRequest         = new SFRestRequest();

            loginRequest.jsonBody = new AuthnRequest()
            {
                data = data
            };
            loginRequest.uri = uriBuilder.Uri;
            loginRequest.authorizationToken = SF_AUTHORIZATION_BASIC;
            // total login timeout
            loginRequest.sfRestRequestTimeout = connectionTimeoutSec <= 0 ? -1 : connectionTimeoutSec * 1000;

            if (logger.IsTraceEnabled)
            {
                logger.TraceFormat("Login Request Data: {0}", loginRequest.ToString());
            }

            JObject response = restRequest.post(loginRequest);

            parseLoginResponse(response);
        }
Esempio n. 2
0
        static SFSession()
        {
            AuthnRequestClientEnv clientEnv = new AuthnRequestClientEnv()
            {
                application = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
                osVersion   = System.Environment.OSVersion.VersionString
            };

            var clientVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            _EnvironmentData = Tuple.Create(clientEnv, clientVersion);
        }