Пример #1
0
        public MainForm()
        {
            ShrewNotifier.OperationLogged         += notifications_OperationLogged;
            ShrewNotifier.ConnectionStatusChanged += notifications_ConnectionStatusChanged;
            UpdateChecker.UpdateAvailable         += updates_UpdateAvailable;
            InitializeComponent();
            ShrewCredentials credentials = null;

            try
            {
                credentials = ShrewConfiguration.LoadCredentials();
            }
            catch (Exception exc)
            {
                MessageBox.Show("Unable to load saved credentials! " + exc.Message, "Error Loading Credentials!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (credentials != null)
            {
                this.usernameTextBox.Text           = credentials.username;
                this.passwordTextBox.Text           = credentials.password;
                this.siteConfigTextBox.Text         = credentials.siteConfigPath;
                this.checkboxConnectOnStart.Checked = credentials.connectOnStart;
                this.checkBoxSave.Checked           = true;
                if (this.checkboxConnectOnStart.Checked)
                {
                    connect();
                    this.WindowState = FormWindowState.Minimized;
                }
            }
            else
            {
                this.checkBoxSave.Checked = false;
            }
        }
Пример #2
0
 public ShrewConnection(ShrewCredentials credentials)
 {
     vpnClient                  = new ShrewClientService(credentials);
     this.shuttingDown          = false;
     this.credentials           = credentials;
     this.failedConnectAttempts = 0;
 }
 public ShrewConnection(ShrewCredentials credentials)
 {
     vpnClient                  = new ShrewClientService(credentials);
     this.networkHost           = GetShrewConfigLine("network-host", credentials.siteConfigPath);
     this.shuttingDown          = false;
     this.failedConnectAttempts = 0;
 }
Пример #4
0
        private void connect()
        {
            if (String.IsNullOrWhiteSpace(this.usernameTextBox.Text) ||
                String.IsNullOrWhiteSpace(this.passwordTextBox.Text) ||
                String.IsNullOrWhiteSpace(this.siteConfigTextBox.Text))
            {
                MessageBox.Show("Site Config Path, Username and Password fields must all be completed before you will be able to connect to your VPN.", "Required Fields", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            statusTextBox.Text   = "";
            connectPanel.Visible = false;
            statusPanel.Visible  = true;

            ShrewCredentials credentials = new ShrewCredentials();

            credentials.username                = this.usernameTextBox.Text;
            credentials.password                = this.passwordTextBox.Text;
            credentials.siteConfigPath          = this.siteConfigTextBox.Text;
            credentials.connectOnStart          = this.checkboxConnectOnStart.Checked;
            credentials.formLogin               = this.formloginTextBox.Text;
            credentials.authenticateOnConnected = this.checkboxAuth.Checked;
            connection = new ShrewConnection(credentials);
            if (checkBoxSave.Checked)
            {
                try
                {
                    ShrewConfiguration.SaveCredentials(credentials);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Unable to save credentials! " + exc.Message, "Error Saving Credentials!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                ShrewConfiguration.DeleteCredentials();
            }
            connection.Connect();
        }