public UserConfigurationProvider(IUserInputProvider inputProvider, IConfigurationValueProvider provider)
        {
            _inputProvider = inputProvider;
            var fileName = provider.Get(ConfigurationConstants.UserConfigFileKey) ?? ConfigurationConstants.DefaultUserConfigFileName;

            _userConfigurationProvider = new UserConfigurationValueProvider(fileName);
        }
        public SendingManager(
            IUserInputProvider inputProvider,
            IConfigurationProvider <UserConfiguration> userConfigurationProvider,
            IConfigurationProvider <ServerConfiguration> serverConfigurationProvider,
            ISelectedProblemProvider selectedProblemProvider,
            IUnsolvedProblemProvider unsolvedProblemProvider,
            ISolutionSender sender)
        {
            _inputProvider               = inputProvider;
            _userConfigurationProvider   = userConfigurationProvider;
            _serverConfigurationProvider = serverConfigurationProvider;
            _selectedProblemProvider     = selectedProblemProvider;
            _unsolvedProblemProvider     = unsolvedProblemProvider;
            _sender = sender;

            _settingMenu = new []
            {
                new MenuItem(Resources.SendCurrentlySelected, ContinueAsync),
                new MenuItem(Resources.ChangeCurrentProblem, ChangeCurrentProblemAsync),
                new MenuItem(Resources.ChangeUserSettings, ChangeUserSettingsAsync),
                new MenuItem(Resources.ChangeServerSettings, ChangeServerSettingsAsync),
                new MenuItem(Resources.SendAllUnsolved, SendAllUnsolvedAsync),
                new MenuItem(Resources.ClearSolvedProblemsRecords, ClearSolvedProblemsRecordsAsync),
                new MenuItem(Resources.SendAllSolutions, SendAllSolutionsAsync)
            };
        }
 public RmiProdClrProjectGenerator(IConsoleWriter consoleWriter, IFileGenerator fileGenerator, IUserInputProvider userInputProvider, IVariableProvider variableProvider)
 {
     _consoleWriter     = consoleWriter;
     _fileGenerator     = fileGenerator;
     _userInputProvider = userInputProvider;
     _variableProvider  = variableProvider;
 }
 public SelectedProblemProvider(IUserInputProvider inputProvider, ISolverProvider solverProvider, IConfigurationValueProvider provider, SolvedConfigurationProvider solvedConfigurationProvider)
 {
     _inputProvider               = inputProvider;
     _configurationProvider       = provider;
     _solvedConfigurationProvider = solvedConfigurationProvider;
     _solverProvider              = solverProvider;
 }
Exemple #5
0
 public GenerationSteps(IUserInputProvider userInputProvider, IExecutingPluginAssemblyProvider assemblyProvider, ITools tools, ITimeKeeper timeKeeper, IConsoleWriter consoleWriter, IExceptionFormatter exceptionFormatter)
 {
     _userInputProvider  = userInputProvider;
     _assemblyProvider   = assemblyProvider;
     _tools              = tools;
     _timeKeeper         = timeKeeper;
     _consoleWriter      = consoleWriter;
     _exceptionFormatter = exceptionFormatter;
 }
        public LogoutUserCommand(IMotorSystemContext context, IUserInputProvider userInputProvider, IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(userInputProvider, "userInputProvider").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.context           = context;
            this.userInputProvider = userInputProvider;
            this.memCache          = memCache;
        }
 public GeneratorCommandBuilder(
     IEnumerable <IMetaGenerator> generators,
     IPluginSelection pluginSelection,
     IUserInputProvider userInputProvider,
     IExecutingPluginAssemblyProvider executingPluginAssemblyProvider)
 {
     _generators        = generators;
     _pluginSelection   = pluginSelection;
     _userInputProvider = userInputProvider;
     _executingPluginAssemblyProvider = executingPluginAssemblyProvider;
 }
 /// <summary>
 /// Creates new account service instance
 /// </summary>
 /// <param name="userInputProvider">input provider</param>
 /// <param name="profilesDir">folder path where keystore files are stored</param>
 public KeyStoreProfileService(IUserInputProvider userInputProvider, string profilesDir = null)
 {
     UserInputProvider = userInputProvider;
     if (profilesDir != null)
     {
         ProfilesDir = profilesDir;
     }
     else
     {
         ProfilesDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Hoard", "Profiles");
     }
 }
        public LoginUserCommand(IUserInputProvider userInputProvider, IMotorSystemContext context,
                                IHelperMethods helpers, IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(userInputProvider, "userInputProvider").IsNull().Throw();
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(helpers, "helpers").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.userInputProvider = userInputProvider;
            this.context           = context;
            this.helpers           = helpers;
            this.memCache          = memCache;
        }
Exemple #10
0
 public MetaGeneratorProjectPluginGenerator(
     IConsoleWriter consoleWriter,
     IFileGenerator fileGenerator,
     IFileManipulator fileManipulator,
     IUserInputProvider userInputProvider,
     IVariableProvider variableProvider)
 {
     _consoleWriter     = consoleWriter;
     _fileGenerator     = fileGenerator;
     _fileManipulator   = fileManipulator;
     _userInputProvider = userInputProvider;
     _variableProvider  = variableProvider;
 }
Exemple #11
0
        /// <summary>
        /// Loads account information for the user
        /// </summary>
        /// <param name="userInputProvider">Provider with user credentials</param>
        /// <param name="filename">filename of the file with account to load</param>
        /// <param name="profilesDir">folder where the key store files are stored</param>
        /// <returns>description making an account</returns>
        public static async Task <ProfileDesc> LoadProfile(IUserInputProvider userInputProvider, string filename, string profilesDir)
        {
            if (!Directory.Exists(profilesDir))
            {
                throw new HoardException(string.Format("Profile doesn't exists: {0:1}", profilesDir, filename));
            }

            var profileFiles = Directory.GetFiles(profilesDir, filename);

            if (profileFiles.Length == 0)
            {
                throw new HoardException(string.Format("Profile doesn't exists: {0:1}", profilesDir, filename));
            }
            ErrorCallbackProvider.ReportInfo(string.Format("Loading profiles {0}", profileFiles[0]));

            string json = null;

            using (var reader = File.OpenText(profileFiles[0]))
            {
                json = await reader.ReadToEndAsync();
            }
            var details = JObject.Parse(json);

            if (details == null)
            {
                throw new HoardException(string.Format("Can't parse json: {0}", json));
            }

            string address = details["address"].Value <string>();
            string name    = "";

            if (details["name"] != null)
            {
                name = details["name"].Value <string>();
            }
            string password = await userInputProvider.RequestInput(name, new HoardID(address), eUserInputType.kPassword, address);

            var keyStoreService = new Nethereum.KeyStore.KeyStoreService();

            Nethereum.Signer.EthECKey key = null;

            try
            {
                key = new Nethereum.Signer.EthECKey(keyStoreService.DecryptKeyStoreFromJson(password, json), true);
                return(new ProfileDesc(name, key.GetPublicAddress(), key.GetPrivateKeyAsBytes()));
            }
            catch (Exception e)
            {
                throw new HoardException("Incorrect password", e);
            }
        }
        public async Task EncryptAndSaveCredentials(HoardID userID, IUserInputProvider credentials)
        {
            var pathToFile = PathToID(userID);
            var pass       = await credentials.RequestInput("Password", userID, eUserInputType.kPassword, "");

            var encrypted = EncryptPassword(userID, pass);

            using (var file = new StreamWriter(pathToFile, true))
            {
                var converted = await Task.Run(() => JsonConvert.SerializeObject(encrypted));

                await file.WriteAsync(converted);
            }
        }
 public LapPickerController(ITelemetryViewsSynchronization telemetryViewsSynchronization, ITelemetryLoadController telemetryLoadController, IMainWindowViewModel mainWindowViewModel, IViewModelFactory viewModelFactory,
                            IColorPaletteProvider colorPaletteProvider, IOpenWindowController openWindowController, ISettingsWindowController settingsWindowController, IUserInputProvider userInputProvider)
 {
     _allAvailableLaps = new List <LapSummaryDto>();
     _loadedLaps       = new List <LapSummaryDto>();
     _telemetryViewsSynchronization = telemetryViewsSynchronization;
     _telemetryLoadController       = telemetryLoadController;
     _lapSelectionViewModel         = mainWindowViewModel.LapSelectionViewModel;
     _viewModelFactory         = viewModelFactory;
     _colorPaletteProvider     = colorPaletteProvider;
     _openWindowController     = openWindowController;
     _settingsWindowController = settingsWindowController;
     _userInputProvider        = userInputProvider;
 }
        public CreateUserCommand(IMotorSystemContext context, IUserInputProvider user, IModelFactory userModel,
                                 IMemoryCacheProvider memCache, IHelperMethods helpers)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(user, "user").IsNull().Throw();
            Guard.WhenArgument(userModel, "userModel").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();
            Guard.WhenArgument(helpers, "helpers").IsNull().Throw();

            this.context      = context;
            this.user         = user;
            this.modelFactory = userModel;
            this.memCache     = memCache;
            this.helpers      = helpers;
        }
Exemple #15
0
 public MesserliOneRepositoryPluginGenerator(
     IConsoleWriter consoleWriter,
     IFileGenerator fileGenerator,
     IUserInputProvider userInputProvider,
     ISolutionLoader solutionLoader,
     ITargetFrameworkProvider targetFrameworkProvider,
     ITools tools)
 {
     _consoleWriter           = consoleWriter;
     _fileGenerator           = fileGenerator;
     _userInputProvider       = userInputProvider;
     _solutionLoader          = solutionLoader;
     _targetFrameworkProvider = targetFrameworkProvider;
     _tools = tools;
 }
 public ManagedWrapperProjectsPluginGenerator(
     IConsoleWriter consoleWriter,
     IFileGenerator fileGenerator,
     IFileManipulator fileManipulator,
     IUserInputProvider userInputProvider,
     IVariableProvider variableProvider,
     IPathProvider pathProvider,
     ITools tools)
 {
     _consoleWriter     = consoleWriter;
     _fileGenerator     = fileGenerator;
     _fileManipulator   = fileManipulator;
     _userInputProvider = userInputProvider;
     _variableProvider  = variableProvider;
     _pathProvider      = pathProvider;
     _tools             = tools;
 }
Exemple #17
0
 public NativeProjectsPluginGenerator(
     IConsoleWriter consoleWriter,
     IFileGenerator fileGenerator,
     IFileManipulator fileManipulator,
     IUserInputProvider userInputProvider,
     IVariableProvider variableProvider,
     IProjectInformation projectInformation,
     ITfsPaths tfsPaths,
     ITools tools)
 {
     _consoleWriter      = consoleWriter;
     _fileGenerator      = fileGenerator;
     _fileManipulator    = fileManipulator;
     _userInputProvider  = userInputProvider;
     _variableProvider   = variableProvider;
     _projectInformation = projectInformation;
     _tfsPaths           = tfsPaths;
     _tools = tools;
 }
Exemple #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userInputProvider"></param>
        /// <param name="id"></param>
        /// <param name="profilesDir"></param>
        /// <param name="passwordNeeded"></param>
        /// <returns></returns>
        public static async Task DeleteProfile(IUserInputProvider userInputProvider, HoardID id, string profilesDir, bool passwordNeeded)
        {
            if (!Directory.Exists(profilesDir))
            {
                throw new HoardException(string.Format("Profile doesn't exists: {0}", id.ToString()));
            }

            string[] files           = Directory.GetFiles(profilesDir, "*.keystore");
            var      keyStoreService = new Nethereum.KeyStore.KeyStoreService();

            foreach (string file in files)
            {
                StreamReader jsonReader = new StreamReader(file);
                JObject      jobj       = JObject.Parse(jsonReader.ReadToEnd());
                jsonReader.Close();
                JToken valueAddress;
                if (jobj.TryGetValue("address", out valueAddress))
                {
                    HoardID actualId = new HoardID(valueAddress.Value <string>());
                    if (id == actualId)
                    {
                        Nethereum.Signer.EthECKey key = null;
                        if (passwordNeeded)
                        {
                            string password = await userInputProvider.RequestInput(null, id, eUserInputType.kPassword, valueAddress.Value <string>());

                            try
                            {
                                key = new Nethereum.Signer.EthECKey(keyStoreService.DecryptKeyStoreFromJson(password, jobj.ToString()), true);
                            }
                            catch (Exception e)
                            {
                                throw new HoardException("Incorrect password", e);
                            }
                        }
                        File.Delete(file);
                        return;
                    }
                }
            }

            throw new HoardException(string.Format("Profile doesn't exists: {0}", id.ToString()));
        }
Exemple #19
0
 public EthTrezorWallet(IDevice hidDevice, string derivationPath, IUserInputProvider pinInputProvider)
     : base(hidDevice, derivationPath, pinInputProvider)
 {
 }
 public void SetProvider(IUserInputProvider inputProvider)
 {
     // ...meh...
 }
Exemple #21
0
 public ServerConfigurationProvider(IUserInputProvider inputProvider, IConfigurationValueProvider configurationValueProvider)
 {
     _inputProvider = inputProvider;
     _valueProvider = configurationValueProvider;
 }
Exemple #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userInputProvider"></param>
        /// <param name="addressOrName"></param>
        /// <param name="profilesDir"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static async Task <ProfileDesc> RequestProfile(IUserInputProvider userInputProvider, string addressOrName, string profilesDir, string password = null)
        {
            if (!Directory.Exists(profilesDir))
            {
                throw new HoardException(string.Format("Profile doesn't exists: {0}", addressOrName));
            }

            var profileFiles = Directory.GetFiles(profilesDir, "*.keystore");

            if (profileFiles.Length == 0)
            {
                throw new HoardException(string.Format("Profile doesn't exists: {0}", addressOrName));
            }

            string providedAddress = addressOrName;

            if (!providedAddress.StartsWith("0x"))
            {
                providedAddress = "0x" + providedAddress;
            }
            bool isValidAddress = Nethereum.Util.AddressUtil.Current.IsValidEthereumAddressHexFormat(providedAddress);

            if (isValidAddress == false)
            {
                throw new HoardException(string.Format("{0} is not a valid ethereum address", providedAddress));
            }

            foreach (var fullPath in profileFiles)
            {
                string fileName = Path.GetFileName(fullPath);
                if ((fileName != null) && (fileName != System.String.Empty))
                {
                    string json    = File.ReadAllText(fullPath);
                    var    details = JObject.Parse(json);
                    if (details == null)
                    {
                        continue;
                    }
                    string address     = details["address"].Value <string>();
                    string profileName = "";
                    if (details["name"] != null)
                    {
                        profileName = details["name"].Value <string>();
                    }
                    if (((isValidAddress == true) && (address == providedAddress)) || ((isValidAddress == false) && (profileName == addressOrName)))
                    {
                        ErrorCallbackProvider.ReportInfo(string.Format("Loading account {0}", fileName));
                        string pswd = null;
                        if (password == null)
                        {
                            pswd = await userInputProvider.RequestInput(profileName, new HoardID(address), eUserInputType.kPassword, address);
                        }
                        else
                        {
                            pswd = password;
                        }
                        var keyStoreService           = new Nethereum.KeyStore.KeyStoreService();
                        Nethereum.Signer.EthECKey key = null;
                        try
                        {
                            key = new Nethereum.Signer.EthECKey(keyStoreService.DecryptKeyStoreFromJson(pswd, json), true);
                            return(new ProfileDesc(profileName, key.GetPublicAddress(), key.GetPrivateKeyAsBytes()));
                        }
                        catch (Exception e)
                        {
                            throw new HoardException("Incorrect password", e);
                        }
                    }
                }
            }

            throw new HoardException(string.Format("Failed to request profile: {0}", providedAddress));
        }
 public ProjectInformation(IUserInputProvider userInputProvider)
 {
     _userInputProvider = userInputProvider;
 }
Exemple #24
0
 public GameRunner(IGameManager gameManager, IGamePrinter gamePrinter, IUserInputProvider userInputProvider)
 {
     _gameManager       = gameManager ?? throw new ArgumentNullException(nameof(gameManager));
     _gamePrinter       = gamePrinter ?? throw new ArgumentNullException(nameof(gamePrinter));
     _userInputProvider = userInputProvider ?? throw new ArgumentNullException(nameof(userInputProvider));
 }
 /// <summary>
 /// Creates new instance of LedgerWallet base class
 /// </summary>
 /// <param name="hidDevice">HID device accessor</param>
 /// <param name="derivationPath">path name for specific wallet</param>
 /// <param name="_pinInputProvider">provider for PIN</param>
 protected TrezorWallet(IDevice hidDevice, string derivationPath, IUserInputProvider _pinInputProvider)
 {
     HIDDevice        = hidDevice;
     DerivationPath   = derivationPath;
     pinInputProvider = _pinInputProvider;
 }
        /// <summary>
        /// Creates instance of Trezor Wallet based on the derivation path
        /// </summary>
        /// <param name="derivationPath">Indicates which wallet to get (use this in form of URL)</param>
        /// <param name="pinInputProvider">user input provider used to get PIN or password from user</param>
        /// <returns></returns>
        public static async Task <TrezorWallet> GetTrezorWalletAsync(string derivationPath, IUserInputProvider pinInputProvider = null)
        {
            var hidDevice = await Helpers.GetHIDDeviceAsync(DeviceInfo, UsageSpecification);

            if (hidDevice != null)
            {
                var wallet = new EthTrezorWallet(hidDevice, derivationPath, pinInputProvider);
                await wallet.InitializeAsync();

                return(wallet);
            }
            return(null);
        }
        public void SetProvider(IUserInputProvider inputProvider)
        {
            if(inputProvider == null) throw new ArgumentNullException("inputProvider");

            this.UserInputProvider = inputProvider;
        }