/// <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> Saves the initial response in the LastOffline file. </summary> /// <param name="initialResponse"></param> internal void SaveInitialResponseInLastOfflineFile(String initialResponse) { String fileName = GetLastOfflineExecutionPropertiesFileName(); String fileTime = HandleFiles.getFileTime(fileName); LastOfflineExecutionProperties[ConstInterface.INITIAL_RESPONSE] = initialResponse; LastOfflineExecutionProperties.WriteToXMLFile(fileName); HandleFiles.setFileTime(fileName, fileTime); }
/// <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); }
/// <summary> /// Saves an indication of unsynchronized metadata in LastOffline to instruct client to start in connected mode next time /// </summary> internal void SaveUnsyncronizedMetadataFlagInLastOfflineFile() { String fileName = GetLastOfflineExecutionPropertiesFileName(); String fileTime = HandleFiles.getFileTime(fileName); MgProperties offlineExecutionProps = LastOfflineExecutionProperties.Clone(); offlineExecutionProps.Add(ConstInterface.MG_TAG_UNSYNCRONIZED_METADATA, "Y"); String initialResponse = offlineExecutionProps[ConstInterface.INITIAL_RESPONSE]; if (GetLastOfflineExecutionPropertyBool(ConstInterface.DISABLE_ENCRYPTION)) { initialResponse = XMLConstants.CDATA_START + OSEnvironment.EolSeq + initialResponse + OSEnvironment.EolSeq + XMLConstants.CDATA_END; offlineExecutionProps[ConstInterface.INITIAL_RESPONSE] = initialResponse; } offlineExecutionProps.WriteToXMLFile(fileName); HandleFiles.setFileTime(fileName, fileTime); }