Esempio n. 1
0
 private void AddAllowedClientNetwork(Network network)
 {
     using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForReading))
     {
         foreach (SC.Security.Network net in clients)
         {
             if (net.IsHostInNet(network.Address) || network.IsHostInNet(net.Address))
             {
                 Logger.Error("Network add failed because network " + network.ToString() + " is contained in " + net.ToString());
                 throw new ArgumentException("Cannot add network because it contains or is contained in another network: " + net.ToString());
             }
         }
         l.UpgradeToWriterLock();
         Logger.Info("Adding network " + network.ToString() + " to the access list.");
         clients.Add(network);
     }
 }
Esempio n. 2
0
        public void RemoveAllowedClientNetwork(SC.Interfaces.INetwork network)
        {
            SC.Security.Network net = new Network(network.Address, network.Netmask);

            DemandAdministratorPermissions();
            using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForWriting))
            {
                if (!clients.Remove(net))
                {
                    Logger.Error("Removal of network " + net.ToString() + " failed because it is not in the access list.");
                    throw new ArgumentException("Given network is not present in list");
                }
                Logger.Info("Network " + net.ToString() + " was removed from the access list.");
            }
        }