Permalink
Browse files

Make improvement MR-419 - Password prompt dialog should have a meanin…

…gful window title
  • Loading branch information...
1 parent 63ad076 commit 5d8e7a9fa8e2cfffa297bbacf4a6652f9a1fa1d3 @rmcardle rmcardle committed Nov 16, 2013
View
@@ -4,6 +4,7 @@
Added feature MR-212 - Add option to connect without credentials
Added feature MR-547 - Add support for Xming Portable PuTTY
Made improvement MR-367 - Make the 'Connect' button on the 'Quick Connect' toolbar a forced dropdown
+ Made improvement MR-419 - Password prompt dialog should have a meaningful window title
Made improvement MR-590 - Make panels docked to the edge of the window keep their size
Fixed issue MR-187 - F7 keyboard shortcut for New Folder conflicts with remote connections
Added "Reset" to config panel context menu to allow resetting some config settings to their default value.
@@ -5,6 +5,7 @@ Imports mRemoteNG.App.Runtime
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
+Imports mRemoteNG.My
Imports PSTaskDialog
Namespace Config
@@ -1033,17 +1034,24 @@ Namespace Config
End Function
Private Function Authenticate(ByVal Value As String, ByVal CompareToOriginalValue As Boolean, Optional ByVal RootInfo As mRemoteNG.Root.Info = Nothing) As Boolean
+ Dim passwordName As String
+ If UseSQL Then
+ passwordName = Language.strSQLServer.TrimEnd(":")
+ Else
+ passwordName = Path.GetFileName(ConnectionFileName)
+ End If
+
If CompareToOriginalValue Then
Do Until Security.Crypt.Decrypt(Value, pW) <> Value
- pW = Tools.Misc.PasswordDialog(False)
+ pW = Tools.Misc.PasswordDialog(passwordName, False)
If pW = "" Then
Return False
End If
Loop
Else
Do Until Security.Crypt.Decrypt(Value, pW) = "ThisIsProtected"
- pW = Tools.Misc.PasswordDialog(False)
+ pW = Tools.Misc.PasswordDialog(passwordName, False)
If pW = "" Then
Return False
@@ -0,0 +1,45 @@
+Imports System.ComponentModel
+
+' Adapted from http://stackoverflow.com/a/3678888/2101395
+
+Namespace Controls
+ Public Class TextBox
+ Inherits Windows.Forms.TextBox
+
+#Region "Public Properties"
+ <Category("Behavior"),
+ DefaultValue(False)> _
+ Public Property SelectAllOnFocus As Boolean = False
+#End Region
+
+#Region "Protected Methods"
+ Protected Overrides Sub OnEnter(ByVal e As EventArgs)
+ MyBase.OnEnter(e)
+
+ If MouseButtons = MouseButtons.None Then
+ SelectAll()
+ _focusHandled = True
+ End If
+ End Sub
+
+ Protected Overrides Sub OnLeave(ByVal e As EventArgs)
+ MyBase.OnLeave(e)
+
+ _focusHandled = False
+ End Sub
+
+ Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
+ MyBase.OnMouseUp(e)
+
+ If Not _focusHandled Then
+ If SelectionLength = 0 Then SelectAll()
+ _focusHandled = True
+ End If
+ End Sub
+#End Region
+
+#Region "Private Fields"
+ Private _focusHandled As Boolean = False
+#End Region
+ End Class
+End Namespace
@@ -0,0 +1,159 @@
+Namespace Forms
+ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
+ Partial Class PasswordForm
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ <System.Diagnostics.DebuggerNonUserCode()> _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ Try
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ <System.Diagnostics.DebuggerStepThrough()> _
+ Private Sub InitializeComponent()
+ Me.lblPassword = New System.Windows.Forms.Label()
+ Me.lblVerify = New System.Windows.Forms.Label()
+ Me.btnOK = New System.Windows.Forms.Button()
+ Me.btnCancel = New System.Windows.Forms.Button()
+ Me.lblStatus = New System.Windows.Forms.Label()
+ Me.pbLock = New System.Windows.Forms.PictureBox()
+ Me.txtVerify = New mRemoteNG.Controls.TextBox()
+ Me.txtPassword = New mRemoteNG.Controls.TextBox()
+ CType(Me.pbLock, System.ComponentModel.ISupportInitialize).BeginInit()
+ Me.SuspendLayout()
+ '
+ 'lblPassword
+ '
+ Me.lblPassword.AutoSize = True
+ Me.lblPassword.Location = New System.Drawing.Point(82, 12)
+ Me.lblPassword.Name = "lblPassword"
+ Me.lblPassword.Size = New System.Drawing.Size(56, 13)
+ Me.lblPassword.TabIndex = 1
+ Me.lblPassword.Text = "Password:"
+ '
+ 'lblVerify
+ '
+ Me.lblVerify.AutoSize = True
+ Me.lblVerify.Location = New System.Drawing.Point(82, 51)
+ Me.lblVerify.Name = "lblVerify"
+ Me.lblVerify.Size = New System.Drawing.Size(36, 13)
+ Me.lblVerify.TabIndex = 3
+ Me.lblVerify.Text = "Verify:"
+ '
+ 'btnOK
+ '
+ Me.btnOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.btnOK.Location = New System.Drawing.Point(291, 119)
+ Me.btnOK.Name = "btnOK"
+ Me.btnOK.Size = New System.Drawing.Size(75, 23)
+ Me.btnOK.TabIndex = 7
+ Me.btnOK.Text = Global.mRemoteNG.My.Language.strButtonOK
+ Me.btnOK.UseVisualStyleBackColor = True
+ '
+ 'btnCancel
+ '
+ Me.btnCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
+ Me.btnCancel.Location = New System.Drawing.Point(210, 119)
+ Me.btnCancel.Name = "btnCancel"
+ Me.btnCancel.Size = New System.Drawing.Size(75, 23)
+ Me.btnCancel.TabIndex = 6
+ Me.btnCancel.Text = Global.mRemoteNG.My.Language.strButtonCancel
+ Me.btnCancel.UseVisualStyleBackColor = True
+ '
+ 'lblStatus
+ '
+ Me.lblStatus.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
+ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.lblStatus.ForeColor = System.Drawing.Color.Red
+ Me.lblStatus.Location = New System.Drawing.Point(85, 90)
+ Me.lblStatus.Name = "lblStatus"
+ Me.lblStatus.Size = New System.Drawing.Size(281, 13)
+ Me.lblStatus.TabIndex = 5
+ Me.lblStatus.Text = "Status"
+ Me.lblStatus.TextAlign = System.Drawing.ContentAlignment.TopRight
+ Me.lblStatus.Visible = False
+ '
+ 'pbLock
+ '
+ Me.pbLock.Image = Global.mRemoteNG.My.Resources.Resources.Lock
+ Me.pbLock.Location = New System.Drawing.Point(12, 12)
+ Me.pbLock.Name = "pbLock"
+ Me.pbLock.Size = New System.Drawing.Size(64, 64)
+ Me.pbLock.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
+ Me.pbLock.TabIndex = 7
+ Me.pbLock.TabStop = False
+ '
+ 'txtVerify
+ '
+ Me.txtVerify.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
+ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.txtVerify.Location = New System.Drawing.Point(85, 67)
+ Me.txtVerify.Name = "txtVerify"
+ Me.txtVerify.SelectAllOnFocus = True
+ Me.txtVerify.Size = New System.Drawing.Size(281, 20)
+ Me.txtVerify.TabIndex = 4
+ Me.txtVerify.UseSystemPasswordChar = True
+ '
+ 'txtPassword
+ '
+ Me.txtPassword.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
+ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.txtPassword.Location = New System.Drawing.Point(85, 28)
+ Me.txtPassword.Name = "txtPassword"
+ Me.txtPassword.SelectAllOnFocus = True
+ Me.txtPassword.Size = New System.Drawing.Size(281, 20)
+ Me.txtPassword.TabIndex = 2
+ Me.txtPassword.UseSystemPasswordChar = True
+ '
+ 'frmPassword
+ '
+ Me.AcceptButton = Me.btnOK
+ Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+ Me.CancelButton = Me.btnCancel
+ Me.ClientSize = New System.Drawing.Size(378, 154)
+ Me.ControlBox = False
+ Me.Controls.Add(Me.pbLock)
+ Me.Controls.Add(Me.txtVerify)
+ Me.Controls.Add(Me.txtPassword)
+ Me.Controls.Add(Me.lblStatus)
+ Me.Controls.Add(Me.lblVerify)
+ Me.Controls.Add(Me.lblPassword)
+ Me.Controls.Add(Me.btnCancel)
+ Me.Controls.Add(Me.btnOK)
+ Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
+ Me.MaximizeBox = False
+ Me.MinimizeBox = False
+ Me.Name = "PasswordForm"
+ Me.ShowIcon = False
+ Me.ShowInTaskbar = False
+ Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
+ Me.Text = "Password"
+ CType(Me.pbLock, System.ComponentModel.ISupportInitialize).EndInit()
+ Me.ResumeLayout(False)
+ Me.PerformLayout()
+
+ End Sub
+ Private WithEvents txtPassword As Controls.TextBox
+ Private WithEvents txtVerify As Controls.TextBox
+ Private WithEvents lblPassword As System.Windows.Forms.Label
+ Private WithEvents lblVerify As System.Windows.Forms.Label
+ Private WithEvents btnOK As System.Windows.Forms.Button
+ Private WithEvents btnCancel As System.Windows.Forms.Button
+ Private WithEvents lblStatus As System.Windows.Forms.Label
+ Private WithEvents pbLock As System.Windows.Forms.PictureBox
+ End Class
+End Namespace
@@ -0,0 +1,102 @@
+Imports mRemoteNG.My
+
+Namespace Forms
+ Public Class PasswordForm
+#Region "Public Properties"
+ Public Property Verify As Boolean = True
+
+ Public ReadOnly Property Password As String
+ Get
+ If Verify Then
+ Return txtVerify.Text
+ Else
+ Return txtPassword.Text
+ End If
+ End Get
+ End Property
+#End Region
+
+
+#Region "Constructors"
+ Public Sub New(Optional ByVal passwordName As String = Nothing, Optional ByVal verify As Boolean = True)
+ ' This call is required by the designer.
+ InitializeComponent()
+
+ ' Add any initialization after the InitializeComponent() call.
+ _passwordName = passwordName
+ Me.Verify = verify
+ End Sub
+#End Region
+
+#Region "Event Handlers"
+ Private Sub frmPassword_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
+ ApplyLanguage()
+
+ If Not Verify Then
+ Height = Height - (txtVerify.Top - txtPassword.Top)
+ lblVerify.Visible = False
+ txtVerify.Visible = False
+ End If
+ End Sub
+
+ Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnCancel.Click
+ DialogResult = DialogResult.Cancel
+ End Sub
+
+ Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnOK.Click
+ If Verify Then
+ If VerifyPassword() Then DialogResult = DialogResult.OK
+ Else
+ DialogResult = DialogResult.OK
+ End If
+ End Sub
+
+ Private Sub txtPassword_TextChanged(sender As System.Object, e As EventArgs) Handles txtPassword.TextChanged, txtVerify.TextChanged
+ HideStatus()
+ End Sub
+#End Region
+
+#Region "Private Fields"
+ Private ReadOnly _passwordName As String
+#End Region
+
+#Region "Private Methods"
+ Private Sub ApplyLanguage()
+ If String.IsNullOrEmpty(_passwordName) Then
+ Text = Language.strTitlePassword
+ Else
+ Text = String.Format(Language.strTitlePasswordWithName, _passwordName)
+ End If
+
+ lblPassword.Text = Language.strLabelPassword
+ lblVerify.Text = Language.strLabelVerify
+
+ btnCancel.Text = Language.strButtonCancel
+ btnOK.Text = Language.strButtonOK
+ End Sub
+
+ Private Function VerifyPassword() As Boolean
+ If txtPassword.Text.Length >= 3 Then
+ If txtPassword.Text = txtVerify.Text Then
+ Return True
+ Else
+ ShowStatus(Language.strPasswordStatusMustMatch)
+ Return False
+ End If
+ Else
+ ShowStatus(Language.strPasswordStatusTooShort)
+ Return False
+ End If
+ End Function
+
+ Private Sub ShowStatus(ByVal status As String)
+ lblStatus.Visible = True
+ lblStatus.Text = status
+ End Sub
+
+ Private Sub HideStatus()
+ lblStatus.Visible = False
+ End Sub
+#End Region
+ End Class
+End Namespace
Oops, something went wrong.

0 comments on commit 5d8e7a9

Please sign in to comment.