Esempio n. 1
0
        private Button CreateSaveButton(Control parent)
        {
            var b = new Button {
                Text = "Save"
            };

            b.Click += (sender, args) =>
            {
                if (FilterCollection.Count > 1)
                {
                    var result = PasswordInputBox.GetPassword(parent, "Master Password");
                    if (!string.IsNullOrEmpty(result))
                    {
                        using (var password = new SecureStringOrArray(Encoding.ASCII.GetBytes(result)))
                        {
                            var folderBasedFilePathProvider = new FolderBasedFilePathProvider(".");
                            var localSecureFileRepository   = new LocalSecureFileRepository(folderBasedFilePathProvider, "muipw.iv", DataFileName, "muipw.ver", "muipw.salt");
                            var aesFormatter = new AesFormatter(localSecureFileRepository);

                            try
                            {
                                //just test that the password is correct by deserializing the current data.
                                var credentialSet = aesFormatter.DeserializeData <CredentialSet>(password);
                                _secretKeyProvider.Initialize(credentialSet.Credentials);
                                _secretKeyProvider.Initialize(FilterCollection);
                                var mSecretsSecretKey = _secretKeyProvider.GetSecret(SecretKeyConstants.MSecretsSecretKeyName);
                                if (mSecretsSecretKey == null)
                                {
                                    MessageBox.Show($"Missing {SecretKeyConstants.MSecretsSecretKeyName}!");
                                    return;
                                }
                                var fileBroker2 = SecureFileBroker.Create(folderBasedFilePathProvider, mSecretsSecretKey, "muipw.iv", DataFileName, "muipw.ver", "muipw.salt");
                                aesFormatter = new AesFormatter(fileBroker2);

                                var set = new CredentialSet();
                                foreach (var credential in FilterCollection)
                                {
                                    set.Credentials.Add(credential);
                                }
                                aesFormatter.SerializeData(password, set);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Incorrect password!");
                            }
                        }
                    }
                }
            };
            return(b);
        }
Esempio n. 2
0
        public IAmazonS3 GetS3Client()
        {
            var s3FilesPrivateKey = _secretKeyProvider.GetSecret(SecretKeyConstants.S3FilesPrivateKeyName);

            if (s3FilesPrivateKey == null)
            {
                return(null);
            }
            return(GetS3Client(s3FilesPrivateKey));
        }
Esempio n. 3
0
        protected string GetSecretValue(string attribute)
        {
            if (string.IsNullOrEmpty(_vaultValue))
            {
                _vaultValue = _secretKeyProvider.GetSecret(_vaultName);
            }

            var jsonObj = JObject.Parse(_vaultValue);

            return((string)jsonObj[attribute]);
        }
Esempio n. 4
0
        public LoggerService(ISecretKeyProvider secretKeyProvider, string vaultName) : base(secretKeyProvider, vaultName)
        {
            LoggerConfiguration loggerConfiguration = new LoggerConfiguration();

#if DEBUG
            loggerConfiguration.WriteTo.File("C:\\temps\\azure.txt", rollingInterval: RollingInterval.Day);
#else
            var appInsightKey = secretKeyProvider.GetSecret(vaultName);

            loggerConfiguration.WriteTo.ApplicationInsightsTraces(appInsightKey);
#endif
            Log.Logger = loggerConfiguration.Enrich.With <HttpRequestIdEnricher>().CreateLogger();
        }
 public LoginController(IMapper mapper, ISecretKeyProvider secretKeyProvider,
                        ILoggerService loggerService, IUserRepository userRepository) : base(mapper, loggerService)
 {
     _secretAuthKey  = secretKeyProvider.GetSecret(AzureKeys.AuthTokenKey);
     _userRepository = userRepository;
 }
Esempio n. 6
0
 public TokenValidationHandler(ISecretKeyProvider secretKeyProvider)
 {
     _secretKeyProvider = secretKeyProvider;
     _secretAuthKey     = _secretKeyProvider.GetSecret(AzureKeys.AuthTokenKey);
 }