Devin Martin avatar Devin Martin committed f27932c

Oops, forgot some new files

Comments (0)

Files changed (3)

OtpInformation.Designer.cs

+namespace KeeOtp
+{
+    partial class OtpInformation
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.textBoxKey = new System.Windows.Forms.TextBox();
+            this.textBoxStep = new System.Windows.Forms.TextBox();
+            this.radioButtonSix = new System.Windows.Forms.RadioButton();
+            this.labelKey = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.labelSize = new System.Windows.Forms.Label();
+            this.radioButtonEight = new System.Windows.Forms.RadioButton();
+            this.buttonOk = new System.Windows.Forms.Button();
+            this.buttonCancel = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // textBoxKey
+            // 
+            this.textBoxKey.Location = new System.Drawing.Point(31, 31);
+            this.textBoxKey.Name = "textBoxKey";
+            this.textBoxKey.Size = new System.Drawing.Size(231, 20);
+            this.textBoxKey.TabIndex = 0;
+            this.textBoxKey.TextChanged += new System.EventHandler(this.textBoxKey_TextChanged);
+            // 
+            // textBoxStep
+            // 
+            this.textBoxStep.Location = new System.Drawing.Point(140, 65);
+            this.textBoxStep.Name = "textBoxStep";
+            this.textBoxStep.Size = new System.Drawing.Size(23, 20);
+            this.textBoxStep.TabIndex = 1;
+            this.textBoxStep.TextChanged += new System.EventHandler(this.textBoxStep_TextChanged);
+            // 
+            // radioButtonSix
+            // 
+            this.radioButtonSix.AutoSize = true;
+            this.radioButtonSix.Checked = true;
+            this.radioButtonSix.Location = new System.Drawing.Point(140, 101);
+            this.radioButtonSix.Name = "radioButtonSix";
+            this.radioButtonSix.Size = new System.Drawing.Size(60, 17);
+            this.radioButtonSix.TabIndex = 2;
+            this.radioButtonSix.TabStop = true;
+            this.radioButtonSix.Text = "6 Digits";
+            this.radioButtonSix.UseVisualStyleBackColor = true;
+            // 
+            // labelKey
+            // 
+            this.labelKey.AutoSize = true;
+            this.labelKey.Location = new System.Drawing.Point(28, 15);
+            this.labelKey.Name = "labelKey";
+            this.labelKey.Size = new System.Drawing.Size(110, 13);
+            this.labelKey.TabIndex = 3;
+            this.labelKey.Text = "Base32 Encoded Key";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(28, 68);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(106, 13);
+            this.label2.TabIndex = 4;
+            this.label2.Text = "Time Step (Seconds)";
+            // 
+            // labelSize
+            // 
+            this.labelSize.AutoSize = true;
+            this.labelSize.Location = new System.Drawing.Point(79, 101);
+            this.labelSize.Name = "labelSize";
+            this.labelSize.Size = new System.Drawing.Size(55, 13);
+            this.labelSize.TabIndex = 5;
+            this.labelSize.Text = "Code Size";
+            // 
+            // radioButtonEight
+            // 
+            this.radioButtonEight.AutoSize = true;
+            this.radioButtonEight.Location = new System.Drawing.Point(140, 124);
+            this.radioButtonEight.Name = "radioButtonEight";
+            this.radioButtonEight.Size = new System.Drawing.Size(60, 17);
+            this.radioButtonEight.TabIndex = 6;
+            this.radioButtonEight.Text = "8 Digits";
+            this.radioButtonEight.UseVisualStyleBackColor = true;
+            // 
+            // buttonOk
+            // 
+            this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
+            this.buttonOk.Location = new System.Drawing.Point(106, 167);
+            this.buttonOk.Name = "buttonOk";
+            this.buttonOk.Size = new System.Drawing.Size(75, 23);
+            this.buttonOk.TabIndex = 7;
+            this.buttonOk.Text = "OK";
+            this.buttonOk.UseVisualStyleBackColor = true;
+            // 
+            // buttonCancel
+            // 
+            this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+            this.buttonCancel.Location = new System.Drawing.Point(187, 167);
+            this.buttonCancel.Name = "buttonCancel";
+            this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+            this.buttonCancel.TabIndex = 8;
+            this.buttonCancel.Text = "Cancel";
+            this.buttonCancel.UseVisualStyleBackColor = true;
+            // 
+            // OtpInformation
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(274, 202);
+            this.Controls.Add(this.buttonCancel);
+            this.Controls.Add(this.buttonOk);
+            this.Controls.Add(this.radioButtonEight);
+            this.Controls.Add(this.labelSize);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.labelKey);
+            this.Controls.Add(this.radioButtonSix);
+            this.Controls.Add(this.textBoxStep);
+            this.Controls.Add(this.textBoxKey);
+            this.Name = "OtpInformation";
+            this.Text = "OtpInformation";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OtpInformation_FormClosing);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.TextBox textBoxKey;
+        private System.Windows.Forms.TextBox textBoxStep;
+        private System.Windows.Forms.RadioButton radioButtonSix;
+        private System.Windows.Forms.Label labelKey;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label labelSize;
+        private System.Windows.Forms.RadioButton radioButtonEight;
+        private System.Windows.Forms.Button buttonOk;
+        private System.Windows.Forms.Button buttonCancel;
+    }
+}

OtpInformation.cs

+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using OtpSharp;
+
+namespace KeeOtp
+{
+    public partial class OtpInformation : Form
+    {
+        const string validKeyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
+        public OtpAuthData Data { get; set; }
+
+        public OtpInformation()
+        {
+            InitializeComponent();
+            this.Shown += (sender, e) => FormWasShown();
+        }
+
+        private void FormWasShown()
+        {
+            if (this.Data != null)
+            {
+                this.textBoxKey.Text = Base32.Encode(this.Data.Key);
+                this.textBoxStep.Text = this.Data.Step.ToString();
+
+                if (this.Data.Size == 8)
+                {
+                    this.radioButtonSix.Checked = false;
+                    this.radioButtonEight.Checked = true;
+                }
+                else
+                {
+                    this.radioButtonSix.Checked = true;
+                    this.radioButtonEight.Checked = false;
+                }
+            }
+            else
+                this.textBoxStep.Text = "30";
+        }
+
+        private void OtpInformation_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            if (this.DialogResult == System.Windows.Forms.DialogResult.Cancel)
+                return;
+
+            try
+            {
+                if (string.IsNullOrEmpty(this.textBoxKey.Text))
+                {
+                    MessageBox.Show("A key must be set");
+                    e.Cancel = true;
+                    return;
+                }
+
+                if (this.textBoxKey.Text.Length < 8)
+                {
+                    MessageBox.Show("Key must be at least 8 characters.  If you are provided less data then fill it out with '='s");
+                    e.Cancel = true;
+                    return;
+                }
+
+                var size = (this.radioButtonEight.Checked) ? 8 : 6;
+                var step = int.Parse(this.textBoxStep.Text);
+                var key = Base32.Decode(this.textBoxKey.Text);
+
+                this.Data = new OtpAuthData()
+                {
+                    Key = key,
+                    Size = size,
+                    Step = step
+                };
+            }
+            catch
+            {
+                e.Cancel = true;
+            }
+        }
+
+        private void textBoxStep_TextChanged(object sender, EventArgs e)
+        {
+            var text = this.textBoxStep.Text;
+            int value;
+            if (!int.TryParse(text, out value))
+                this.textBoxStep.Text = "30";
+        }
+
+        private void textBoxKey_TextChanged(object sender, EventArgs e)
+        {
+            var unpaddedBase32 = this.textBoxKey.Text.ToUpperInvariant().TrimEnd('=');
+
+            bool invalid = false;
+            foreach (var c in unpaddedBase32)
+            {
+                if (validKeyChars.IndexOf(c) < 0)
+                {
+                    invalid = true;
+                    break;
+                }
+            }
+
+            if (invalid)
+            {
+                if (this.textBoxKey.Text.Length > 1)
+                    this.textBoxKey.Text = this.textBoxKey.Text.Substring(0, this.textBoxKey.Text.Length - 1);
+                else
+                    this.textBoxKey.Text = string.Empty;
+            }
+        }
+    }
+}

OtpInformation.resx

+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.