Add power/reset button mask checks for RequestedPowerTransition

To fully honor button masking, the RequestedPowerTransition interface
now checks the button mask state prior to actually initiating the
requested transition. This will make it so the IPMI and Redfish
commands will not be able to subvert the masked buttons.

The last patch set only blocked resets and graceful power transitions.
This patch adds the similar behavior for power transitions.

Tested: disable front panel buttons (ipmitool raw 0 0x0a 0xf0)
        and then attempt to reset and power cycle with ipmi
        and redfish.

        ipmitool chassis power off
	redfish  /v1/Systems/system/Actions/ComputerSystem.Reset
                 { "ResetType": "ForceOff" }

        Host power stays on and uninterrupted.

Change-Id: Ic3be2bc7cf364524949c1ee31037fff8d3438d19
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/power-control-x86/src/power_control.cpp b/power-control-x86/src/power_control.cpp
index 6a33f53..58e7a8b 100644
--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -3510,20 +3510,53 @@
         [](const std::string& requested, std::string& resp) {
             if (requested == "xyz.openbmc_project.State.Chassis.Transition.Off")
             {
-                sendPowerControlEvent(Event::powerOffRequest);
-                addRestartCause(RestartCause::command);
+                // if power button is masked, ignore this
+                if (!powerButtonMask)
+                {
+                    sendPowerControlEvent(Event::powerOffRequest);
+                    addRestartCause(RestartCause::command);
+                }
+                else
+                {
+                    phosphor::logging::log<phosphor::logging::level::INFO>(
+                        "Power Button Masked.");
+                    throw std::invalid_argument("Transition Request Masked");
+                    return 0;
+                }
             }
             else if (requested ==
                      "xyz.openbmc_project.State.Chassis.Transition.On")
             {
-                sendPowerControlEvent(Event::powerOnRequest);
-                addRestartCause(RestartCause::command);
+                // if power button is masked, ignore this
+                if (!powerButtonMask)
+                {
+                    sendPowerControlEvent(Event::powerOnRequest);
+                    addRestartCause(RestartCause::command);
+                }
+                else
+                {
+                    phosphor::logging::log<phosphor::logging::level::INFO>(
+                        "Power Button Masked.");
+                    throw std::invalid_argument("Transition Request Masked");
+                    return 0;
+                }
             }
             else if (requested ==
                      "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
             {
-                sendPowerControlEvent(Event::powerCycleRequest);
-                addRestartCause(RestartCause::command);
+                // if power button is masked, ignore this
+                if (!powerButtonMask)
+                {
+                    sendPowerControlEvent(Event::powerCycleRequest);
+                    addRestartCause(RestartCause::command);
+                }
+                else
+                {
+                    phosphor::logging::log<phosphor::logging::level::INFO>(
+                        "Power Button Masked.");
+                    throw std::invalid_argument("Transition Request Masked");
+                    return 0;
+                }
             }
             else
             {