예제 #1
0
        ///<summary>
        /// Display passphrase dialog
        ///</summary>
        ///<param name="path">Path of ifolder</param>
        ///<param name="domain_id">Id of the domain</param>
        ///<param name="encrypted">Enctypred or not</param>
        ///<returns>0 on success else 1</returns>
        private static int ShowPassPhraseDialog(string path, string domain_id, bool encrypted)
        {
            Console.WriteLine(" The corresponding c# file is called");
            if (!encrypted)
            {
                iFolderWeb newiFolder = ifws.CreateiFolderInDomain(path, domain_id);
                if (newiFolder != null)
                {
                    Console.WriteLine("Created iFolder");
                    return(0);
                }
                Console.WriteLine("Error creating iFolder");
                return(1);
            }
            bool passphraseSet = false;

            try
            {
                passphraseSet = simws.IsPassPhraseSet(domain_id);
            }
            catch (Exception ex)
            {
                // Unable to create iFolder. Need to login..
            }
            bool passPhraseEntered = false;

            if (passphraseSet == true)
            {
                bool   rememberOption = simws.GetRememberOption(domain_id);
                string passphrasecheck;
                passphrasecheck = simws.GetPassPhrase(domain_id);
                if (passphrasecheck == null || passphrasecheck == "")
                {
                    passPhraseEntered = ShowVerifyDialog(domain_id, simws);
                }
                else
                {
                    passPhraseEntered = true;
                }
            }
            else
            {
                passPhraseEntered = ShowEnterPassPhraseDialog(domain_id, simws);
            }
            if (passPhraseEntered == true)
            {
                iFolderWeb newiFolder = ifws.CreateiFolderInDomainEncr(path, domain_id, !encrypted, "BlowFish", simws.GetPassPhrase(domain_id));
                if (newiFolder != null)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
//			string[] array = domainController.GetRAList( domain_id);
            return(0);
        }
예제 #2
0
        internal override int ValidatePage(int currentIndex)
        {
            if (ifWebService.GetSecurityPolicy(this.SelectedDomain.ID) == 0)
            {
                MessageBox.Show(TrayApp.Properties.Resources.encryptionNotSet, TrayApp.Properties.Resources.encryptionNotSetHeading, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if (!simiasWebService.IsPassPhraseSet(this.SelectedDomain.ID))
            {
                MessageBox.Show(TrayApp.Properties.Resources.passphraseNotSet, TrayApp.Properties.Resources.passphraseNotSetHeading, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                string RAName = this.ifWebService.GetRAName(SelectedDomain.ID);

                if (RAName != "DEFAULT" && RAName != null)
                {
                    currentIndex = wizard.MaxPages - 8;
                }

                else
                {
                    currentIndex = wizard.MaxPages - 9;
                }

                currentIndex = base.ValidatePage(currentIndex);
            }
            return(currentIndex);
        }
예제 #3
0
 /// <summary>
 /// Update UI
 /// </summary>
 private void UpdateUI()
 {
     if (ifws.GetSecurityPolicy(Domain) != 0 && simws.IsPassPhraseSet(Domain))
     {
         BrowseButton.Sensitive = location.Sensitive = oneTimePassphrase.Sensitive = retypePassPhrase.Sensitive = passPhrase.Sensitive = true;
     }
     else
     {
         BrowseButton.Sensitive = location.Sensitive = oneTimePassphrase.Sensitive = retypePassPhrase.Sensitive = passPhrase.Sensitive = false;
     }
 }
예제 #4
0
 /// <summary>
 /// Update UI
 /// </summary>
 private void UpdateUI()
 {
     if (ifws.GetSecurityPolicy(this.Domain) != 0 && simws.IsPassPhraseSet(this.Domain))
     {
         location.Sensitive = BrowseButton.Sensitive = true;
     }
     else
     {
         location.Sensitive = BrowseButton.Sensitive = false;
     }
 }
예제 #5
0
 /// <summary>
 /// Update UI
 /// </summary>
 private void UpdateUI()
 {
     //check if encryption is enabled or not. If not yet enabled then disable the option to reset the PP.
     if (ifws.GetSecurityPolicy(this.DomainID) != 0 && simws.IsPassPhraseSet(this.DomainID))
     {
         oldPassPhrase.Sensitive = newPassPhrase.Sensitive = retypePassPhrase.Sensitive = recoveryAgentCombo.Sensitive = savePassPhrase.Sensitive = true;
     }
     else
     {
         oldPassPhrase.Sensitive = newPassPhrase.Sensitive = retypePassPhrase.Sensitive = recoveryAgentCombo.Sensitive = savePassPhrase.Sensitive = false;
     }
 }
예제 #6
0
        /// <summary>
        /// Update the User Interface
        /// </summary>
        private void UpdateUI()
        {
            DomainItem domainItem = (DomainItem)this.DomainComboBox.SelectedItem;

            if ((ifWebService.GetSecurityPolicy(domainItem.ID) != 0) && (simiasWebService.IsPassPhraseSet(domainItem.ID)))
            {
                this.filePath.Enabled = this.BrowseButton.Enabled = true;
            }
            else
            {
                this.filePath.Enabled = this.BrowseButton.Enabled = false;
            }
        }
예제 #7
0
 private bool ShowVerifyDialog(string DomainID, SimiasWebService simws)
 {
     bool status = false;
        int result;
        Status passPhraseStatus= null;
        VerifyPassPhraseDialog vpd = new VerifyPassPhraseDialog();
        if (!Util.RegisterModalWindow(vpd))
        {
     vpd.Destroy();
     vpd = null;
     return false;
        }
        try
        {
        do
        {
     result = vpd.Run();
     vpd.Hide();
     if( result == (int)ResponseType.Cancel || result == (int)ResponseType.DeleteEvent)
      break;
     if( result == (int)ResponseType.Ok)
     {
      passPhraseStatus = simws.ValidatePassPhrase(DomainID, vpd.PassPhrase);
     }
     if( passPhraseStatus != null)
     {
      if( passPhraseStatus.statusCode == StatusCodes.PassPhraseInvalid)
      {
       Debug.PrintLine("Invalid Passphrase");
       Debug.PrintLine("Invalid Passphrase");
       iFolderMsgDialog dialog = new iFolderMsgDialog(
        null,
        iFolderMsgDialog.DialogType.Error,
        iFolderMsgDialog.ButtonSet.None,
        Util.GS("Invalid PassPhrase"),
        Util.GS("The PassPhrase entered is invalid"),
        Util.GS("Please re-enter the passphrase"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
        passPhraseStatus = null;
      }
      else if(passPhraseStatus.statusCode == StatusCodes.Success)
       break;
     }
        }while( result != (int)ResponseType.Cancel && result !=(int)ResponseType.DeleteEvent);
        if(result == (int)ResponseType.Cancel || result ==(int)ResponseType.DeleteEvent)
        {
     status = false;
     simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
        }
        else if( passPhraseStatus != null && passPhraseStatus.statusCode == StatusCodes.Success)
        {
     try
     {
      simws.StorePassPhrase( DomainID, vpd.PassPhrase, CredentialType.Basic, vpd.ShouldSavePassPhrase);
      status = simws.IsPassPhraseSet(DomainID);
     }
     catch(Exception) {}
        }
        }
        catch(Exception)
        {
     return false;
        }
        return status;
 }
예제 #8
0
 /// <summary>
 /// Create Default iFolder
 /// </summary>
 /// <param name="shared">true if shared else encryoted</param>
 private iFolderWeb CreateDefaultiFolder(bool shared)
 {
     try
     {
         DirectoryInfo di = new DirectoryInfo(this.LocationEntry.Text);
         di.Create();
     }
     catch (Exception ex)
     {
         // Unable to create the folder
         DisplayErrorMesg(ex);
         return(null);
     }
     if (shared)
     {
         iFolderWeb ifolder = null;
         try
         {
             //ifolder = this.ifws.CreateiFolderInDomain(this.LocationEntry.Text, this.domainInfo.ID);
             ifolder = this.ifws.CreateiFolderInDomainEncr(this.LocationEntry.Text, domainInfo.ID, this.SecureSync.Checked, null, null);
         }
         catch (Exception ex)
         {
             DisplayErrorMesg(ex);
             return(null);
         }
         return(ifolder);
     }
     else
     {
         string algorithm        = "BlowFish";
         bool   passPhraseStatus = false;
         bool   passphraseStatus = false;
         try
         {
             passphraseStatus = simws.IsPassPhraseSet(domainInfo.ID);
         }
         catch (Exception)
         {
             //	MessageBox.Show("Unable to contact the server.");
             return(null);
         }
         if (passphraseStatus == true)
         {
             // if passphrase not given during login
             string passphrasecheck = null;
             passphrasecheck = simws.GetPassPhrase(domainInfo.ID);
             if (passphrasecheck == null || passphrasecheck == "")
             {
                 VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(domainInfo.ID, this.simws);
                 vpd.ShowDialog();
                 passPhraseStatus = vpd.PassphraseStatus;
             }
             else
             {
                 passPhraseStatus = true;
             }
         }
         else
         {
             // Passphrase not enterd at the time of login...
             EnterPassphraseDialog enterPassPhrase = new EnterPassphraseDialog(domainInfo.ID, this.simws, this.ifws);
             enterPassPhrase.ShowDialog();
             passPhraseStatus = enterPassPhrase.PassphraseStatus;
         }
         if (passPhraseStatus == true)
         {
             // check for passphrase existence and display corresponding dialogs.
             string     Passphrase = simws.GetPassPhrase(domainInfo.ID);
             iFolderWeb ifolder    = null;
             try
             {
                 ifolder = this.ifws.CreateiFolderInDomainEncr(this.LocationEntry.Text, domainInfo.ID, this.SecureSync.Checked, algorithm, Passphrase);
             }
             catch (Exception ex)
             {
                 DisplayErrorMesg(ex);
                 return(null);
             }
             return(ifolder);
         }
     }
     return(null);
 }
예제 #9
0
        /// <summary>
        /// Event handler for Domain Login COmpleted
        /// </summary>
        private void OnDomainLoginCompleted(object o, DomainLoginCompletedArgs args)
        {
            if (WaitDialog != null)
            {
                WaitDialog.Hide();
                WaitDialog.Destroy();
                WaitDialog = null;
            }

            Status authStatus = args.AuthenticationStatus;

            if (authStatus != null)
            {
                switch (authStatus.statusCode)
                {
                case StatusCodes.Success:
                case StatusCodes.SuccessInGrace:
                    if (LoginDialog != null)
                    {
                        LoginDialog.Hide();
                        LoginDialog.Destroy();
                        LoginDialog = null;
                    }
                    // Check if any recovery agent present;
                    // if( domainController.GetRAList(args.DomainID) == null)
                    // {
                    // No recovery agent present;
                    //		return;
                    // }
                    ShowClientUpgradeMessageBox();
                    iFolderWebService ifws = DomainController.GetiFolderService();
                    int policy             = ifws.GetSecurityPolicy(args.DomainID);
                    if (policy % 2 == 0)
                    {
                        break;
                    }
                    bool passphraseStatus = simws.IsPassPhraseSet(args.DomainID);
                    if (passphraseStatus == true)
                    {
                        bool rememberOption = simws.GetRememberOption(args.DomainID);
                        if (rememberOption == false)
                        {
                            ShowVerifyDialog(args.DomainID, simws);
                        }
                        else
                        {
                            Debug.PrintLine(" remember Option true. Checking for passphrase existence");
                            string passphrasecheck = simws.GetPassPhrase(args.DomainID);
                            if (passphrasecheck == null || passphrasecheck == "")
                            {
                                Debug.PrintLine("BugBug: Passphrase doesn't exist");
                                ShowVerifyDialog(args.DomainID, simws);
                            }
                        }
                    }
                    else
                    {
                        iFolderWindow.ShowEnterPassPhraseDialog(args.DomainID, simws);
                    }

//						string[] array = domainController.GetRAList( args.DomainID);
                    iFolderData ifdata = iFolderData.GetData();
                    ifdata.Refresh();
                    UpdateWidgetSensitivity();
                    break;

                case StatusCodes.InvalidCertificate:
                    DomainInformation dom = domainController.GetDomain(args.DomainID);
                    if (authStatus.UserName != null)
                    {
                        dom.Host = authStatus.UserName;
                    }
                    byte[] byteArray = simws.GetCertificate(dom.Host);
                    System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);

                    iFolderMsgDialog dialog = new iFolderMsgDialog(
                        null,
                        iFolderMsgDialog.DialogType.Question,
                        iFolderMsgDialog.ButtonSet.YesNo,
                        "",
                        Util.GS("Accept the certificate of this server?"),
                        string.Format(Util.GS("iFolder is unable to verify \"{0}\" as a trusted server.  You should examine this server's identity certificate carefully."), dom.Host),
                        cert.ToString(true));

                    Gdk.Pixbuf certPixbuf = new Gdk.Pixbuf(Util.ImagesPath("ifolder-application-x-x509-ca-cert_48.png"));
                    if (certPixbuf != null && dialog.Image != null)
                    {
                        dialog.Image.Pixbuf = certPixbuf;
                    }

                    int rc = dialog.Run();
                    dialog.Hide();
                    dialog.Destroy();
                    if (rc == -8)                            // User clicked the Yes button
                    {
                        simws.StoreCertificate(byteArray, dom.Host);
                        LoginDialog.Respond(Gtk.ResponseType.Ok);
                    }
                    else
                    {
                        LoginDialog.Respond(Gtk.ResponseType.Cancel);
                    }
                    break;

                case StatusCodes.UserAlreadyMoved:
                    LoginDialog.Respond(Gtk.ResponseType.Ok);
                    break;

                default:
                    Util.ShowLoginError(topLevelWindow, authStatus.statusCode);

                    if (LoginDialog != null)
                    {
                        LoginDialog.Present();
                    }

                    UpdateDomainStatus(args.DomainID);
                    break;
                }
                //UpdateiFolderWindowOnLoginComplete();
            }
            else
            {
                Util.ShowLoginError(topLevelWindow, StatusCodes.Unknown);

                if (LoginDialog != null)
                {
                    LoginDialog.Present();
                }

                UpdateDomainStatus(args.DomainID);
            }

            iFolderWindow ifwin = Util.GetiFolderWindow();

            ifwin.UpdateServerInfoForSelectedDomain();
            ifwin.UpdateListViewItems();
        }