public FidoDevice updateFidoDevice(String id, FidoDevice fidoDevice) throws Exception {

    fidoDeviceService = FidoDeviceService.instance();

    GluuCustomFidoDevice gluuCustomFidoDevice =
        fidoDeviceService.getGluuCustomFidoDeviceById(fidoDevice.getUserId(), id);
    if (gluuCustomFidoDevice == null) {
      throw new EntryPersistenceException(
          "Scim2FidoDeviceService.updateFidoDevice(): Resource " + id + " not found");
    }

    GluuCustomFidoDevice updatedGluuCustomFidoDevice =
        CopyUtils2.updateGluuCustomFidoDevice(fidoDevice, gluuCustomFidoDevice);

    log.info(" Setting meta: update device ");
    DateTimeFormatter dateTimeFormatter =
        ISODateTimeFormat.dateTime().withZoneUTC(); // Date should be in UTC format
    Date dateLastModified = DateTime.now().toDate();
    updatedGluuCustomFidoDevice.setMetaLastModified(
        dateTimeFormatter.print(dateLastModified.getTime()));
    if (updatedGluuCustomFidoDevice.getMetaLocation() == null
        || (updatedGluuCustomFidoDevice.getMetaLocation() != null
            && updatedGluuCustomFidoDevice.getMetaLocation().isEmpty())) {
      String relativeLocation = "/scim/v2/FidoDevices/" + id;
      updatedGluuCustomFidoDevice.setMetaLocation(relativeLocation);
    }

    fidoDeviceService.updateGluuCustomFidoDevice(gluuCustomFidoDevice);

    FidoDevice updatedFidoDevice = CopyUtils2.copy(gluuCustomFidoDevice, new FidoDevice());

    return updatedFidoDevice;
  }
  public void deleteFidoDevice(String id) throws Exception {

    fidoDeviceService = FidoDeviceService.instance();

    GluuCustomFidoDevice gluuCustomFidoDevice =
        fidoDeviceService.getGluuCustomFidoDeviceById(null, id);
    if (gluuCustomFidoDevice == null) {
      throw new EntryPersistenceException(
          "Scim2FidoDeviceService.deleteFidoDevice(): Resource " + id + " not found");
    }

    fidoDeviceService.removeGluuCustomFidoDevice(gluuCustomFidoDevice);
  }