Esempio n. 1
0
 public bool CanRead(Session sess, File item)
 {
     if (sess.CurrentUser == this.RootUser)
     {
         return true;
     }
     return item.CanView(sess.CurrentUser);
 }
Esempio n. 2
0
 public void FSCreateDirectory(string name, Session sess)
 {
     Console.WriteLine(this.Parent.Name + "\\\\" + this.Name + " : Creating Directory : " + name);
     string[] items = name.Split('\\');
     File currentDir = this.RootFile;
     for (int i = 0; i < items.Length; i++)
     {
         currentDir = currentDir.GetDirectory(items[i], true, sess.CurrentUser);
     }
 }
Esempio n. 3
0
        public static void GenerateNetworks()
        {
            LocalHost = new ComputerSystem(LocalNetwork);
            LocalNetwork.AllSystems.Add(LocalHost);

            LocalSession = new Session(LocalHost.GetUser("Admin"));

            for (int i = 0; i < 5; i++)
            {
                Networks.Add(new Network());
            }
        }
 public static void GenerateBasicFilesystem(ComputerSystem sys, Session rootUser)
 {
     sys.FSCreateDirectory("Users", rootUser);
     for (int i = 0; i < Singiltons.rand.Next(100) + 40; i++)
     {
         sys.FSCreateFile("", GetRandomDLLName(), Singiltons.rand.Next(2000000), rootUser);
     }
     for (int i = 0; i < Singiltons.rand.Next(5) + 5; i++)
     {
         string exeName = GetRandom(EXENames);
         sys.FSCreateDirectory(exeName, rootUser);
         sys.FSCreateFile(exeName + "\\", exeName + ".exe", Singiltons.rand.Next(6000000), rootUser);
         for (int x = 0; x < Singiltons.rand.Next(4); x++)
         {
             sys.FSCreateFile(exeName + "\\", GetRandomDATName(), Singiltons.rand.Next(10000000), rootUser);
         }
     }
     sys.FSSweepPremissions("", true, sys.GetGroup("Admins"), new FilePremission(true, false), rootUser);
     sys.FSCreateDirectory("SystemStore", rootUser);
 }
Esempio n. 5
0
 public File FSGetDirectory(string name, Session sess)
 {
     string[] items = name.Split('\\');
     File currentDir = this.RootFile;
     for (int i = 0; i < items.Length - 1; i++)
     {
         File target = currentDir.GetDirectory(items[i], false, sess.CurrentUser);
         if (target != null)
         {
             currentDir = target;
         }
         else
         {
             throw new Exception("Directory not Found");
         }
     }
     return currentDir;
 }
Esempio n. 6
0
 public void FSCreateFile(string path, string name, int size, Session sess)
 {
     File currentDirectory = this.FSGetDirectory(path, sess);
     File newFile = new File(name, size, sess.CurrentUser);
     currentDirectory.Children.Add(newFile);
 }
Esempio n. 7
0
 public void FSSweepPremissions(File path, bool subdirectorys, UserGroup toJoin, FilePremission newPremission, Session sess)
 {
     foreach (File item in path.Children)
     {
         if (item.Directory)
         {
             if (!subdirectorys)
             {
                 continue;
             }
             this.FSSetPremission(item, toJoin, newPremission, sess);
             this.FSSweepPremissions(item, subdirectorys, toJoin, newPremission, sess);
         }
         else
         {
             this.FSSetPremission(item, toJoin, newPremission, sess);
         }
     }
 }
Esempio n. 8
0
 public void FSSweepPremissions(string path, bool subdirectorys, UserGroup toJoin, FilePremission newPremission, Session sess)
 {
     File rootBase;
     if (path == "")
     {
         rootBase = this.RootFile;
     }
     else
     {
         rootBase = this.FSGetDirectory(path, sess);
     }
     this.FSSetPremission(rootBase, toJoin, newPremission, sess);
     this.FSSweepPremissions(rootBase, subdirectorys, toJoin, newPremission, sess);
 }
Esempio n. 9
0
 public void FSSetPremission(File item, UserGroup toJoin, FilePremission newPremission, Session sess)
 {
     if (item.CanView(sess.CurrentUser))
     {
         if (item.GroupPremitions.ContainsKey(toJoin))
         {
             item.GroupPremitions[toJoin] = newPremission;
         }
         else
         {
             item.GroupPremitions.Add(toJoin, newPremission);
         }
     }
 }