Exemplo n.º 1
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindData()
        {
            string RAName;

            // query
            RAName = Request.QueryString.Get("RAName");

            //proceed only if there is a valid RAName
            if (!RAName.Equals(GetString("NONE")))
            {
                byte [] RACertificateObj = web.GetRACertificate(RAName);

                if (RACertificateObj != null && RACertificateObj.Length != 0)
                {
                    System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
                    CertDetails.Text         = Cert.ToString(true);
                    Session["CertPublicKey"] = Cert.GetPublicKey();
                }
            }
            else
            {
                Message.Text = GetString("NO.RA.SELECTED");
                return;
            }

            // Pass the page information so that it can be added to help link
            Head.AddHelpLink(GetString("CERTIFICATE"));
        }
Exemplo n.º 2
0
        /// <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;
            }
        }