예제 #1
0
        protected void BtnSign_Click(object sender, EventArgs e)
        {
            bool cofirma   = false;
            bool timestamp = false;
            bool convert   = false;

            DigitalSignature.RemoteDigitalSignManager           dsm       = null;
            DigitalSignature.RemoteDigitalSignManager.tipoFirma tipoFirma = DigitalSignature.RemoteDigitalSignManager.tipoFirma.CADES;
            DigitalSignature.RemoteDigitalSignManager.Memento   mem       = null;

            String alias, dominio, pin, otp;

            byte[] fileToSign = null;

            if (!string.IsNullOrEmpty(this.TxtHsmAlias.Text) && !string.IsNullOrEmpty(this.TxtHsmDomain.Text) && !string.IsNullOrEmpty(this.TxtHsmPin.Text) && !string.IsNullOrEmpty(this.TxtHsmLitOtp.Text))
            {
                alias   = this.TxtHsmAlias.Text;
                dominio = this.TxtHsmDomain.Text;
                pin     = this.TxtHsmPin.Text;
                otp     = this.TxtHsmLitOtp.Text;

                dsm       = new DigitalSignature.RemoteDigitalSignManager();
                tipoFirma = new DigitalSignature.RemoteDigitalSignManager.tipoFirma();
                mem       = new DigitalSignature.RemoteDigitalSignManager.Memento {
                    Alias = alias, Dominio = dominio
                };

                try
                {
                    // D.O. 16/11/2016 le seguenti proprità non sono inizializzate in Page_Load (IsPostBack = true)
                    //
                    this.wss          = new ProxyManager().getProxy();
                    this.idIstanza    = Request.QueryString["idIstanza"];
                    this.infoUtente   = ((WSConservazioneLocale.InfoUtente)Session["infoutCons"]);
                    this.infoUtenteWR = GetInfoUtenteWR(infoUtente);

                    dsm.HSM_SetMementoForUser(mem, this.infoUtenteWR);
                    //

                    fileToSign = wss.downloadSignedXml(idIstanza, this.infoUtente);

                    dsm.HSM_SignContent(idIstanza, fileToSign, cofirma, timestamp, tipoFirma, alias, dominio, otp, pin, convert, this.infoUtenteWR);
                }
                catch (System.Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + ex.Message + "', 'warning');} else {parent.ajaxDialogModal('" + ex.Message + "', 'warning');}", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "alert('Inserire tutti i campi obbligatori.';", true);
            }
        }
예제 #2
0
        //richiedo OTP
        protected void BtnRequestOTP_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "reallowOp", "reallowOp();", true);

            DigitalSignature.RemoteDigitalSignManager dsm = new DigitalSignature.RemoteDigitalSignManager();
            if (!string.IsNullOrEmpty(this.TxtHsmAlias.Text) && !string.IsNullOrEmpty(this.TxtHsmDomain.Text))
            {
                string alias   = this.TxtHsmAlias.Text;
                string dominio = this.TxtHsmDomain.Text;

                try
                {
                    DigitalSignature.RemoteDigitalSignManager.Memento m = new DigitalSignature.RemoteDigitalSignManager.Memento {
                        Alias = alias, Dominio = dominio
                    };
                    //Intanto salvo il memento
                    dsm.HSM_SetMementoForUser(m, this.infoUtenteWR);
                }
                catch (System.Exception ex)
                {
                    //UIManager.AdministrationManager.DiagnosticError(ex);
                    return;
                }

                bool retval = false;
                try
                {
                    retval = dsm.HSM_RequestOTP(alias, dominio);
                }
                catch (System.Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('ErrorHsmSignOtp', 'error');} else {parent.ajaxDialogModal('ErrorHsmSignOtp', 'error');}", true);
                    return;
                }


                if (retval)
                {
                    //mandiamo in avviso che informa del successo dell'operazione e che tra pochi secondi riceverà l'opt sul telefonio
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('SuccessHsmRequestOTP', 'check');} else {parent.ajaxDialogModal('SuccessHsmRequestOTP', 'check');}", true);
                }
                else
                {
                    // è accaduto un inconveniente.. l'operazione è fallita.
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('ErrorHsmSignOtp', 'error');} else {parent.ajaxDialogModal('ErrorHsmSignOtp', 'error');}", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('WarningHsmRequestOTPReq', 'warning');} else {parent.ajaxDialogModal('WarningHsmRequestOTPReq', 'warning');}", true);
            }
        }
예제 #3
0
 //andrebbe chiamato all'open della maschera se presenti i dati alias e dominio essi verrano PRE popolati
 private void popolaCampiMemento()
 {
     DigitalSignature.RemoteDigitalSignManager dsm = new DigitalSignature.RemoteDigitalSignManager();
     try
     {
         DigitalSignature.RemoteDigitalSignManager.Memento m = dsm.HSM_GetMementoForUser(this.infoUtenteWR);
         if (m != null)
         {
             this.TxtHsmAlias.Text  = m.Alias;
             this.TxtHsmDomain.Text = m.Dominio;
         }
     }
     catch (System.Exception ex)
     {
         //UIManager.AdministrationManager.DiagnosticError(ex);
         return;
     }
 }