/// <summary> Returns whether messages should be secured (scrambled). </summary> /// <returns></returns> private bool GetShouldSecureMessages() { string val = LastOfflineExecutionProperties.getProperty(ConstInterface.SECURE_MESSAGES); return(!String.IsNullOrEmpty(val) ? val.Equals("Y", StringComparison.CurrentCultureIgnoreCase) : !GetLastOfflineExecutionPropertyBool(ConstInterface.DISABLE_ENCRYPTION)); // Backwards compatibility: Until xpa 3.0, both messages and xml files were encrypted based on this single flag. }
/// <summary></summary> /// <param name="propertyName">The name of a property that should be retrieved from last offline execution properties.</param> /// <returns>Boolean value of execution property.</returns> private bool GetLastOfflineExecutionPropertyBool(String propertyName) { bool ret = false; string val = LastOfflineExecutionProperties.getProperty(propertyName); if (!String.IsNullOrEmpty(val)) { ret = val.Equals("Y", StringComparison.CurrentCultureIgnoreCase); } return(ret); }
/// <summary> /// Returns true if there is an indication of unsynchronized metadata in last execution, to instruct client to start in connected mode /// even when execution property ConnectOnStartup = N /// </summary> /// <returns></returns> internal bool IsUnsyncronizedMetadata() { bool ret = false; string val = LastOfflineExecutionProperties.getProperty(ConstInterface.MG_TAG_UNSYNCRONIZED_METADATA); if (!String.IsNullOrEmpty(val)) { ret = val.Equals("Y", StringComparison.CurrentCultureIgnoreCase); } return(ret); }
/// <summary> /// Initializes the encryptor that handles encryption/decryption of cached content (this functionality is currently embedded in the PersistentOnlyCacheManager..) /// </summary> internal void InitializeEncryptor() { // retrieve the required encryption state (enabled/disabled) and key: bool disableEncryption = GetLastOfflineExecutionPropertyBool(ConstInterface.DISABLE_ENCRYPTION); string encryptionKeyStr = LastOfflineExecutionProperties.getProperty(ConstInterface.ENCRYPTION_KEY); byte[] encryptionKey = null; if (!String.IsNullOrEmpty(encryptionKeyStr)) { // TODO: Scrambling the encryption key in the execution.properties_LastOffline file is not secured enough! encryptionKeyStr = Scrambler.UnScramble(encryptionKeyStr, 0, encryptionKeyStr.Length - 1); encryptionKey = Encoding.Default.GetBytes(encryptionKeyStr); } // initialize the encryptor: IEncryptor encryptor = PersistentOnlyCacheManager.CreateInstance(disableEncryption, encryptionKey); }