/// <summary> /// Accept Button Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AcceptButton_Click(object sender, EventArgs e) { string RAName, PassPhraseStr, EncryptionAlgorithm; byte [] CertPublicKey; iFolder ifolder; try { RAName = Request.QueryString.Get("RAName"); //PassPhraseStr = Request.QueryString.Get("PassPhrase"); PassPhraseStr = Session["SessionPassPhrase"] as string; EncryptionAlgorithm = Request.QueryString.Get("EncryptionAlgorithm"); // If there was not any RA selected then RAName and PublicKey will be null if (!RAName.Equals(GetString("NONE"))) { //try getting publickey from current session CertPublicKey = Session["CertPublicKey"] as byte []; string PublicKey = Convert.ToBase64String(CertPublicKey); web.SetPassPhrase(PassPhraseStr, RAName, PublicKey); } else { web.SetPassPhrase(PassPhraseStr, null, null); } // Send the ifolder Name, Description, Security details and the encryption algorithm ifolder = web.CreateiFolder(iFolderName, iFolderDescription, false, EncryptionAlgorithm, PassPhraseStr); Session["SessionPassPhrase"] = PassPhraseStr; // redirect Response.Redirect("Browse.aspx?iFolder=" + ifolder.ID); } catch (SoapException ex) { if (!HandleException(ex)) { Message.Text = ex.Message; AcceptButton.Enabled = false; } return; } }
/// <summary> /// Create Button Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateButton_Click(object sender, EventArgs e) { string name = NewiFolderName.Text.Trim(); string description = NewiFolderDescription.Text.Trim(); string PassPhraseStr = PassPhraseText.Text.Trim(); string VerifyPassPhraseStr = VerifyPassPhraseText.Text.Trim(); string SessionPassPhrase = Session["SessionPassPhrase"] as string; //Validate the inputs if (name.Length == 0) { Message.Text = GetString("IFOLDER.NONAME"); return; } //Very first time this code will be executed if (Encryption.Checked == true && (web.IsPassPhraseSet() == false)) { if ((PassPhraseStr == "" || VerifyPassPhraseStr == "")) { Message.Text = GetString("ENTER_PASSPHRASE"); return; } if ((!PassPhraseStr.Equals(VerifyPassPhraseStr))) { Message.Text = GetString("PASSPHRASE_NOT_MATCH"); VerifyPassPhraseText.Text = ""; return; } } else if (Encryption.Checked == true && PassPhraseStr == "" && SessionPassPhrase == null) { //create encrypted folder and pasphrase is not provided Message.Text = GetString("ENTER_PASSPHRASE"); return; } // create iFolder iFolder ifolder; try { if (Encryption.Checked == true) { EncryptionAlgorithm = "BlowFish"; Sharable = false; //If not avaiable in the session if (SessionPassPhrase == null) { bool PassPhraseSet = web.IsPassPhraseSet(); if (PassPhraseSet) { Status ObjValidate = web.ValidatePassPhrase(PassPhraseStr); if (ObjValidate.statusCode != StatusCodes.Success) { Message.Text = GetString("PASSPHRASE_INCORRECT"); PassPhraseText.Text = ""; return; } else { Session["SessionPassPhrase"] = PassPhraseStr; } } else { //This block will get executed very first time // i am storing the passphrase temporarily in session variable , avoiding passing through URL Session["SessionPassPhrase"] = PassPhraseStr; // Do a utf-8 encoding as there may be multibyte characters in the name UTF8Encoding utf8Name = new UTF8Encoding(); byte[] EncodediFolderNameInByte = utf8Name.GetBytes(name); string iFolderNameBase64 = Convert.ToBase64String(EncodediFolderNameInByte); byte[] EncodediFolderDescInByte = utf8Name.GetBytes(description); string iFolderDescBase64 = Convert.ToBase64String(EncodediFolderDescInByte); if (web.GetRAList() != null) { Response.Redirect(String.Format("iFolderCertificate.aspx?RAName={0}&EncryptionAlgorithm={1}&name={2}&description={3}", RAList.SelectedValue, EncryptionAlgorithm, iFolderNameBase64, iFolderDescBase64)); //SetPassphrase will be done in the redirected page and store in the session } else { //This case should come when no RA is configured by the admin web.SetPassPhrase(PassPhraseStr, null, null); } } } else { PassPhraseStr = Session["SessionPassPhrase"] as string; } } else { PassPhraseStr = null; //if not encrypted then sharable must be true Sharable = true; } //check for no of ifolders per user limit policy if (web.GetiFolderLimitPolicyStatus(null) != 1) { Message.Text = GetString("ERRORIFOLDERLIMITEXCEPTION"); return; } // Send the ifolder Name, Description, Security details and the encryption algorithm ifolder = web.CreateiFolder(name, description, Sharable, EncryptionAlgorithm, PassPhraseStr); if (SessionPassPhrase == null) { Session["SessionPassPhrase"] = PassPhraseStr; } // Redirect to the browser page Response.Redirect("Browse.aspx?iFolder=" + ifolder.ID); } catch (SoapException ex) { if (!HandleException(ex)) { Message.Text = ex.Message; return; } } }