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); }
public void UpdateDBIoTDeviceKey(string deviceKey) { DBHelper._IoTDevice iotDeviceHelper = new DBHelper._IoTDevice(); IoTDevice iotDevice = iotDeviceHelper.GetByid(this._IoTHubDeviceId); iotDevice.IoTHubDeviceKey = deviceKey; iotDeviceHelper.Update(iotDevice); }
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); }
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"); } }