예제 #1
0
        public void ResetIoTDevicePassword(string deviceId, string newPassword)
        {
            DBHelper._IoTDevice dbhelp    = new DBHelper._IoTDevice();
            IoTDevice           iotDevice = dbhelp.GetByid(deviceId);

            iotDevice.IoTHubDevicePW = Crypto.HashPassword(newPassword);
            dbhelp.Update(iotDevice);
        }
예제 #2
0
        public void UpdateDBIoTDeviceKey(string deviceKey)
        {
            DBHelper._IoTDevice iotDeviceHelper = new DBHelper._IoTDevice();
            IoTDevice           iotDevice       = iotDeviceHelper.GetByid(this._IoTHubDeviceId);

            iotDevice.IoTHubDeviceKey = deviceKey;
            iotDeviceHelper.Update(iotDevice);
        }
예제 #3
0
        public void updateIoTDevice(string iotHubDeviceId, Update iotDevice)
        {
            DBHelper._IoTDevice dbhelp            = new DBHelper._IoTDevice();
            IoTDevice           existingIoTDevice = dbhelp.GetByid(iotHubDeviceId);

            existingIoTDevice.IoTHubAlias         = iotDevice.IoTHubAlias;
            existingIoTDevice.IoTHubProtocol      = iotDevice.IoTHubProtocol;
            existingIoTDevice.FactoryID           = iotDevice.FactoryId;
            existingIoTDevice.AuthenticationType  = iotDevice.AuthenticationType;
            existingIoTDevice.DeviceCertificateID = (iotDevice.DeviceCertificateId == 0) ? (int?)null : iotDevice.DeviceCertificateId;
            existingIoTDevice.DeviceTypeId        = iotDevice.DeviceTypeId;
            existingIoTDevice.DeviceVendor        = iotDevice.DeviceVendor;
            existingIoTDevice.DeviceModel         = iotDevice.DeviceModel;

            dbhelp.Update(existingIoTDevice);
        }
예제 #4
0
        public void ChangeIoTDevicePassword(string deviceId, PasswordSet passwordSet)
        {
            DBHelper._IoTDevice dbhelp    = new DBHelper._IoTDevice();
            IoTDevice           iotDevice = dbhelp.GetByid(deviceId);

            if (iotDevice == null)
            {
                throw new Exception("404");
            }

            if (Crypto.VerifyHashedPassword(iotDevice.IoTHubDevicePW, passwordSet.OldPassword))
            {
                iotDevice.IoTHubDevicePW = Crypto.HashPassword(passwordSet.NewPassword);
                dbhelp.Update(iotDevice);
            }
            else
            {
                throw new Exception("401");
            }
        }