Ejemplo n.º 1
0
        /// <summary>
        /// Reperimento dell' HASH sha256 del documento da firmare
        /// </summary>
        /// <param name="page"></param>
        /// <param name="fileRequest"></param>
        /// <returns></returns>
        public string GetSignedDocumentHash(System.Web.UI.Page page, DocsPaWR.FileRequest fileRequest, bool pades)
        {
            DocsPAWA.DocsPaWR.DocsPaWebService ws = DocsPAWA.ProxyManager.getWS();

            DocsPAWA.DocsPaWR.MassSignature msReq = new DocsPaWR.MassSignature {
                fileRequest = fileRequest, signPades = pades
            };
            DocsPAWA.DocsPaWR.MassSignature ms = ws.getSha256(msReq, DocsPAWA.UserManager.getInfoUtente());

            if (ms == null)
            {
                throw new ApplicationException("Attenzione! il file non è visualizzabile.<br><br>Verificare:<br>&bull;&nbsp;l'esistenza del file in:<br>" + fileRequest.docServerLoc + fileRequest.path + fileRequest.fileName + "<br><br>&bull;&nbsp;la stringa di Impronta sulla base dati.");
            }

            return(ms.base64Sha256);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public string GetCoSignDocumentHash(System.Web.UI.Page page)
        {
            DocsPaWR.FileRequest fr = FileManager.getSelectedFile();
            DocsPAWA.DocsPaWR.DocsPaWebService ws = DocsPAWA.ProxyManager.getWS();

            DocsPAWA.DocsPaWR.MassSignature msReq = new DocsPaWR.MassSignature {
                fileRequest = fr, signPades = false, cosign = true
            };
            DocsPAWA.DocsPaWR.MassSignature ms = ws.getSha256(msReq, DocsPAWA.UserManager.getInfoUtente());
            if (ms == null)
            {
                throw new ApplicationException("Attenzione! il file non è visualizzabile.<br><br>Verificare:<br>&bull;&nbsp;l'esistenza del file in:<br>" + fr.docServerLoc + fr.path + fr.fileName + "<br><br>&bull;&nbsp;la stringa di Impronta sulla base dati.");
            }



            return(string.Format("{0}#{1}", ms.base64Sha256, ms.base64Signature));
        }
Ejemplo n.º 3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.Expires = -1;

            if (requestHash)
            {
                DocsPaWR.MassSignature massSignature = UIManager.FileManager.getSelectedMassSignature();
                if (massSignature != null)
                {
                    Response.Write(massSignature.base64Sha256);
                }
                else
                {
                    throw new Exception("UIManager.FileManager.getSelectedMassSignature() in errore.");
                }
            }
            else
            {
                try {
                    DigitalSignature.DigitalSignManager firmaDigitaleMng = new DigitalSignature.DigitalSignManager();

                    NttDataWA.DocsPaWR.FileDocumento fileFirmato = firmaDigitaleMng.GetSignedDocument(this);

                    firmaDigitaleMng = null;

                    if (fileFirmato != null)
                    {
                        Response.BinaryWrite(fileFirmato.content);
                        Response.Flush();
                    }
                }
                catch (System.Exception ex)
                {
                    UIManager.AdministrationManager.DiagnosticError(ex);
                    return;
                }
            }
        }
Ejemplo n.º 4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.Expires = -1;

            string componentType = UIManager.UserManager.getComponentType(Request.UserAgent);

            if (Request.QueryString["idDocumento"] != null)
            {
                idDocument = Request.QueryString["idDocumento"].ToString();
            }

            if (requestHash)
            {
                bool   wantcosign = requestCosign;
                string strResp    = "";

                DocsPaWR.MassSignature massSignature = UIManager.FileManager.getSelectedMassSignature(idDocument);

                if (massSignature != null)
                {
                    strResp = massSignature.base64Sha256;
                    if (!String.IsNullOrEmpty(massSignature.base64Signature))
                    {
                        strResp += string.Format("#{0}", massSignature.base64Signature);
                    }


                    if (componentType == Utils.Constans.TYPE_SMARTCLIENT || componentType == Utils.Constans.TYPE_ACTIVEX)
                    {
                        byte[] byteResp = System.Text.ASCIIEncoding.ASCII.GetBytes(strResp);
                        Response.BinaryWrite(byteResp);
                        Response.Flush();
                    }
                    else
                    {
                        Response.Write(strResp);
                    }
                }
                else
                {
                    Response.Write(null);
                }
            }
            else
            {
                requestType = Request.QueryString["type"];

                SmartClient.FirmaDigitaleMng firmaDigitaleMng = new SmartClient.FirmaDigitaleMng();

                NttDataWA.DocsPaWR.FileDocumento fileFirmato = null;

                if (string.IsNullOrEmpty(idDocument))
                {
                    fileFirmato = firmaDigitaleMng.GetSignedDocument(this);
                }
                else
                {
                    fileFirmato = firmaDigitaleMng.GetSignedDocument(this, idDocument);
                }

                firmaDigitaleMng = null;

                if (fileFirmato != null)
                {
                    if (requestType == "applet")
                    {
                        string base64String = System.Convert.ToBase64String(fileFirmato.content, 0, fileFirmato.content.Length);

                        Response.Write(base64String);
                    }
                    else
                    {
                        Response.BinaryWrite(fileFirmato.content);
                        Response.Flush();
                    }
                }
                else
                {
                    //Response.End();
                    //torno una response NULL, quindi l'fso non salvando nulla dovrebbe tornare null
                    Response.Write(null);
                }
            }
        }
Ejemplo n.º 5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string base64content = string.Empty;

            // Put user code to initialize the page here
            try
            {
                this.startUp();
                this.ErrorPage = "";

                if (Request.QueryString["idDocumento"] != null)
                {
                    idDocument = Request.QueryString["idDocumento"].ToString();
                }

                hashSigned = Request.Form["signedDoc"];
                if (hashSigned == null)
                {
                    byte[] ba = Request.BinaryRead(Request.ContentLength);
                    hashSigned = System.Text.ASCIIEncoding.ASCII.GetString(ba);
                }
                isPades = false;

                string strPades = Request.QueryString["isPades"];
                bool.TryParse(strPades, out isPades);

                DocsPaWR.MassSignature massSignature = UIManager.FileManager.getSelectedMassSignature(idDocument);
                massSignature.base64Signature = hashSigned;
                massSignature.signPades       = isPades;

                DocsPaWR.DocsPaWebService DocsPaWS = ProxyManager.GetWS();
                massSignature = DocsPaWS.signDocument(massSignature, UIManager.UserManager.GetInfoUser());

                FileRequest fr = massSignature.fileRequest;
                UIManager.FileManager.setSelectedFile(fr);
                DocsPaWR.SchedaDocumento schedaDocumento = UIManager.DocumentManager.getSelectedRecord();
                //List<DocsPaWR.Allegato> attachments = new List<DocsPaWR.Allegato>(schedaDocumento.allegati);

                if (schedaDocumento != null)
                {
                    if (schedaDocumento.allegati != null && UIManager.DocumentManager.getSelectedAttachId() != null)
                    {
                        //attachments.Add((Allegato)fr);
                        //schedaDocumento.allegati = attachments.ToArray();
                        int      index = schedaDocumento.allegati.Select((item, i) => new { obj = item, index = i }).First(item => item.obj.versionId.Equals(UIManager.DocumentManager.GetSelectedAttachment().versionId)).index;
                        Allegato a     = new Allegato();
                        a.applicazione          = fr.applicazione;
                        a.daAggiornareFirmatari = fr.daAggiornareFirmatari;
                        a.dataInserimento       = fr.dataInserimento;
                        a.descrizione           = fr.descrizione;
                        a.docNumber             = fr.docNumber;
                        a.docServerLoc          = fr.docServerLoc;
                        a.fileName          = fr.fileName;
                        a.fileSize          = fr.fileSize;
                        a.firmatari         = fr.firmatari;
                        a.firmato           = fr.firmato;
                        a.idPeople          = fr.idPeople;
                        a.path              = fr.path;
                        a.subVersion        = fr.version;
                        a.version           = fr.version;
                        a.versionId         = fr.versionId;
                        a.versionLabel      = schedaDocumento.allegati[index].versionLabel;
                        a.cartaceo          = fr.cartaceo;
                        a.repositoryContext = fr.repositoryContext;
                        a.TypeAttachment    = 1;
                        //a.numeroPagine = (fr as Allegato).numeroPagine;
                        // modifica necessaria per FILENET (A.B.)
                        if ((fr.fNversionId != null) && (fr.fNversionId != ""))
                        {
                            a.fNversionId = fr.fNversionId;
                        }
                        schedaDocumento.allegati[index] = a;

                        UIManager.DocumentManager.setSelectedAttachId(fr.versionId);
                        UIManager.DocumentManager.setSelectedNumberVersion(a.version);
                        //schedaDocumento.allegati = UIManager.DocumentManager.AddAttachment((Allegato)fr);
                    }
                    else
                    {
                        //fr = UIManager.DocumentManager.AddVersion(fr, false);
                        schedaDocumento.documenti = UIManager.DocumentManager.addVersion(schedaDocumento.documenti, (Documento)fr);
                        UIManager.DocumentManager.setSelectedNumberVersion(fr.version);
                    }

                    UIManager.DocumentManager.setSelectedRecord(schedaDocumento);
                }
            }
            catch (Exception es)
            {
                ErrorManager.setError(this, es);
            }
        }
Ejemplo n.º 6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            try
            {
                Utils.startUp(this);
                this.ErrorPage = "";
                this.Button1.Attributes.Add("onclick", "window.close();");

                bool useHash = false;

                string signType = this.Request.QueryString["signType"];
                if (!String.IsNullOrEmpty(signType))
                {
                    if (signType == "P" || signType == "C")
                    {
                        useHash = true;
                    }
                }

                bool   coSign    = false;
                string cosignStr = this.Request.QueryString["tipoFirma"];
                if (!String.IsNullOrEmpty(cosignStr))
                {
                    if (cosignStr.ToLower().Equals("cosign"))
                    {
                        coSign = true;
                    }
                }

                if (Request.QueryString["tipofirma"] != null)
                {
                    if (!Request.QueryString["tipofirma"].Equals(""))
                    {
                        tipofirma = Request.QueryString["tipofirma"];
                    }
                }
                if (tipofirma.Equals("cosign"))
                {
                    firmabool = true;
                }
                else
                {
                    firmabool = false;
                }
                byte[] ba = Request.BinaryRead(Request.ContentLength);
                DocsPaWR.DocsPaWebService DocsPaWS = ProxyManager.getWS();
                DocsPaWR.FileDocumento    fd       = new DocsPAWA.DocsPaWR.FileDocumento();
                //fd.content=ba;

                ASCIIEncoding ae            = new ASCIIEncoding();
                string        base64content = ae.GetString(ba);

                if (UserManager.getBoolDocSalva(this) == null)
                {
                    if (!IsPostBack)
                    {
                        //	string prova=base64content.Replace(base64content.Substring(4,2),"Ds");
                        DocsPaWR.FileRequest fr = FileManager.getSelectedFile(this);

                        if (!string.IsNullOrEmpty(Request.QueryString["signedAsPdf"]))
                        {
                            // Se il file è in formato pdf, viene modificato il nome del file
                            bool signedAsPdf;
                            bool.TryParse(Request.QueryString["signedAsPdf"], out signedAsPdf);
                            if (signedAsPdf)
                            {
                                fr.fileName += ".pdf";
                            }
                        }

                        fr.dataInserimento = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");

                        if (fr.GetType().Equals(typeof(DocsPAWA.DocsPaWR.Allegato)))
                        {
                            // Creazione di un nuovo allegato per il file firmato
                            DocsPaWR.Allegato currentAllegato = (DocsPAWA.DocsPaWR.Allegato)fr;

                            DocsPaWR.Allegato newAllegato = new DocsPAWA.DocsPaWR.Allegato();
                            newAllegato.descrizione       = currentAllegato.descrizione;
                            newAllegato.numeroPagine      = currentAllegato.numeroPagine;
                            newAllegato.fileName          = fr.fileName;
                            newAllegato.firmatari         = currentAllegato.firmatari;
                            newAllegato.docNumber         = currentAllegato.docNumber;
                            newAllegato.version           = "0";
                            newAllegato.repositoryContext = DocumentManager.getDocumentoInLavorazione().repositoryContext;

                            fr = newAllegato;
                        }

                        bool retValue = false;
                        if (!useHash)
                        {
                            retValue = DocsPaWS.AppendDocumentoFirmato(base64content, firmabool, ref fr, UserManager.getInfoUtente(this));
                        }
                        else
                        {
                            bool pades = (signType == "P");
                            DocsPaWR.MassSignature msReq = new DocsPaWR.MassSignature {
                                fileRequest = fr, base64Signature = base64content, signPades = pades, cosign = coSign
                            };
                            DocsPaWR.MassSignature msRet = DocsPaWS.signDocument(msReq, UserManager.getInfoUtente(this));
                            retValue = msRet.result;
                        }

                        if (!retValue)
                        {
                            logger.Error("Errore nel Page_Load (docs = NULL)");
                            throw new Exception();
                        }

                        FileManager.setSelectedFile(this, fr);
                        DocsPaWR.SchedaDocumento schedaDocumento = DocumentManager.getDocumentoSelezionato(this);

                        if (fr.GetType().Equals(typeof(DocsPAWA.DocsPaWR.Allegato)))
                        {
                            schedaDocumento.allegati = DocumentManager.addAllegato(schedaDocumento.allegati, (DocsPAWA.DocsPaWR.Allegato)fr);
                        }
                        else
                        {
                            schedaDocumento.documenti = DocumentManager.addVersione(schedaDocumento.documenti, (DocsPAWA.DocsPaWR.Documento)fr);
                        }

                        DocumentManager.setDocumentoSelezionato(this, schedaDocumento);
                        UserManager.setBoolDocSalva(this, "salvato");
                    }
                }
            }
            catch (Exception es)
            {
                ErrorManager.setError(this, es);
            }
        }