Example #1
0
        public OutputResponseMarca getTSR(InputMarca richiesta, InfoUtente utente)
        {
            OutputResponseMarca resultMarca = new OutputResponseMarca();

            //Se l'oggetto infoUtente non รจ valorizzato non eseguo alcuna operazione e restituisco solo
            //il messaggio di errore dell'oggetto OutputResponseMarca
            if (utente == null)
            {
                logger.Debug("InfoUtente nullo o non valido.");
                resultMarca.esito             = "KO";
                resultMarca.descrizioneErrore = "Utente nullo o non autorizzato!";
                return(resultMarca);
            }

            try
            {
                //Scelta del tipo di implementazione per la richiesta della marca temporale
                string typeName = System.Configuration.ConfigurationManager.AppSettings["TYPE_TSA"];

                Type instanceType = Type.GetType(typeName, false);
                if (instanceType == null)
                {
                    throw new ApplicationException(string.Format("Tipo non valido per la configurazione '{0}'", "TYPE_TSA"));
                }

                DocsPa_I_TSAuthority.I_TSR_Request instance = (DocsPa_I_TSAuthority.I_TSR_Request)Activator.CreateInstance(instanceType);

                //ottengo una marca temporale in base alla specifica implementazione settata nel web.config
                resultMarca = instance.getTimeStamp(richiesta);

                //genero l'array di byte per il file p7m e TSR
                byte[] p7m = String_To_Bytes(richiesta.file_p7m);
                byte[] TSR = Convert.FromBase64String(resultMarca.marca);

                //verifico la marca e completo l'oggetto OutputResponseMarca
                resultMarca = VerificaMarca(p7m, TSR);
            }
            catch (Exception eMarca)
            {
                resultMarca.esito             = "KO";
                resultMarca.descrizioneErrore = "richiesta della marca fallita: " + eMarca.Message;
                logger.Debug("richiesta della marca fallita: " + eMarca.Message);
            }

            return(resultMarca);
        }
Example #2
0
        public static DocsPaVO.areaConservazione.OutputResponseMarca executeAndSaveTSR(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.areaConservazione.InputMarca richiesta, DocsPaVO.documento.FileRequest fileRequest)
        {
            // La marca temporale da restituire
            DocsPaVO.areaConservazione.OutputResponseMarca resultMarca = null;

            try
            {
                //Scelta del tipo di implementazione per la richiesta della marca temporale
                string typeName = System.Configuration.ConfigurationManager.AppSettings["TYPE_TSA"];
                logger.Debug("Istanza TYPE_TSA = " + typeName);

                Type instanceType = Type.GetType(typeName, false);
                if (instanceType != null)
                {
                    logger.Debug("Istanza TYPE_TSA = " + typeName + " non nulla");
                    DocsPa_I_TSAuthority.I_TSR_Request instance = (DocsPa_I_TSAuthority.I_TSR_Request)Activator.CreateInstance(instanceType);
                    resultMarca = new DocsPaVO.areaConservazione.OutputResponseMarca();

                    //Ottengo una marca temporale in base alla specifica implementazione settata nel web.config
                    logger.Debug("Richiesta marca temporale");
                    resultMarca = instance.getTimeStamp(richiesta);
                    logger.Debug("Fine richiesta marca temporale");

                    //Genero l'array di byte per il file p7m e TSR
                    byte[] p7m = String_To_Bytes(richiesta.file_p7m);
                    byte[] TSR = Convert.FromBase64String(resultMarca.marca);

                    //Verifico la marca e completo l'oggetto OutputResponseMarca
                    logger.Debug("Verifica marca temporale");
                    resultMarca = VerificaMarca(p7m, TSR);
                    logger.Debug("Fine verifica marca temporale");

                    //Salvo la marca generata sul database
                    using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
                    {
                        try
                        {
                            logger.Debug("Salvataggio TSR");
                            DocsPaDB.Query_DocsPAWS.TimestampDoc timestampDoc = new DocsPaDB.Query_DocsPAWS.TimestampDoc();
                            timestampDoc.saveTSR(infoUtente, resultMarca, fileRequest);
                            transactionContext.Complete();
                            FileManager.processFileInformation(fileRequest, infoUtente);
                            logger.Debug("Fine Salvataggio TSR");
                        }
                        catch (Exception e)
                        {
                            logger.DebugFormat("ERRORE : Salvataggio marca temporale sul database : {0} \r\nstk\r\n{1}" + e.Message, e.StackTrace);
                        }
                    }
                }
                else
                {
                    logger.Debug("Istanza TYPE_TSA = " + typeName + " nulla");
                }
            }
            catch (Exception eMarca)
            {
                logger.DebugFormat("ERRORE : Richiesta marca temporale :{0} \r\nstk{1}\r\n " + eMarca.Message, eMarca.StackTrace);
            }

            return(resultMarca);
        }