Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Nasname,Ip,Username,Secret,Port,Description,Lat,Long")] AccessPoints accessPoints)
        {
            if (id != accessPoints.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accessPoints);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccessPointsExists(accessPoints.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accessPoints));
        }
Ejemplo n.º 2
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = base.GetHashCode();
         if (InterfaceUri != null)
         {
             result = (result * 397) ^ InterfaceUri.GetHashCode();
         }
         if (Name != null)
         {
             result = (result * 397) ^ Name.GetHashCode();
         }
         result = (result * 397) ^ AutoUpdate.GetHashCode();
         if (Requirements != null)
         {
             result = (result * 397) ^ Requirements.GetHashCode();
         }
         result = (result * 397) ^ CapabilityLists.GetSequencedHashCode();
         if (AccessPoints != null)
         {
             result = (result * 397) ^ AccessPoints.GetHashCode();
         }
         return(result);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves access points and interfaces from the device and updates the view.
        /// </summary>
        private async Task DownloadAccessPointsAsync()
        {
            BusyStateManager.EnterBusy();
            BusyStateManager.SetMessage(SeverityType.Info, "Retrieving access points and interfaces.");

            /* Temporary store selected interface and access point so they can be restored after download. */
            Guid?  interfaceId = SelectedInterface?.Id;
            string profileName = SelectedAccessPoint?.ProfileName;
            string ssid        = SelectedAccessPoint?.Ssid;

            /* Scan and download access points and interfaces. */
            await _mainController.ScanNetworkAsync(TimeSpan.FromSeconds(_configurationProvider.Timeout),
                                                   CancellationToken.None);

            IEnumerable <AccessPoint> accessPoints = await _mainController.GetWiFiAccessPointsAsync();

            IEnumerable <Interface> interfaces = await _mainController.GetWiFiInterfacesAsync();

            if (accessPoints == default(IEnumerable <AccessPoint>) || interfaces == default(IEnumerable <Interface>))
            {
                AccessPoints = new ObservableCollection <AccessPoint>(Enumerable.Empty <AccessPoint>());
                WiFiAccessPointViewSource.Source = AccessPoints;
                Interfaces = new ObservableCollection <Interface>(Enumerable.Empty <Interface>());
            }
            else
            {
                /* User specified threshold is used to filter access points that meet this threshold. */
                AccessPoints = new ObservableCollection <AccessPoint>(accessPoints
                                                                      .Where(x => x.LinkQuality > _configurationProvider.Threshold));
                WiFiAccessPointViewSource.Source = AccessPoints;
                Interfaces = new ObservableCollection <Interface>(interfaces);
            }

            /* Restore selected interface and access point. */
            Interface   selectedInterface   = Interfaces.Where(x => x.Id == interfaceId).FirstOrDefault();
            AccessPoint selectedAccessPoint = default(AccessPoint);

            if (!string.IsNullOrEmpty(profileName))
            {
                selectedAccessPoint = AccessPoints.Where(x => x.Id == interfaceId &&
                                                         x.ProfileName == profileName).FirstOrDefault();
            }
            else if (!string.IsNullOrEmpty(ssid))
            {
                selectedAccessPoint = AccessPoints.Where(x => x.Id == interfaceId &&
                                                         x.Ssid.Equals(ssid, StringComparison.Ordinal)).FirstOrDefault();
            }

            SelectedInterface = selectedInterface == default(Interface) ?
                                Interfaces.FirstOrDefault() : selectedInterface;

            if (selectedAccessPoint != default(AccessPoint))
            {
                SelectedAccessPoint = selectedAccessPoint;
            }

            BusyStateManager.SetMessage(SeverityType.None);
            BusyStateManager.ExitBusy();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a Pairwise Master Key (PMK) to the access point with the specified BSSID.
 /// In WPA2, the PMK is derived from the access point BSSID and password and used to
 /// create other keys used in encryption.
 /// </summary>
 /// <param name="bssid">The BSSID of the access point.</param>
 /// <param name="ssid">The SSID of the access point.</param>
 /// <param name="password">The password of the access point.</param>
 public void AddPassword(PhysicalAddress bssid, string ssid, string password)
 {
     byte[] pmk =
         WPA2CryptographyTools.GeneratePairwiseMasterKey(password, ssid);
     if (AccessPoints.ContainsKey(bssid) == false)
     {
         AccessPoints[bssid] = new AccessPoint(bssid);
     }
     AccessPoints[bssid].PairwiseMasterKey = pmk;
 }
        public Patient(Biography biography = null, Physical body = null, Mental mind = null)
        {
            Biography    = biography ?? new Biography();
            Body         = body ?? new Physical();
            Mind         = mind ?? new Mental();
            AccessPoints = new AccessPoints();

            Flags = new PatientFlags();
            //_randomSeed = MagicRandomStaticThingy;
        }
        internal static void LoadToMongoDB()
        {
            try
            {
                _applicationLogs.WriteInformation("----LoadToMongoDB -> Process started-------");

                _client = new MongoClient("mongodb://localhost:27017");

                _database = _client.GetDatabase("AttendanceDB");
                _accessEventsCollection = _database.GetCollection <AccessEvent>("AccessEvents");
                _accessPointsCollection = _database.GetCollection <AccessPoint>("AccessPoints");

                _database            = _client.GetDatabase("EmployeeDB");
                _employeesCollection = _database.GetCollection <Employee>("Employees");

                _database = _client.GetDatabase("OperationalsDB");
                _departmentsCollection = _database.GetCollection <Department>("Departments");

                _database        = _client.GetDatabase("AuthDB");
                _usersCollection = _database.GetCollection <User>("Users");

                _applicationLogs.WriteInformation("Mongo Database loaded");
                _applicationLogs.WriteInformation($"Departments count:{Departments?.Count()}");
                foreach (var v in Departments)
                {
                    AddDepartment(v);
                }

                _applicationLogs.WriteInformation($"Employees count:{Employees?.Count()}");
                foreach (var v in Employees)
                {
                    AddEmployee(v);
                }

                _applicationLogs.WriteInformation($"AccessPoints count:{AccessPoints?.Count()}");
                foreach (var v in AccessPoints)
                {
                    AddAccessPoint(v);
                }

                _applicationLogs.WriteInformation($"MonthlyAccessLogs count:{MonthlyAccessLogs?.Count()}");
                foreach (var v in MonthlyAccessLogs)
                {
                    foreach (var e in v.AccessEvents)
                    {
                        AddAccessLog(e);
                    }
                }
                _applicationLogs.WriteInformation($"----LoadToMongoDB -> Process completed----");
            }
            catch (Exception ex)
            {
                _applicationLogs.WriteInformation($"Error:{ex.Message} \n {ex.StackTrace}\n {ex.StackTrace}");
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,Name,Nasname,Ip,Username,Secret,Port,Description,Lat,Long")] AccessPoints accessPoints)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accessPoints);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accessPoints));
        }
Ejemplo n.º 8
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = base.GetHashCode();
         result = (result * 397) ^ InterfaceUri?.GetHashCode() ?? 0;
         result = (result * 397) ^ Name?.GetHashCode() ?? 0;
         result = (result * 397) ^ AutoUpdate.GetHashCode();
         result = (result * 397) ^ Requirements?.GetHashCode() ?? 0;
         result = (result * 397) ^ CapabilityLists.GetUnsequencedHashCode();
         result = (result * 397) ^ AccessPoints?.GetHashCode() ?? 0;
         return(result);
     }
 }
        public void GetAccessPoints()
        {
            var accessPoints = WifiService.GetAccessPointsOrderedBySignalStrength();

            foreach (var accessPoint in accessPoints)
            {
                AccessPoints.Add(new WifiAccessPoint
                {
                    Name           = accessPoint.Name,
                    SignalStrength = accessPoint.SignalStrength,
                    IsConnected    = accessPoint.IsConnected,
                    IsSecure       = accessPoint.IsSecure
                });
            }
        }
Ejemplo n.º 10
0
        public void Add(IAccessPoint item)
        {
            var ap = AccessPoints.FirstOrDefault(p => string.Equals(p.Bssid, item.Bssid, StringComparison.CurrentCultureIgnoreCase));

            if (ap == null)
            {
                AccessPoints.Add(item);

                TrackerManager.CheckAccessPoint(item);
            }
            else
            {
                ap.LastTime = item.LastTime;
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Select access point from the access points in range.
 /// </summary>
 public void SelectAccessPointCmd()
 {
     try
     {
         bool dialogResult = _windowManager.ShowDialog(_wiFiSearchViewModel) ?? false;
         if (dialogResult)
         {
             AccessPoints.Add(_wiFiSearchViewModel.SelectedAccessPoint);
             SelectedAccessPoint = _wiFiSearchViewModel.SelectedAccessPoint;
             SelectedInterface   = _wiFiSearchViewModel.SelectedInterface;
         }
     }
     catch (Exception ex)
     {
         BusyStateManager.SetMessage(SeverityType.Error, ex.Message);
         BusyStateManager.ClearBusy();
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a deep copy of this <see cref="AppEntry"/> instance.
        /// </summary>
        /// <returns>The new copy of the <see cref="AppEntry"/>.</returns>
        public AppEntry Clone()
        {
            var appList = new AppEntry {
                UnknownAttributes = UnknownAttributes, UnknownElements = UnknownElements, Name = Name, InterfaceUri = InterfaceUri
            };

            if (Requirements != null)
            {
                appList.Requirements = Requirements.Clone();
            }
            if (AccessPoints != null)
            {
                appList.AccessPoints = AccessPoints.Clone();
            }
            appList.CapabilityLists.AddRange(CapabilityLists.CloneElements());

            return(appList);
        }
        public IHttpActionResult CreateAccessPoint(AccessPoints access)
        {
            try
            {
                using (IntegraContext integ = new IntegraContext())
                {
                    integ.AccessPoints.Add(access);
                    integ.SaveChanges();

                    var mess = Content(HttpStatusCode.Created, "Submited successfully");
                    //mess.Headers.Location = new Uri(Request.RequestUri + access.AP_ID.ToString());
                    return(Ok(mess));
                }
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.NotFound, ex.Message));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Refresh selected access point properties.
        /// </summary>
        private async Task RefreshAccessPointAsync()
        {
            BusyStateManager.EnterBusy();
            BusyStateManager.SetMessage(SeverityType.Info,
                                        $"Refreshing the status of access point [{SelectedAccessPoint.Ssid}].");

            IEnumerable <AccessPoint> accessPoints = await _mainController.GetWiFiAccessPointsAsync();

            AccessPoint accessPoint = accessPoints.Where(x => x.Id == SelectedAccessPoint.Id &&
                                                         x.Ssid == SelectedAccessPoint.Ssid &&
                                                         x.ProfileName == SelectedAccessPoint.Ssid).FirstOrDefault();

            /* If access point not found, repeat search without specifying profile name. */
            if (accessPoint == default(AccessPoint))
            {
                accessPoint = accessPoints.Where(x => x.Id == SelectedAccessPoint.Id &&
                                                 x.Ssid == SelectedAccessPoint.Ssid).FirstOrDefault();
            }

            /* Update access point in view. */
            if (accessPoint != default(AccessPoint))
            {
                AccessPoints.Clear();
                AccessPoints.Add(accessPoint);
                SelectedAccessPoint = accessPoint;
            }

            /* Update SelectedInterface status, (isConnected). */
            IEnumerable <Interface> interfaces = await _mainController.GetWiFiInterfacesAsync();

            Interface wiFiInterface = interfaces.Where(x => x.Id == SelectedInterface.Id).FirstOrDefault();

            if (wiFiInterface != default(Interface))
            {
                SelectedInterface = wiFiInterface;
            }

            BusyStateManager.SetMessage(SeverityType.None);
            BusyStateManager.ExitBusy();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Gets the destination and source of a PacketDotNet IEEE 802.11 DataFrame.
        /// The destination and source are determined by the return value. <br />
        /// If no access point or station with MAC addresses matching those in the dataFrame
        /// are found in the existing network graph, then the corresponding access point and
        /// station are added to the graph.
        /// </summary>
        /// <param name="dataFrame">The frame whose destination and source to get.</param>
        /// <param name="accessPoint">The access point to or from which the message is sent.</param>
        /// <param name="station">The station to or from which the message is sent.</param>
        /// <returns>True, if the access point is the destination. Otherwise, false.</returns>
        public bool GetDestinationAndSource(
            DataFrame dataFrame,
            out AccessPoint accessPoint,
            out Station station)
        {
            PhysicalAddress bssid         = dataFrame.BssId;
            PhysicalAddress destAddress   = dataFrame.DestinationAddress;
            PhysicalAddress sourceAddress = dataFrame.SourceAddress;

            if (AccessPoints.TryGetValue(bssid, out accessPoint) == false)
            {
                accessPoint         = new AccessPoint(bssid);
                AccessPoints[bssid] = accessPoint;
            }

            if (Stations.TryGetValue(destAddress, out station))
            {
                return(false);
            }
            else if (Stations.TryGetValue(sourceAddress, out station))
            {
                return(true);
            }
            else
            {
                station = new Station();
                if ((dataFrame.FrameControl.ToDS == true) &&
                    (dataFrame.FrameControl.FromDS == false))
                {
                    Stations[sourceAddress] = station;
                    return(true);
                }
                else
                {
                    Stations[destAddress] = station;
                    return(false);
                }
            }
        }
        public IHttpActionResult Put(int id, [FromBody] AccessPoints access)
        {
            try
            {
                using (IntegraContext integ = new IntegraContext())
                {
                    var resp = integ.AccessPoints.FirstOrDefault(e => e.AP_ID == id);
                    if (resp == null)
                    {
                        return(Content(HttpStatusCode.NotFound, "AccessPoint with ID " + id.ToString() + " not found to update"));
                    }
                    else
                    {
                        resp.AP_IP_ADDR           = access.AP_IP_ADDR;
                        resp.AP_COMID             = access.AP_COMID;
                        resp.AP_SUBNETMASK        = access.AP_SUBNETMASK;
                        resp.AP_GETWAY            = access.AP_GETWAY;
                        resp.AP_NAME              = access.AP_NAME;
                        resp.AP_ONLINESTATUS      = access.AP_ONLINESTATUS;
                        resp.AP_FWVERSION         = access.AP_FWVERSION;
                        resp.AP_LASTCOMMUNICATION = access.AP_LASTCOMMUNICATION;
                        resp.AP_CONNECTED_LOCK    = access.AP_CONNECTED_LOCK;
                        resp.AP_PHY_ADDR          = access.AP_PHY_ADDR;
                        resp.AP_GROUP_ID          = access.AP_GROUP_ID;

                        integ.SaveChanges();

                        return(Ok(resp));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.NotFound, ex.Message));
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Remove selected access point.
 /// </summary>
 public void RemoveAccessPointCmd()
 {
     AccessPoints.Clear();
     SelectedAccessPoint = null;
     SelectedInterface   = null;
 }
Ejemplo n.º 18
0
 private void Setup()
 {
     APs = new AccessPoints();
 }
Ejemplo n.º 19
0
 public void Update()
 {
     AccessPoints = AccessPoints.Where(
         ap => (ap.LastTime != null) && ((DateTime.Now - ap.LastTime) < TimeSpan.FromSeconds(MAX_AP_INVISIBLE_TIME_SEC))).ToList();
 }