Exemplo n.º 1
0
        private void DoSecurityAction(string name, ActionSecurity action)
        {
            if (selectedDevice == null && IsDebugMode)
            {
                Trace.WriteLine("No device selected");
            }
            // MessageBox.Show(this, "No device selected", name);
            else
            {
                bool result = action(selectedDevice.DeviceAddress);
                UpdateBTDeviceDetails("Remove Bluetooth Device, Result: " + result);

                if (result)
                {
                    UpdateFindDeviceResult("Device Removed");
                    buttonRemove.Enabled    = false;
                    buttonAudioPASS.Enabled = true;
                    buttonAudioFAIL.Enabled = true;
                }
                else
                {
                    UpdateFindDeviceResult("Device not Removed");
                    labelResult.ForeColor = Color.Red;
                }
            }
        }
Exemplo n.º 2
0
        private void buttonSecurityRemoveDevice_Click(System.Object sender, System.EventArgs e)
        {
            buttonAudioTest.Enabled = false;
            UpdateFindDeviceResult("Removing a device...");
            labelResult.ForeColor = Color.Orange;
            ActionSecurity actionRemove = (BluetoothAddress device) => BluetoothSecurity.RemoveDevice(device);

            DoSecurityAction("Remove Bluetooth Device", actionRemove);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Whether the user is authorized to see the menu item.
        /// </summary>
        internal bool IsAuthorized(ClaimSubset identity, bool isPreprodOrProd)
        {
            bool controllerAuthorized = ControllerSecurity != null && ControllerSecurity.IsAuthorized(identity, isPreprodOrProd);
            bool actionAuthorized     = ActionSecurity != null && ActionSecurity.IsAuthorized(identity, isPreprodOrProd);

            // Authorized if:
            // - controller authorized and:
            //      - action authorized or no action security specified (use controller security)
            // - or action authorized.
            return((controllerAuthorized && (actionAuthorized || ActionSecurity == null)) || actionAuthorized);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Whether the user is authorized to see the menu item.
        /// </summary>
        public bool IsAuthorized(ClaimsIdentity identity)
        {
            bool controllerAuthorized = ControllerSecurity != null && ControllerSecurity.IsAuthorized(identity);
            bool actionAuthorized     = ActionSecurity != null && ActionSecurity.IsAuthorized(identity);

            // Authorized if:
            // - controller authorized and:
            //      - action authorized or no action security specified (use controller security)
            // - or action authorized.
            return((controllerAuthorized && (actionAuthorized || ActionSecurity == null)) || actionAuthorized);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Override GetHashCode for object
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 1;
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ParentController != null ? ParentController.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ParentAction != null ? ParentAction.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ParentArea != null ? ParentArea.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Area != null ? Area.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Controller != null ? Controller.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Action != null ? Action.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Parent != null ? Parent.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ControllerSecurity != null ? ControllerSecurity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ActionSecurity != null ? ActionSecurity.GetHashCode() : 0);
         return(hashCode);
     }
 }