Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

Your device(s) may contain sensitive information (database connection strings), or context-specific configuration data (a reference to a specific local resource). If you want to clear out specific fields when a device is exported, you can do so with the following code.

Sensitive data should be encrypted within your device configuration. Configuration remains encrypted during export (and within a channel file) and is not viewable upon import in Connexion. Clearing configuration is usually done to protect against accidentally starting a newly imported channel which has incorrect configuration information (referencing a different customer, accessing a specific folder, etc.)

The OnBeforeExport method in the ConfigurationFactory class is used to clear configuration data.

public override string OnBeforeExport(string configuration, StringBuilder warnings)
{
  // deserialize the configuration string into a configuratino object
  var config = SerializationEx.Deserialize<FtpDeviceConfiguration>(configuration);
  var updated = false;
  
  // the ShouldReplaceValue method checks for null/empty as well as
  // global values. Globals are not cleared
  if (ShouldReplaceValue(config.SomeStringProperty))
  {
    config.SomeStringProperty = string.Empty;
    warnings.AppendLine("SomeStringProperty has been cleared.");
    updated = true;
  }

  // serialize the cleared configuration, if we cleared something
  return updated ? SerializationEx.Serialize(config, false) : configuration;
}

  • No labels