lib/_provisioning/provision-config.js
function storeProvisionConfig (config, configDir, filePrefix,
                               privateKeyFileName, verbosity) {
  if (typeof config !== 'string') {
    throw new DxlError('Unexpected data type for response: ' +
      typeof config)
  }
  var configElements = config.split(',')
  if (configElements.length < 3) {
    throw new DxlError('Did not receive expected number of response ' +
      'elements. Expected: 3, Received: ' + configElements.length +
      '. Value: ' + config)
  }

  var brokerLines = configElements[2].split(
    /[\r\n]+/).filter(function (brokerLine) {
      return brokerLine.length > 0
    }
  )

  var brokers = brokersForConfig(brokerLines)

  var certFileName = filePrefix + '.crt'
  var configString = ini.encode({
    Certs: {
      BrokerCertChain: DEFAULT_BROKER_CERT_CHAIN_FILE_NAME,
      CertFile: path.basename(certFileName),
      PrivateKey: path.basename(privateKeyFileName)
    },
    Brokers: brokers
  }).replace(/\\;/g, ';')

  var configFileName = path.join(configDir,
    provisionUtil.DEFAULT_CONFIG_FILE_NAME)
  if (verbosity) {
    console.log('Saving DXL config file to ' + configFileName)
  }
  provisionUtil.saveToFile(configFileName, configString)

  var caBundleFileName = path.join(configDir,
    DEFAULT_BROKER_CERT_CHAIN_FILE_NAME)
  if (verbosity) {
    console.log('Saving ca bundle file to ' + caBundleFileName)
  }
  provisionUtil.saveToFile(caBundleFileName, configElements[0])

  var fullCertFileName = path.join(configDir, certFileName)
  if (verbosity) {
    console.log('Saving client certificate file to ' + fullCertFileName)
  }
  provisionUtil.saveToFile(fullCertFileName, configElements[1])
}
function storeProvisionConfig (config, configDir, filePrefix,
                               privateKeyFileName, verbosity) {
  if (typeof config !== 'string') {
    throw new DxlError('Unexpected data type for response: ' +
      typeof config)
  }
  var configElements = config.split(',')
  if (configElements.length < 3) {
    throw new DxlError('Did not receive expected number of response ' +
      'elements. Expected: 3, Received: ' + configElements.length +
      '. Value: ' + config)
  }

  var brokerLines = configElements[2].split(
    /[\r\n]+/).filter(function (brokerLine) {
      return brokerLine.length > 0
    }
  )

  var brokers = brokersForConfig(brokerLines)

  var certFileName = filePrefix + '.crt'
  var configString = ini.encode({
    Certs: {
      BrokerCertChain: DEFAULT_BROKER_CERT_CHAIN_FILE_NAME,
      CertFile: path.basename(certFileName),
      PrivateKey: path.basename(privateKeyFileName)
    },
    Brokers: brokers
  }).replace(/\\;/g, ';')

  var configFileName = path.join(configDir,
    provisionUtil.DEFAULT_CONFIG_FILE_NAME)
  if (verbosity) {
    console.log('Saving DXL config file to ' + configFileName)
  }
  provisionUtil.saveToFile(configFileName, configString)

  var caBundleFileName = path.join(configDir,
    DEFAULT_BROKER_CERT_CHAIN_FILE_NAME)
  if (verbosity) {
    console.log('Saving ca bundle file to ' + caBundleFileName)
  }
  provisionUtil.saveToFile(caBundleFileName, configElements[0])

  var fullCertFileName = path.join(configDir, certFileName)
  if (verbosity) {
    console.log('Saving client certificate file to ' + fullCertFileName)
  }
  provisionUtil.saveToFile(fullCertFileName, configElements[1])
}
function storeProvisionConfig ( config , configDir , filePrefix , privateKeyFileName , verbosity ) { if ( typeof config !== 'string' ) { throw new DxlError ( 'Unexpected data type for response: ' + typeof config ) } var configElements = config . split ( ',' ) if ( configElements . length < 3 ) { throw new DxlError ( 'Did not receive expected number of response ' + 'elements. Expected: 3, Received: ' + configElements . length + '. Value: ' + config ) } var brokerLines = configElements [ 2 ] . split ( / [\r\n]+ / ) . filter ( function ( brokerLine ) { return brokerLine . length > 0 } ) var brokers = brokersForConfig ( brokerLines ) var certFileName = filePrefix + '.crt' var configString = ini . encode ( { Certs : { BrokerCertChain : DEFAULT_BROKER_CERT_CHAIN_FILE_NAME , CertFile : path . basename ( certFileName ) , PrivateKey : path . basename ( privateKeyFileName ) } , Brokers : brokers } ) . replace ( / \\; / g , ';' ) var configFileName = path . join ( configDir , provisionUtil . DEFAULT_CONFIG_FILE_NAME ) if ( verbosity ) { console . log ( 'Saving DXL config file to ' + configFileName ) } provisionUtil . saveToFile ( configFileName , configString ) var caBundleFileName = path . join ( configDir , DEFAULT_BROKER_CERT_CHAIN_FILE_NAME ) if ( verbosity ) { console . log ( 'Saving ca bundle file to ' + caBundleFileName ) } provisionUtil . saveToFile ( caBundleFileName , configElements [ 0 ] ) var fullCertFileName = path . join ( configDir , certFileName ) if ( verbosity ) { console . log ( 'Saving client certificate file to ' + fullCertFileName ) } provisionUtil . saveToFile ( fullCertFileName , configElements [ 1 ] ) }
Store the configuration data received from the management service to the
local file system.
@param {String} config - Configuration data received from the management
service.
@param {String} configDir - Directory in which to store the configuration
data.
@param {String} filePrefix - Prefix of the certificate file to store.
@param {String} privateKeyFileName - Name of the private key file to
include in the stored configuration file.
@param {Number} verbosity - Level of verbosity at which to log any error
or trace messages.
@private
Store the configuration data received from the management service to the local file system .