コード例 #1
0
 public static bool ShowEnterPassPhraseDialog(string DomainID, SimiasWebService simws)
 {
     bool status = false;
      EnterPassPhraseDialog epd = new EnterPassPhraseDialog(DomainID, simws);
       if (!Util.RegisterModalWindow(epd))
      {
       epd.Destroy();
        epd = null;
        return false;
       }
       try
       {
     status = PassphraseHelper( epd, DomainID, simws);
     if( !status )
         return status;
       }
       catch(Exception ex)
       {
     iFolderMsgDialog dialog = new iFolderMsgDialog(
         null,
         iFolderMsgDialog.DialogType.Error,
         iFolderMsgDialog.ButtonSet.None,
         Util.GS("Unable to set the passphrase"),
         Util.GS(ex.Message),
         Util.GS("Please enter the passphrase again"));
     dialog.Run();
     dialog.Hide();
     dialog.Destroy();
     dialog = null;
        return false;
       }
       return status;
 }
コード例 #2
0
 private static bool PassphraseHelper( EnterPassPhraseDialog epd, string DomainID, SimiasWebService simws)
 {
     bool status = false;
       int result;
     do
     {
       result = epd.Run();
      if(result == (int)ResponseType.Cancel || result == (int) ResponseType.DeleteEvent)
      {
         epd.Hide();
       return false;
     }
       if( epd.PassPhrase != epd.RetypedPassPhrase )
       {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
     null,
     iFolderMsgDialog.DialogType.Error,
     iFolderMsgDialog.ButtonSet.None,
     Util.GS("passphrase mismatch"),
     Util.GS("The passphrase and retyped passphrase are not same"),
        Util.GS("Please enter the passphrase again"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
       }
     else
     {
         break;
     }
     }while( result != (int)ResponseType.Cancel );
       if( result != (int)ResponseType.Cancel || result != (int) ResponseType.DeleteEvent)
       {
        string publicKey = null;
        if( epd.RecoveryAgent != null && epd.RecoveryAgent != "Server_Default")
        {
     byte [] RACertificateObj = DomainController.GetDomainController().GetRACertificate(DomainID, epd.RecoveryAgent);
     if( RACertificateObj != null && RACertificateObj.Length != 0)
     {
      System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
      CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
      if (!Util.RegisterModalWindow(dlg))
      {
       dlg.Destroy();
       dlg = null;
       return false;
      }
      int res = dlg.Run();
      dlg.Hide();
      dlg.Destroy();
      dlg = null;
      if( res == (int)ResponseType.Ok)
      {
       publicKey = Convert.ToBase64String(Cert.GetPublicKey());
      }
      else
      {
                 status = false;
           simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
       return ShowEnterPassPhraseDialog(DomainID, simws);
      }
     }
         status = SetPassPhrase( epd, DomainID, publicKey, simws );
         epd.Hide();
         return status;
        }
       else
       {
      DomainInformation domainInfo = (DomainInformation)simws.GetDomainInformation(DomainID);
                 string memberID = domainInfo.MemberUserID;
       iFolderWebService ifWebService = DomainController.GetiFolderService();
      publicKey = ifWebService.GetDefaultServerPublicKey(DomainID,memberID);
                 status = SetPassPhrase(epd,DomainID,publicKey,simws);
                 epd.Hide();
                 return status;
       }
       }
     else
     {
     epd.Hide();
     }
     return true;
 }
コード例 #3
0
 private static bool SetPassPhrase( EnterPassPhraseDialog epd, string DomainID, string publicKey, SimiasWebService simws )
 {
     bool status;
     Status passPhraseStatus = null;
       if(epd.RecoveryAgent != null && epd.RecoveryAgent != Util.GS("Server_Default"))
      passPhraseStatus = simws.SetPassPhrase( DomainID, epd.PassPhrase, epd.RecoveryAgent, publicKey);
      else
        passPhraseStatus = simws.SetPassPhrase( DomainID, epd.PassPhrase, "DEFAULT", publicKey);
     if(passPhraseStatus.statusCode == StatusCodes.Success)
     {
     status = true;
     simws.StorePassPhrase( DomainID, epd.PassPhrase, CredentialType.Basic, epd.ShouldSavePassPhrase);
     }
     else
     {
     status = false;
     iFolderMsgDialog dialog = new iFolderMsgDialog(
         null,
         iFolderMsgDialog.DialogType.Error,
         iFolderMsgDialog.ButtonSet.None,
         Util.GS("Error setting the PassPhrase"),
         Util.GS("Unable to set the passphrase"),
         Util.GS("Please try again"));
     dialog.Run();
     dialog.Hide();
     dialog.Destroy();
     dialog = null;
     }
     return status;
 }
コード例 #4
0
 private static bool PassphraseHelper( EnterPassPhraseDialog epd, string DomainID, SimiasWebService simws)
 {
     bool status = false;
       int result;
     do
     {
       result = epd.Run();
      if(result == (int)ResponseType.Cancel || result == (int) ResponseType.DeleteEvent)
      {
         epd.Hide();
       return false;
     }
       if( epd.PassPhrase != epd.RetypedPassPhrase )
       {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
     null,
     iFolderMsgDialog.DialogType.Error,
     iFolderMsgDialog.ButtonSet.None,
     Util.GS("passphrase mismatch"),
     Util.GS("The passphrase and retyped passphrase are not same"),
        Util.GS("Please enter the passphrase again"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
       }
     else
     {
         break;
     }
     }while( result != (int)ResponseType.Cancel );
       if( result != (int)ResponseType.Cancel || result != (int) ResponseType.DeleteEvent)
       {
        string publicKey = null;
        if( epd.RecoveryAgent != null)
        {
     byte [] RACertificateObj = DomainController.GetDomainController().GetRACertificate(DomainID, epd.RecoveryAgent);
     if( RACertificateObj != null && RACertificateObj.Length != 0)
     {
      System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
      CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
      if (!Util.RegisterModalWindow(dlg))
      {
       dlg.Destroy();
       dlg = null;
       return false;
      }
      int res = dlg.Run();
      dlg.Hide();
      dlg.Destroy();
      dlg = null;
      if( res == (int)ResponseType.Ok)
      {
       publicKey = Convert.ToBase64String(Cert.GetPublicKey());
      }
      else
      {
                 status = false;
           simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
       return ShowEnterPassPhraseDialog(DomainID, simws);
      }
     }
         status = SetPassPhrase( epd, DomainID, publicKey, simws );
         epd.Hide();
         return status;
        }
     else
     {
         iFolderMsgDialog dg = new iFolderMsgDialog(
             epd,
             iFolderMsgDialog.DialogType.Warning,
             iFolderMsgDialog.ButtonSet.YesNo,
             "No Recovery Agent",
             Util.GS("Recovery Agent Not Selected"),
             Util.GS("There is no Recovery Agent selected. Encrypted data cannot be recovered later, if passphrase is lost. Do you want to continue?"));
       int rc = dg.Run();
        dg.Hide();
      dg.Destroy();
         if( (ResponseType)rc == ResponseType.Yes )
         {
             status = SetPassPhrase( epd, DomainID, publicKey, simws );
             epd.Hide();
             return status;
         }
         else
         {
             epd.Hide();
             PassphraseHelper( epd, DomainID, simws );
         }
     }
       }
     else
     {
     epd.Hide();
     }
     return true;
 }