public ProtocolsViewModel(Repositories.IConfigurationRepository ConfigurationRepository)
 {
     this.ConfigurationRepository = ConfigurationRepository;
     
     for (int i = 0; i < protocolMap.Count; i++)
     {
         var item = protocolMap[i];
         var id = i;
         var name = item.Item1;
         var enabled = item.Item2(this.ConfigurationRepository).Enabled;
         protocols.Add(new Protocol { ID = id, Name = name, Enabled = enabled });
     }
 }
        public ProtocolsViewModel(Repositories.IConfigurationRepository ConfigurationRepository)
        {
            this.ConfigurationRepository = ConfigurationRepository;

            for (int i = 0; i < protocolMap.Count; i++)
            {
                var item    = protocolMap[i];
                var id      = i;
                var name    = item.Item1;
                var enabled = item.Item2(this.ConfigurationRepository).Enabled;
                protocols.Add(new Protocol {
                    ID = id, Name = name, Enabled = enabled
                });
            }
        }
예제 #3
0
        public void Update(Repositories.IConfigurationRepository ConfigurationRepository)
        {
            var keys = ConfigurationRepository.Keys;

            try
            {
                //var cert = X509.LocalMachine.My.SubjectDistinguishedName.Find(SigningCertificate, false).First();
                var cert = X509.CurrentUser.My.SubjectDistinguishedName.Find(SigningCertificate, false).First();

                // make sure we can access the private key
                var pk = cert.PrivateKey;

                keys.SigningCertificate = cert;
            }
            catch (CryptographicException)
            {
                throw new ValidationException(string.Format(Resources.KeyConfigurationViewModel.NoReadAccessToPrivateKey, WindowsIdentity.GetCurrent().Name));
            }

            if (DecryptionCertificate == null)
            {
                keys.DecryptionCertificate = null;
            }
            else
            {
                try
                {
                    // var cert = X509.LocalMachine.My.SubjectDistinguishedName.Find(DecryptionCertificate, false).First();
                    var cert = X509.CurrentUser.My.SubjectDistinguishedName.Find(DecryptionCertificate, false).First();

                    // make sure we can access the private key
                    var pk = cert.PrivateKey;

                    keys.DecryptionCertificate = cert;
                }
                catch (CryptographicException)
                {
                    throw new ValidationException(string.Format(Resources.KeyConfigurationViewModel.NoReadAccessToPrivateKey, WindowsIdentity.GetCurrent().Name));
                }
            }

            keys.SymmetricSigningKey = SymmetricSigningKey;

            // updates key material config
            ConfigurationRepository.Keys = keys;
        }
        public void Update(Repositories.IConfigurationRepository ConfigurationRepository)
        {
            var keys = ConfigurationRepository.Keys;

            try
            {
                var cert = X509.LocalMachine.My.SubjectDistinguishedName.Find(SigningCertificate, false).First();

                // make sure we can access the private key
                var pk = cert.PrivateKey;

                keys.SigningCertificate = cert;
            }
            catch (CryptographicException)
            {
                throw new ValidationException(WindowsIdentity.GetCurrent().Name + " does not have read access to the private key of the signing certificate you selected (see http://technet.microsoft.com/en-us/library/ee662329.aspx).");
            }

            if (DecryptionCertificate == null)
            {
                keys.DecryptionCertificate = null;
            }
            else
            {
                try
                {
                    var cert = X509.LocalMachine.My.SubjectDistinguishedName.Find(DecryptionCertificate, false).First();

                    // make sure we can access the private key
                    var pk = cert.PrivateKey;

                    keys.DecryptionCertificate = cert;
                }
                catch (CryptographicException)
                {
                    throw new ValidationException(WindowsIdentity.GetCurrent().Name + " does not have read access to the private key of the signing certificate you selected (see http://technet.microsoft.com/en-us/library/ee662329.aspx).");
                }
            }

            keys.SymmetricSigningKey = SymmetricSigningKey;

            // updates key material config
            ConfigurationRepository.Keys = keys;
        }
예제 #5
0
 public void Update(Repositories.IConfigurationRepository configurationRepository)
 {
     new ProtocolsViewModel(configurationRepository).Update(this.Protocols);
 }
		public ConfigurationService(Repositories.IConfigurationRepository configurations)
		{
			_configurations = configurations;
		}