Пример #1
0
        public static bool checkEntryMigratable(PwEntry entry, MigrationMode migrateMode)
        {
            switch (migrateMode)
            {
            case MigrationMode.KeeOtp1ToBuiltIn:
                return(OtpAuthUtils.checkKeeOtp1Mode(entry));

            case MigrationMode.BuiltInToKeeOtp1:
                return(OtpAuthUtils.checkBuiltInMode(entry));

            default:
                return(false);
            }
        }
Пример #2
0
 // If built-in {TIMEOTP} placeholder is used, but KeeOtp1 Save Mode is used
 private void SprEngine_FilterCompilePre(object sender, SprEventArgs e)
 {
     if ((e.Context.Flags & SprCompileFlags.ExtActive) == SprCompileFlags.ExtActive)
     {
         string currentPlaceHolder = null;
         if (e.Text.IndexOf(BuiltInTotpPlaceHolder, StringComparison.InvariantCultureIgnoreCase) >= 0)
         {
             currentPlaceHolder = BuiltInTotpPlaceHolder;
         }
         else if (e.Text.IndexOf(BuiltInHotpPlaceHolder, StringComparison.InvariantCultureIgnoreCase) >= 0)
         {
             currentPlaceHolder = BuiltInHotpPlaceHolder;
         }
         if (!string.IsNullOrEmpty(currentPlaceHolder))
         {
             PwEntry     entry = e.Context.Entry;
             OtpAuthData data  = OtpAuthUtils.loadData(entry);
             if (data != null)
             {
                 if (!OtpAuthUtils.checkBuiltInMode(entry) ||
                     (OtpAuthUtils.checkEntry(entry) && OtpTime.getOverrideBuiltInTime() && (OtpTime.getTimeType() == OtpTimeType.FixedOffset || OtpTime.getTimeType() == OtpTimeType.CustomNtpServer)) ||
                     !data.Proprietary)
                 {
                     OtpBase otp = OtpAuthUtils.getOtp(data);
                     if (data.Type == OtpType.Totp || data.Type == OtpType.Steam)
                     {
                         e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, currentPlaceHolder, otp.getTotpString(OtpTime.getTime()));
                     }
                     else if (data.Type == OtpType.Hotp)
                     {
                         e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, currentPlaceHolder, otp.getHotpString(data.Counter));
                         OtpAuthUtils.increaseHotpCounter(host, data, entry);
                     }
                 }
             }
         }
     }
 }