Esempio n. 1
0
 public Database(string basePath, UserStorageBase userStorage)
 {
     if (basePath == null)
         throw new ArgumentNullException ("basePath");
     if (userStorage == null)
         throw new ArgumentNullException ("userStorage");
     this.basePath = basePath;
     this.userStorage = userStorage;
     this.frontends = new SortedDictionary<string, FrontendBase> ();
     encryptedStorageManager = new EncryptedStorageManager (userStorage);
 }
Esempio n. 2
0
 public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, UserStorageBase userStorage, IEnumerable<byte[]> users)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
 }
Esempio n. 3
0
File: Program.cs Progetto: vebin/BD2
 public static void Main(string[] args)
 {
     if (args.Length == 1)
         foreach (string str in System.IO.File.ReadAllLines (args[0]))
             initial.Enqueue (str);
     SortedDictionary<int, System.Threading.Thread> jobs = new SortedDictionary<int, System.Threading.Thread> ();
     Modifiers.Add ("async");
     //BD2.Core.Database DB = new BD2.Core.Database ();
     string command;
     do {
         command = Query ("Command>");
         if (command == null)
             return;
         OffsetedArray<string> commandparts = command.Split (' ');
         string[] CommandParts = (string[])((string[])commandparts).Clone ();
         commandparts.Offset = ExtractModifiers (CommandParts);
         SortedSet<string> CommandModifiers = new SortedSet<string> (commandparts.GetStrippedPart ());
         switch (CommandParts [0]) {
         case "Open":
             {
                 UR = new LocalUserStorage (new DatabasePath (Query ("path")), new UserStorageConfiguration ());
             }
             break;
         case "CreateAdmin":
             {
                 string name = Query ("name");
                 string password = Query ("Password");
                 string pepper = Query ("Pepper");
                 UR.CreateUser (name, password, pepper, null);
             }
             break;
         case "Create":
             {
                 string name = Query ("name");
                 string password = Query ("Password");
                 string pepper = (Query ("Pepper"));
                 byte[] parentID;
                 parentID = HexStringToByteArray (Query ("Parent").Replace (" ", "").Replace (":", ""));
                 UR.CreateUser (name, password, pepper, parentID);
             }
             break;
         case "List":
             foreach (var U in UR.GetUsers ()) {
                 Console.WriteLine ("{0}:{1}", U.Key.ToHexadecimal (), U.Value);
                 var P = UR.GetUserParent (U.Key);
                 if (P != null)
                     Console.WriteLine ("parent:{0}", P.ToHexadecimal ());
                 foreach (var R in UR.GetUserRepositories (U.Key)) {
                     Console.WriteLine ("repository:{0}", R.ToHexadecimal ());
                 }
                 Console.WriteLine ();
             }
             break;
         case "Exit":
             return;
         default:
             Console.Error.WriteLine (string.Format ("{0} is not a valid command.", CommandParts [0]));
             break;
         }
     } while(true);
 }