コード例 #1
0
 public virtual void ChangeEnvironment(SalesforceConfig config, bool login = false)
 {
     _config = config;
     if (login)
     {
         Login();
     }
 }
コード例 #2
0
 public SalesforceClient(SalesforceConfig config, bool login = false)
 {
     _sessionStore = new MemoryCacheProvider();
     _config       = config;
     if (login)
     {
         Login();
     }
 }
コード例 #3
0
ファイル: SDKManager.cs プロジェクト: hunsakerjeff/mcdsa
        public static T InitializeConfig <T>(EncryptionSettings settings) where T : SalesforceConfig
        {
            Encryptor.init(settings);
            T config = SalesforceConfig.RetrieveConfig <T>() ?? Activator.CreateInstance <T>();

            config.SaveConfig();
            ServerConfiguration = config;
            return(config);
        }
コード例 #4
0
 public virtual void ChangeEnvironment(SalesforceConfig config, bool login = false, SecurityProtocolType securityProtocol = SecurityProtocolType.Tls11)
 {
     ServicePointManager.SecurityProtocol = securityProtocol;
     _config = config;
     if (login)
     {
         Login();
     }
 }
コード例 #5
0
 public SalesforceStreamingService(
     ILogger <SalesforceStreamingService> logger, IApplicationLifetime appLifetime,
     IOptions <SalesforceConfig> sfOptions, SalesforceClient salesforceClient)
 {
     this.logger           = logger;
     this.appLifetime      = appLifetime;
     this.salesforceClient = salesforceClient;
     this.sfOptions        = sfOptions.Value;
 }
コード例 #6
0
 public SalesforceClient(ILogger logger, SalesforceConfig config)
 {
     this.Logger     = logger;
     this.SfdcConfig = config;
     if (String.IsNullOrEmpty(Bearer))
     {
         Authorize();
     }
 }
コード例 #7
0
 public SalesforceClient(ISessionStoreProvider sessionStore, SalesforceConfig config, bool login = false)
 {
     _sessionStore = sessionStore;
     _config       = config;
     if (login)
     {
         Login();
     }
 }
コード例 #8
0
        private void addAccount_Click(object sender, RoutedEventArgs e)
        {
            SalesforceApplication.ServerConfiguration.SetSelectedServer(listboxServers.SelectedIndex);
            SalesforceApplication.ResetClientManager();
            ServerSetting    server  = listboxServers.SelectedItem as ServerSetting;
            SalesforceConfig config  = SalesforceApplication.ServerConfiguration;
            LoginOptions     options = new LoginOptions(server.ServerHost, config.ClientId, config.CallbackUrl, config.Scopes);

            StartLoginFlow(options);
        }
コード例 #9
0
        protected void CreateClientManager(bool reset)
        {
            if (GlobalClientManager == null || reset)
            {
                ServerConfiguration = InitializeConfig();
                GlobalClientManager = new ClientManager();
            }

            GlobalClientManager.GetRestClient();
        }
コード例 #10
0
 private void StartLoginFlow(ServerSetting server)
 {
     if (server != null)
     {
         VisualStateManager.GoToState(this, LoggingUserInViewState, true);
         SDKManager.ResetClientManager();
         SalesforceConfig config = SDKManager.ServerConfiguration;
         var options             = new LoginOptions(server.ServerHost, config.ClientId, config.CallbackUrl, config.Scopes);
         SalesforceConfig.LoginOptions = new LoginOptions(server.ServerHost, config.ClientId, config.CallbackUrl,
                                                          config.Scopes);
         DoAuthFlow(options);
     }
 }
コード例 #11
0
 private void StartLoginFlow(ServerSetting server)
 {
     if (server != null)
     {
         VisualStateManager.GoToState(this, LoggingUserInViewState, true);
         SDKManager.ResetClientManager();
         SalesforceConfig config        = SDKManager.ServerConfiguration;
         var clientId                   = config.GetClientIdForServer(server);
         var callbackUrl                = config.GetCallbackUrlForServer(server);
         var brokerOptions              = config.GetOptionsForServer(server);
         var useTwoParamAuthAsyncMethod = config.GetUseTwoParamAuthAsyncMethodForServer(server);
         var options = new LoginOptions(server.ServerHost, clientId, callbackUrl, config.Scopes, brokerOptions, useTwoParamAuthAsyncMethod);
         SalesforceConfig.LoginOptions = new LoginOptions(server.ServerHost, clientId, callbackUrl, config.Scopes, brokerOptions, useTwoParamAuthAsyncMethod);
         DoAuthFlow(options);
     }
 }
コード例 #12
0
        protected override SalesforceConfig InitializeConfig()
        {
            EncryptionSettings settings = new EncryptionSettings(new HmacSHA256KeyGenerator())
            {
                Password = "******",
                Salt     = "mysalt"
            };

            Encryptor.init(settings);
            Config config = SalesforceConfig.RetrieveConfig <Config>();

            if (config == null)
            {
                config = new Config();
            }
            return(config);
        }
コード例 #13
0
        protected override Salesforce.SDK.Source.Settings.SalesforceConfig InitializeConfig()
        {
            EncryptionSettings settings = new EncryptionSettings(new HmacSHA256KeyGenerator())
            {
                Password = "******",
                Salt     = "friesaresaltyforsure"
            };

            Encryptor.init(settings);
            Config config = SalesforceConfig.RetrieveConfig <Config>();

            if (config == null)
            {
                config = new Config();
            }
            return(config);
        }
コード例 #14
0
        protected override Task UpgradeConfigAsync()
        {
            if (!ApplicationData.Current.Version.Equals(0))
            {
                return(Task.CompletedTask);
            }
            var config = SalesforceConfig.RetrieveConfig <Config>().Result;

            if (config == null)
            {
                return(Task.CompletedTask);
            }
            Encryptor.init(new EncryptionSettings(new HmacSHA256KeyGenerator(HashAlgorithmNames.Md5)));
            config = SDKManager.InitializeConfigAsync <Config>().Result;
            Encryptor.ChangeSettings(
                new EncryptionSettings(new HmacSHA256KeyGenerator(HashAlgorithmNames.Sha256)));
            return(config.SaveConfigAsync());
        }
コード例 #15
0
        internal static HttpRequest GetLoginRequest(SalesforceConfig config)
        {
            string domain = !string.IsNullOrEmpty(config.InstanceUrl)
                ? config.InstanceUrl
                : config.IsSandbox ? "https://test.salesforce.com" : "https://login.salesforce.com";

            HttpRequest request = new HttpRequest
            {
                Url    = GetSoapUrl(domain, config.ApiVersion),
                Body   = SoapCommands.Login(config.Username, config.Password + config.SecurityToken),
                Method = RequestType.POST,
                Proxy  = config.Proxy
            };

            request.Headers.Add("SOAPAction", "login");

            return(request);
        }
コード例 #16
0
        public static async Task <T> InitializeConfigAsync <T>() where T : SalesforceConfig
        {
            T config = await SalesforceConfig.RetrieveConfig <T>();

            if (config == null)
            {
                config = Activator.CreateInstance <T>();
                await config.InitializeAsync();
            }

            if (config.ServerList == null)
            {
                config.ServerList = new System.Collections.ObjectModel.ObservableCollection <ServerSetting>();
            }

            await config.SaveConfigAsync();

            ServerConfiguration = config;
            return(config);
        }
コード例 #17
0
        private void SetupAccountPage()
        {
            ResourceLoader   loader       = ResourceLoader.GetForCurrentView("Salesforce.SDK.Core/Resources");
            SalesforceConfig config       = SDKManager.ServerConfiguration;
            bool             titleMissing = true;

            if (!String.IsNullOrWhiteSpace(config.ApplicationTitle) && config.IsApplicationTitleVisible)
            {
                ApplicationTitle.Visibility = Visibility.Visible;
                ApplicationTitle.Text       = config.ApplicationTitle;
                titleMissing = false;
            }
            else
            {
                ApplicationTitle.Visibility = Visibility.Collapsed;
            }

            if (config.LoginBackgroundLogo != null)
            {
                if (ApplicationLogo.Items != null)
                {
                    ApplicationLogo.Items.Clear();
                    ApplicationLogo.Items.Add(config.LoginBackgroundLogo);
                }
                if (titleMissing)
                {
                    var padding = new Thickness(10, 24, 10, 24);
                    ApplicationLogo.Margin = padding;
                }
            }

            // set background from config
            if (config.LoginBackgroundColor != null)
            {
                var background = new SolidColorBrush((Color)config.LoginBackgroundColor);
                PageRoot.Background = background;
                Background          = background;
                // ServerFlyoutPanel.Background = background;
                //  AddServerFlyoutPanel.Background = background;
            }

            // set foreground from config
            if (config.LoginForegroundColor != null)
            {
                var foreground = new SolidColorBrush((Color)config.LoginForegroundColor);
                Foreground = foreground;
                ApplicationTitle.Foreground   = foreground;
                LoginToSalesforce.Foreground  = foreground;
                LoginToSalesforce.BorderBrush = foreground;
                ChooseConnection.Foreground   = foreground;
                ChooseConnection.BorderBrush  = foreground;
            }

            if (Accounts == null || Accounts.Length == 0)
            {
                _currentState = SingleUserViewState;
                SetLoginBarVisibility(Visibility.Collapsed);
                VisualStateManager.GoToState(this, SingleUserViewState, true);
            }
            else
            {
                _currentState = MultipleUserViewState;
                SetLoginBarVisibility(Visibility.Visible);
                ListTitle.Text = loader.GetString("select_account");
                VisualStateManager.GoToState(this, MultipleUserViewState, true);
            }
            ListboxServers.ItemsSource     = Servers;
            AccountsList.ItemsSource       = Accounts;
            ServerFlyout.Opening          += ServerFlyout_Opening;
            ServerFlyout.Closed           += ServerFlyout_Closed;
            AddServerFlyout.Opened        += AddServerFlyout_Opened;
            AddServerFlyout.Closed        += AddServerFlyout_Closed;
            AccountsList.SelectionChanged += accountsList_SelectionChanged;
            ListboxServers.SelectedValue   = null;
            HostName.PlaceholderText       = LocalizedStrings.GetString("name");
            HostAddress.PlaceholderText    = LocalizedStrings.GetString("address");
            AddConnection.Visibility       = (SDKManager.ServerConfiguration.AllowNewConnections
                ? Visibility.Visible
                : Visibility.Collapsed);
        }
コード例 #18
0
 public SalesforceClient(HttpClient httpClient, IOptions <SalesforceConfig> configurationOptions)
 {
     client             = httpClient;
     this.configuration = configurationOptions.Value;
 }
コード例 #19
0
 public SalesforceClient(SalesforceConfig config, bool login = false, SecurityProtocolType securityProtocol = SecurityProtocolType.Tls11)
     : this(new MemoryCacheProvider(), config, login, securityProtocol)
 {
 }
コード例 #20
0
        protected void CreateClientManager(bool reset)
        {
            if (GlobalClientManager == null || reset)
            {
                ServerConfiguration = InitializeConfig();
                GlobalClientManager = new ClientManager();
            }

            GlobalClientManager.GetRestClient();
        }
コード例 #21
0
 public SalesforceClient(ISessionStoreProvider sessionStore, SalesforceConfig config, bool login = false, SecurityProtocolType securityProtocol = SecurityProtocolType.Tls11)
 {
     _sessionStore = sessionStore;
     this.ChangeEnvironment(config, login, securityProtocol);
 }