Exemplo n.º 1
0
        public static HashDevice GetDeviceFromSerializedData(SerializedHashDevice serializedDevice)
        {
            var device = new HashDevice();

            device.DeviceName = serializedDevice.DeviceName;
            device.Condition  = serializedDevice.Condition;
            device.IpAddress  = serializedDevice.IpAddress;

            device.AllPrograms = ProgramUtil.GetAllProgramsFromSerializedData(serializedDevice.Programs);
            device.AllUsers    = SList.Create <HashUser>(serializedDevice.Users.Length);

            for (int i = 0; i < serializedDevice.Users.Length; i++)
            {
                var user = GetUserFromSerializedData(serializedDevice.Users[i]);
                SList.Add(device.AllUsers, user);
            }

            var defaultUser = new HashUser();

            defaultUser.Username = DEFAULT_USER_NAME;
            defaultUser.Password = DEFAULT_PASSWORD;

            SList.Add(device.AllUsers, defaultUser);

            device.FileSystem = FileSystem.GetFileSystemFromSerializedData(serializedDevice.FileSystem);

            return(device);
        }
Exemplo n.º 2
0
        public static void ChangeDevice(HashDevice newDevice, HashUser newUser)
        {
            DataHolder.DeviceData.CurrentDevice = newDevice;
            DataHolder.DeviceData.CurrentUser   = newUser;

            UpdateDeviceRelatedGUI();
        }
Exemplo n.º 3
0
        public static HashUser GetUserFromSerializedData(SerializedHashUser serializedUser)
        {
            DebugUtil.AssertContext(serializedUser == null, "Null user", serializedUser);

            var result = new HashUser();

            result.Username = serializedUser.UserName;
            result.Password = serializedUser.Password;
            return(result);
        }
Exemplo n.º 4
0
 public static bool TryFindUserByName(HashDevice device, string userName, out HashUser user)
 {
     user = FindUserByName(device, userName);
     return(user != null);
 }
Exemplo n.º 5
0
 public static bool AuthenticateUser(HashUser user, string passwordAttempt)
 {
     return(string.Equals(user.Password, passwordAttempt));
 }