/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); if (!isPdf && !fileReq.firmato.Equals("1")) { this.chkConverti.Checked = true; if (UIManager.FileManager.IsEnabledSupportedFileTypes()) { this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); bool retVal = true; int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant() && e.FileTypeUsed && e.FileTypeSignature); retVal = (count > 0); this.chkConverti.Checked = !retVal; } this.chkPades.Visible = false; } else { this.chkPades.Visible = true; //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } } // this.chkConverti.Enabled = false; if (!signHash) // se non posso firmare con l'HASH allora non posso neanche firmare pades { this.chkPades.Visible = false; } //if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString()).Equals("0")) ScriptManager.RegisterStartupScript(this, this.GetType(), "clickconvertpdf", "$(function() {OnClickConvertPDF();});", true); } else { //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } this.chkConverti.Attributes.Add("onClick", "OnClickConvertPDF();"); } //PDZ - Nuova gestione firma/cofirma //Valore della Chiave FE_SET_TIPO_FIRMA // 0: Annidata // 1: Parallela // 2: Annidata non modificabile // 3: Parallela non modificabile if (fileReq.firmato.Equals("0") || fileReq.tipoFirma == NttDataWA.Utils.TipoFirma.ELETTORNICA) { this.tipoFirmaH.Value = "true"; this.optFirma.Visible = false; this.optCofirma.Visible = false; } string setTipoFirma = string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString())) ? "0" : Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString()); switch (setTipoFirma) { //Annidata default ma modificabile case ("0"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = true; this.optFirma.Enabled = true; break; //Parallela default ma modificabile case ("1"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = true; this.optFirma.Enabled = true; break; //Annidata non modificabile case ("2"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = false; this.optFirma.Enabled = false; break; //Parallela non modificabile case ("3"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = false; this.optFirma.Enabled = false; break; } }
private string CheckSign(SchedaDocumento schedaDoc) { string msgError = string.Empty; FileRequest fileReq = schedaDoc.documenti[0]; bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); string estenxione = FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant(); #region FILE NON ACQUISITO if (string.IsNullOrEmpty(fileReq.fileSize) || int.Parse(fileReq.fileSize) == 0) { msgError = "Il file non risulta acquisito, quindi non è possibile applicare la firma HSM."; return(msgError); } #endregion #region VERIFICA ESTENSIONE DEL FILE if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) || !Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { if (IsEnabledSupportedFileTypes) { int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == estenxione && e.FileTypeUsed && e.FileTypeSignature); bool retVal = (count > 0); if (!retVal) { msgError = "Non è stato possibile firmare il documento. Effettuare la conversione in PDF del file."; return(msgError); } } } #endregion #region VERIFICA DIMENSIONE FILE if (this.MaxDimFileSign > 0 && Convert.ToInt32(schedaDoc.documenti[0].fileSize) > this.MaxDimFileSign) { string maxSize = Convert.ToString(Math.Round((double)this.MaxDimFileSign / 1048576, 3)); msgError = "La dimensione del file supera il limite massimo consentito per la firma. Il limite massimo consentito è: " + maxSize + " Mb."; return(msgError); } #endregion #region DOCUMENTO ANNULLATO if (schedaDoc.protocollo != null && schedaDoc.protocollo.protocolloAnnullato != null && !string.IsNullOrEmpty(schedaDoc.protocollo.protocolloAnnullato.dataAnnullamento)) { msgError = "Il file non è stato firmato in quanto il protocollo risulta annullato."; return(msgError); } #endregion #region DOCUMENTO IN CESTINO if (schedaDoc.inCestino != null && schedaDoc.inCestino == "1") { msgError = "Il file non è stato firmato in quanto il documento è stato rimosso."; return(msgError); } #endregion #region DOCUMENTO CONSOLIDATO if (schedaDoc.ConsolidationState != null && schedaDoc.ConsolidationState.State != DocsPaWR.DocumentConsolidationStateEnum.None) { msgError = "Il file non è stato firmato in quanto il documento è consolidato."; return(msgError); } #endregion #region DOCUMENTO IN CHECKOUT if (schedaDoc.checkOutStatus != null && !string.IsNullOrEmpty(schedaDoc.checkOutStatus.ID)) { msgError = "Il file non è stato firmato in quanto il documento è bloccato."; return(msgError); } #endregion #region DOCUMENTO IN SOLA LETTURA if (Convert.ToInt32(schedaDoc.accessRights) == Convert.ToInt32(HMdiritti.HMdiritti_Read)) { msgError = "Il file non è stato firmato in quanto il documento è in sola lettura."; return(msgError); } #endregion #region DOCUMENTO IN ATTESA DI ACCETTAZIONE if (Convert.ToInt32(schedaDoc.accessRights) == Convert.ToInt32(HMdiritti.HDdiritti_Waiting)) { msgError = "Il file non è stato firmato in quanto il documento è in attesa di accettazione."; return(msgError); } #endregion #region FIRMA PADES //Controllo che il file che stò firmando è un PDF if (this.HsmRadioSign.Checked) { if (!isPdf && this.HsmLitPades.Checked) { msgError = "Non è possibile firmare pades un documento non pdf. Effettuare la conversione in PDF del file"; return(msgError); } } System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileReq.fileName); bool isCadesSign = (fileInfo != null && !String.IsNullOrEmpty(fileInfo.Extension) && fileInfo.Extension.ToLower().Equals(".p7m")); //bool isCadesSign = (!String.IsNullOrEmpty(fileReq.tipoFirma) && fileReq.tipoFirma.Equals(TipoFirma.CADES)) || (fileInfo != null && !String.IsNullOrEmpty(fileInfo.Extension) && fileInfo.Extension.ToLower().Equals(".p7m")); if (this.HsmLitPades.Checked && isCadesSign) { msgError = "Non è possibile applicare una firma PADES su di un file firmato CADES"; return(msgError); } #endregion #region COFIRMA //if (this.HsmRadioCoSign.Checked) //{ ////Non posso cofirmare PADES //if (this.HsmLitPades.Checked) //{ // msgError = "Non è possibile applicare la cofirma PADES su file firmato"; // return msgError; //} // if (this.HsmLitP7M.Checked && (fileReq.tipoFirma == TipoFirma.PADES || fileReq.tipoFirma == TipoFirma.PADES_ELETTORNICA)) //{ //Non posso firmare CADES un file firmato PADES :se l'estensione del file è PDF, il file è stato firmato PADES // msgError = "Non è possibile applicare la cofirma CADES su file firmato PADES"; // return msgError; //} // } #endregion #region VERFICA SE è OBBLIGATORIA LA CONVERSIONE IN PDF DEL FILE if (!isPdf) { if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { if (IsEnabledSupportedFileTypes) { bool retVal = true; int count = this.FileTypes.Count(f => f.FileExtension.ToLowerInvariant() == estenxione && f.FileTypeUsed && f.FileTypeSignature); retVal = (count > 0); if (!retVal) { msgError = "Non è stato possibile firmare il documento. Effettuare la conversione in PDF del file."; return(msgError); } } } } #endregion //MEV LIBRO FIRMA #region TIPO FIRMA DA APPORRE if (!IsLF && fileReq.inLibroFirma) { string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (this.HsmLitP7M.Checked && !typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_CADES)) { msgError = "Documento in Libro firma. La tipologia di firma selezionata non corrisponde a quella richiesta"; return(msgError); } else if (this.HsmLitPades.Checked && !typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { msgError = "Documento in Libro firma. La tipologia di firma selezionata non corrisponde a quella richiesta"; return(msgError); } } #endregion return(msgError); }
private void InitializeKeys() { DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); //if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString()).Equals("0")) //{ // //E' spento il libro firma e quindi rimane la normale gestione della co-firma //} //Modifica condizioni Libro Firma per APSS: se il libro firma è attivo ma è abilitata UNLOCK_COFIRMA ripristino la selezione del tipo firma(firma/cofirma) //else if (!string.IsNullOrEmpty(fileReq.firmato) && fileReq.firmato.Trim() == "1" && // (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.UNLOCK_COFIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.UNLOCK_COFIRMA.ToString()).Equals("0"))) //{ // //E' attivo il libro firma e quindi se è già firmato, appone sempre co-firma // forzaCofirma = true; //} if (!isPdf && !fileReq.firmato.Equals("1")) { this.chkConverti.Checked = true; this.chkConverti.Enabled = false; if (UIManager.FileManager.IsEnabledSupportedFileTypes()) { this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); bool retVal = true; int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant() && e.FileTypeUsed && e.FileTypeSignature); retVal = (count > 0); this.chkConverti.Checked = !retVal; } this.chkPades.Visible = false; } else { this.chkPades.Visible = true; this.chkConverti.Enabled = false; //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } } } if (!signHash) // se non posso firmare con l'HASH allora non posso neanche firmare pades { this.chkPades.Visible = false; } //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } //PDZ - Nuova gestione firma/cofirma //Valore della Chiave FE_SET_TIPO_FIRMA // 0: Annidata // 1: Parallela // 2: Annidata non modificabile // 3: Parallela non modificabile if (fileReq.firmato.Equals("0") || fileReq.tipoFirma == NttDataWA.Utils.TipoFirma.ELETTORNICA) { this.tipoFirmaH.Value = "true"; this.optFirma.Visible = false; this.optCofirma.Visible = false; } string setTipoFirma = string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString())) ? "0" : Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString()); switch (setTipoFirma) { //Annidata default ma modificabile case ("0"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = true; this.optFirma.Enabled = true; break; //Parallela default ma modificabile case ("1"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = true; this.optFirma.Enabled = true; break; //Annidata non modificabile case ("2"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = false; this.optFirma.Enabled = false; break; //Parallela non modificabile case ("3"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = false; this.optFirma.Enabled = false; break; } }
private void InitializePage() { this.popolaCampiMemento(); DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } if (UIManager.UserManager.IsAuthorizedFunctions("TO_GET_OTP")) { this.BtnRequestOTP.Visible = true; } if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); if (!isPdf && !fileReq.firmato.Equals("1")) { this.HsmCheckConvert.Checked = true; if (UIManager.FileManager.IsEnabledSupportedFileTypes()) { this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); bool retVal = true; int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant() && e.FileTypeUsed && e.FileTypeSignature); retVal = (count > 0); //INC000000778865 - PROBLEMA CON MASCHERA DI FIRMA HSM //this.HsmCheckConvert.Checked = retVal; } } this.HsmCheckConvert.Enabled = false; setCofirma(fileReq.firmato == "1" ? true : false); //ABBATANGELI - nuova gestione sign/cosign //MEV LIBRO FIRMA //if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString())) && Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString()).Equals("1")) //{ // this.PnlTypeSign.Visible = false; //} } //se il documento è in libro firma, forzo la selezione al radio button relativo al tipo di firma richiesto if (fileReq.inLibroFirma) { this.HsmLitPades.Enabled = false; this.HsmLitP7M.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.HsmLitPades.Checked = true; this.HsmLitP7M.Checked = false; } else { this.HsmLitPades.Checked = false; this.HsmLitP7M.Checked = true; } } //ABBATANGELI - Nuova gestione firma/cofirma //if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString()).Equals("0")) //Valore della Chiave FE_SET_TIPO_FIRMA // 0: Annidata // 1: Parallela // 2: Annidata non modificabile // 3: Parallela non modificabile string setTipoFirma = string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString())) ? "0" : Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString()); if (setTipoFirma.Equals("0") || setTipoFirma.Equals("2")) { this.optFirma.Checked = true; if (fileReq.firmato.Equals("1")) { bool enabledRadio = setTipoFirma.Equals("0"); this.optCofirma.Enabled = enabledRadio; this.optFirma.Enabled = enabledRadio; } else { this.optCofirma.Enabled = false; this.optFirma.Enabled = false; } } else { if (fileReq.firmato.Equals("1") && !fileReq.tipoFirma.Equals(NttDataWA.Utils.TipoFirma.ELETTORNICA)) { this.optCofirma.Checked = true; bool enabledRadio = setTipoFirma.Equals("1"); this.optCofirma.Enabled = enabledRadio; this.optFirma.Enabled = enabledRadio; } else { this.optFirma.Checked = true; this.optCofirma.Enabled = false; this.optFirma.Enabled = false; } } this.TxtHsmPin.Focus(); }