function decryptSGContextValues(globalConfigModel, sg, sgt) {
  if (!sg.context || !sgt.contextDefinition) {
    return Promise.resolve(sg);
  }

  return getSGEncryptionKeyAndAlgorithm(globalConfigModel)
  .then((config) => {
    const isKeyAlgoConfigured =
      config && config.secretKey && config.algorithm;
    for (const key in sgt.contextDefinition) {
      if (sgt.contextDefinition.hasOwnProperty(key) &&
        sgt.contextDefinition[key].encrypted && sg.context[key]) {
        if (isKeyAlgoConfigured) {
          sg.context[key] = decrypt(sg.context[key], config.secretKey,
            config.algorithm);
        } else {
          return Promise.reject('Cannot decrypt the text without the ' +
            'secretKey and algorithm');
        }
      }
    }

    return sg;
  });
} // decryptSGContextValues
/**
 * Decrypts the encrypted sample generator context values. If the secret key
 * and algorithm are not found in the global config table the encryption is
 * not done.
 * @param  {GlobalConfig} globalConfigModel - The global config model
 * @param  {Object} sg - The sample generator object
 * @param  {Object} sgt - The sample generatot template object.
 * @returns {Objec} - sample generator object with decrypted context values
 */
Decrypts the encrypted sample generator context values. If the secret key
and algorithm are not found in the global config table the encryption is
not done.
@param  {GlobalConfig} globalConfigModel - The global config model
@param  {Object} sg - The sample generator object
@param  {Object} sgt - The sample generatot template object.
@returns {Objec} - sample generator object with decrypted context values
Decrypts the encrypted sample generator context values . If the secret key and algorithm are not found in the global config table the encryption is not done . @param { GlobalConfig } globalConfigModel - The global config model @param { Object } sg - The sample generator object @param { Object } sgt - The sample generatot template object . @returns { Objec } - sample generator object with decrypted context values
function decryptSGContextValues(globalConfigModel, sg, sgt) {
  if (!sg.context || !sgt.contextDefinition) {
    return Promise.resolve(sg);
  }
  return getSGEncryptionKeyAndAlgorithm(globalConfigModel)
  .then((config) => {
    const isKeyAlgoConfigured =
      config && config.secretKey && config.algorithm;
    for (const key in sgt.contextDefinition) {
      if (sgt.contextDefinition.hasOwnProperty(key) &&
        sgt.contextDefinition[key].encrypted && sg.context[key]) {
        if (isKeyAlgoConfigured) {
          sg.context[key] = decrypt(sg.context[key], config.secretKey,
            config.algorithm);
        } else {
          return Promise.reject('Cannot decrypt the text without the ' +
            'secretKey and algorithm');
        }
      }
    }
    return sg;
  });
} 
function decryptSGContextValues ( globalConfigModel , sg , sgt ) { if ( ! sg . context || ! sgt . contextDefinition ) { return Promise . resolve ( sg ) ; } return getSGEncryptionKeyAndAlgorithm ( globalConfigModel ) . then ( ( config ) => { const isKeyAlgoConfigured = config && config . secretKey && config . algorithm ; for ( const key in sgt . contextDefinition ) { if ( sgt . contextDefinition . hasOwnProperty ( key ) && sgt . contextDefinition [ key ] . encrypted && sg . context [ key ] ) { if ( isKeyAlgoConfigured ) { sg . context [ key ] = decrypt ( sg . context [ key ] , config . secretKey , config . algorithm ) ; } else { return Promise . reject ( 'Cannot decrypt the text without the ' + 'secretKey and algorithm' ) ; } } } return sg ; } ) ; }
Decrypts the encrypted sample generator context values.
Decrypts the encrypted sample generator context values .
// decryptSGContextValues