从驱动程序实现访问设备凭据的最简单方法?

easiest way to access to device credentials from a Driver implementation?

我正在制作一个 class 以简化从 cumulocity

向设备分发文件
/**
 * Class to simplify pushing files to the devices
 */
public class GenericFileUploadDriver implements Driver, OperationExecutor {

使用 c8y_DownloadConfigFile 我可以在客户端上挖掘文件 URL,显然我需要手动验证才能访问它。

我想使用 cfg/device.properties 文件中的凭据。 我想知道从这种情况下访问这些内容的最简单方法是什么?

谢谢

您可以从传递给您的 Platform 对象中找出它:

public void initialize(Platform platform) throws Exception {
  PlatformParameters parms = (PlatformParameters)platform;
  String user = parms.getUser();
  String password = parms.getPassword();
  // ...
}