private void ShowOneTimePasswords_FormClosing(object sender, FormClosingEventArgs e) { if (increaseHotpAfterClosing) { OtpAuthUtils.increaseHotpCounter(host, data, entry); } }
private void linkLabelIncorrectNext_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (data.Type == OtpType.Totp || data.Type == OtpType.Steam) { Troubleshooting troubleshooting = new Troubleshooting(this.host); troubleshooting.ShowDialog(); } else if (data.Type == OtpType.Hotp) { OtpAuthUtils.increaseHotpCounter(host, data, entry); this.data = OtpAuthUtils.loadData(this.entry); } }
// 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); } } } } } }
private void otpCopyToolStripItem_Click(object sender, EventArgs e) { PwEntry entry; if (this.GetSelectedSingleEntry(out entry)) { OtpAuthData data = OtpAuthUtils.loadData(entry); if (data == null) { if (MessageBox.Show(KeeOtp2Statics.MessageBoxOtpNotConfigured, KeeOtp2Statics.PluginName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ShowOneTimePasswords form = new ShowOneTimePasswords(entry, host); form.ShowDialog(); } } else { OtpBase otp = OtpAuthUtils.getOtp(data); if (data.Type == OtpType.Totp) { if (ClipboardUtil.CopyAndMinimize(new ProtectedString(true, otp.getTotpString(OtpTime.getTime())), true, this.host.MainWindow, entry, this.host.Database)) { this.host.MainWindow.StartClipboardCountdown(); } } else if (data.Type == OtpType.Hotp) { if (ClipboardUtil.CopyAndMinimize(new ProtectedString(true, otp.getHotpString(data.Counter)), true, this.host.MainWindow, entry, this.host.Database)) { this.host.MainWindow.StartClipboardCountdown(); } OtpAuthUtils.increaseHotpCounter(host, data, entry); } } } }
private void SprEngine_FilterCompile(object sender, SprEventArgs e) { if ((e.Context.Flags & SprCompileFlags.ExtActive) == SprCompileFlags.ExtActive) { if (e.Text.IndexOf(KeeOtp1PlaceHolder, StringComparison.InvariantCultureIgnoreCase) >= 0) { PwEntry entry = e.Context.Entry; OtpAuthData data = OtpAuthUtils.loadData(entry); if (data != null) { OtpBase otp = OtpAuthUtils.getOtp(data); if (data.Type == OtpType.Totp || data.Type == OtpType.Steam) { e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, KeeOtp1PlaceHolder, otp.getTotpString(OtpTime.getTime())); } else if (data.Type == OtpType.Hotp) { e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, KeeOtp1PlaceHolder, otp.getHotpString(data.Counter)); OtpAuthUtils.increaseHotpCounter(host, data, entry); } } } } }