コード例 #1
0
ファイル: AppConfigEx.cs プロジェクト: kkato233/KeePass
        /// <summary>
        /// Prepare for saving the configuration to disk. None of the
        /// modifications in this method need to be rolled back
        /// (for rollback, use <c>OnSavePre</c> / <c>OnSavePost</c>).
        /// </summary>
        private void PrepareSave()
        {
            AceMeta        aceMeta = this.Meta;        // m_meta might be null
            AceApplication aceApp  = this.Application; // m_aceApp might be null
            AceDefaults    aceDef  = this.Defaults;    // m_def might be null

            aceMeta.OmitItemsWithDefaultValues = true;
            aceMeta.DpiFactorX = DpiUtil.FactorX;             // For new (not loaded) cfgs.
            aceMeta.DpiFactorY = DpiUtil.FactorY;

            aceApp.LastUsedFile.ClearCredentials(true);

            foreach (IOConnectionInfo iocMru in aceApp.MostRecentlyUsed.Items)
            {
                iocMru.ClearCredentials(true);
            }

            if (aceDef.RememberKeySources == false)
            {
                aceDef.KeySources.Clear();
            }

            aceApp.TriggerSystem = Program.TriggerSystem;

            SearchUtil.PrepareForSerialize(aceDef.SearchParameters);

            const int     m = 64;         // Maximum number of compatibility items
            List <string> l = aceApp.PluginCompatibility;

            if (l.Count > m)
            {
                l.RemoveRange(m, l.Count - m);                         // See reg.
            }
        }
コード例 #2
0
ファイル: AppConfigEx.cs プロジェクト: kkato233/KeePass
        private void ChangePathsRelAbs(bool bMakeAbsolute)
        {
            AceApplication aceApp = this.Application;       // m_aceApp might be null
            AceDefaults    aceDef = this.Defaults;          // m_def might be null

            ChangePathRelAbs(aceApp.LastUsedFile, bMakeAbsolute);

            foreach (IOConnectionInfo iocMru in aceApp.MostRecentlyUsed.Items)
            {
                ChangePathRelAbs(iocMru, bMakeAbsolute);
            }

            List <string> lWDKeys = aceApp.GetWorkingDirectoryContexts();

            foreach (string strWDKey in lWDKeys)
            {
                aceApp.SetWorkingDirectory(strWDKey, ChangePathRelAbsStr(
                                               aceApp.GetWorkingDirectory(strWDKey), bMakeAbsolute));
            }

            foreach (AceKeyAssoc kfp in aceDef.KeySources)
            {
                kfp.DatabasePath = ChangePathRelAbsStr(kfp.DatabasePath, bMakeAbsolute);
                kfp.KeyFilePath  = ChangePathRelAbsStr(kfp.KeyFilePath, bMakeAbsolute);
            }
        }
コード例 #3
0
        /// <summary>
        /// Prepare for saving the configuration to disk. None of the
        /// modifications in this method need to be rolled back
        /// (for rollback, use <c>OnSavePre</c> / <c>OnSavePost</c>).
        /// </summary>
        private void PrepareSave()
        {
            AceMeta        aceMeta = this.Meta;        // m_meta might be null
            AceApplication aceApp  = this.Application; // m_aceApp might be null
            AceDefaults    aceDef  = this.Defaults;    // m_def might be null

            aceMeta.OmitItemsWithDefaultValues = true;
            aceMeta.DpiFactorX = DpiUtil.FactorX;             // For new (not loaded) cfgs.
            aceMeta.DpiFactorY = DpiUtil.FactorY;

            aceApp.LastUsedFile.ClearCredentials(true);

            foreach (IOConnectionInfo iocMru in aceApp.MostRecentlyUsed.Items)
            {
                iocMru.ClearCredentials(true);
            }

            if (aceDef.RememberKeySources == false)
            {
                aceDef.KeySources.Clear();
            }

            aceApp.TriggerSystem = Program.TriggerSystem;

            SearchUtil.PrepareForSerialize(aceDef.SearchParameters);
        }
コード例 #4
0
ファイル: AppConfigEx.cs プロジェクト: kkato233/KeePass
        private void ObfuscateCred(bool bObf)
        {
            AceApplication aceApp = this.Application;             // m_aceApp might be null
            AceIntegration aceInt = this.Integration;             // m_int might be null

            if (aceApp.LastUsedFile == null)
            {
                Debug.Assert(false);
            }
            else
            {
                aceApp.LastUsedFile.Obfuscate(bObf);
            }

            foreach (IOConnectionInfo iocMru in aceApp.MostRecentlyUsed.Items)
            {
                if (iocMru == null)
                {
                    Debug.Assert(false);
                }
                else
                {
                    iocMru.Obfuscate(bObf);
                }
            }

            if (bObf)
            {
                aceInt.ProxyUserName = StrUtil.Obfuscate(aceInt.ProxyUserName);
            }
            else
            {
                aceInt.ProxyUserName = StrUtil.Deobfuscate(aceInt.ProxyUserName);
            }

            if (bObf)
            {
                aceInt.ProxyPassword = StrUtil.Obfuscate(aceInt.ProxyPassword);
            }
            else
            {
                aceInt.ProxyPassword = StrUtil.Deobfuscate(aceInt.ProxyPassword);
            }
        }
コード例 #5
0
ファイル: AppConfigEx.cs プロジェクト: kkato233/KeePass
        public void Apply(AceApplyFlags f)
        {
            AceApplication aceApp = this.Application;       // m_aceApp might be null
            AceSecurity    aceSec = this.Security;          // m_sec might be null
            AceIntegration aceInt = this.Integration;       // m_int might be null

            if ((f & AceApplyFlags.Proxy) != AceApplyFlags.None)
            {
                IOConnection.SetProxy(aceInt.ProxyType, aceInt.ProxyAddress,
                                      aceInt.ProxyPort, aceInt.ProxyAuthType, aceInt.ProxyUserName,
                                      aceInt.ProxyPassword);
            }

            if ((f & AceApplyFlags.Ssl) != AceApplyFlags.None)
            {
                IOConnection.SslCertsAcceptInvalid = aceSec.SslCertsAcceptInvalid;
            }

            if ((f & AceApplyFlags.FileTransactions) != AceApplyFlags.None)
            {
                FileTransactionEx.ExtraSafe = aceApp.FileTxExtra;
            }
        }