From 49ebc77424065611c84184dafccdc4beef5375d5 Mon Sep 17 00:00:00 2001 From: "marco.spasiano" Date: Tue, 7 Nov 2023 16:46:00 +0100 Subject: [PATCH] Validating information for digital signature --- ...mministrativiFatturazioneElettronicaAction.java | 1 + .../action/CRUDDistintaCassiere1210Action.java | 2 ++ .../action/CRUDDistintaCassiereAction.java | 2 ++ .../action/FirmaDigitaleDocContAction.java | 1 + .../it/cnr/contab/firma/bulk/FirmaOTPBulk.java | 14 +++++++++++++- .../FirmaDigitaleStampaPdgVariazioneAction.java | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sigla-ejb/src/main/java/it/cnr/contab/docamm00/actions/SelezionatoreDocumentiAmministrativiFatturazioneElettronicaAction.java b/sigla-ejb/src/main/java/it/cnr/contab/docamm00/actions/SelezionatoreDocumentiAmministrativiFatturazioneElettronicaAction.java index 138a1c7d43..54dad5178e 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/docamm00/actions/SelezionatoreDocumentiAmministrativiFatturazioneElettronicaAction.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/docamm00/actions/SelezionatoreDocumentiAmministrativiFatturazioneElettronicaAction.java @@ -90,6 +90,7 @@ public Forward doBackFirmaOTP(ActionContext context) { HookForward caller = (HookForward)context.getCaller(); FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); try { + firmaOTPBulk.validate(); fillModel(context); bulk = (OggettoBulk)bp.getBulkInfo().getBulkClass().newInstance(); bp.setModel(context, bulk); diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiere1210Action.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiere1210Action.java index ac34779ee1..c3def454e5 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiere1210Action.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiere1210Action.java @@ -88,6 +88,7 @@ public Forward doBackInvia(ActionContext context) { CRUDDistintaCassiere1210BP bp = (CRUDDistintaCassiere1210BP)context.getBusinessProcess(); HookForward caller = (HookForward)context.getCaller(); FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); + firmaOTPBulk.validate(); bp.invia(context, firmaOTPBulk); return context.findDefaultForward(); } catch (Exception e ){ @@ -115,6 +116,7 @@ public Forward doBackSign(ActionContext context) { CRUDDistintaCassiere1210BP bp = (CRUDDistintaCassiere1210BP)context.getBusinessProcess(); HookForward caller = (HookForward)context.getCaller(); FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); + firmaOTPBulk.validate(); bp.signDocuments(context, firmaOTPBulk); return super.doSalva(context); } catch (Exception e ){ diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiereAction.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiereAction.java index 02c33a4c28..e7bc674a1e 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiereAction.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/CRUDDistintaCassiereAction.java @@ -227,6 +227,7 @@ public Forward doBackSign(ActionContext context) { FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); try { fillModel(context); + firmaOTPBulk.validate(); bp.invia(context, firmaOTPBulk); } catch (Exception e) { return handleException(context, e); @@ -308,6 +309,7 @@ public Forward doBackInviaSiopeplus(ActionContext context) { FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); try { fillModel(context); + firmaOTPBulk.validate(); bp.inviaSiopeplus(context, firmaOTPBulk); } catch (Exception e) { return handleException(context, e); diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/FirmaDigitaleDocContAction.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/FirmaDigitaleDocContAction.java index ff5ca99070..e887f29768 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/FirmaDigitaleDocContAction.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/action/FirmaDigitaleDocContAction.java @@ -227,6 +227,7 @@ public Forward doBackSign(ActionContext context) { FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); try { fillModel(context); + firmaOTPBulk.validate(); String statoTrasmissione = statoTrasmissioneBulk.getStato_trasmissione(); bulk = (OggettoBulk)bp.getBulkInfo().getBulkClass().newInstance(); statoTrasmissioneBulk = ((StatoTrasmissione)bulk); diff --git a/sigla-ejb/src/main/java/it/cnr/contab/firma/bulk/FirmaOTPBulk.java b/sigla-ejb/src/main/java/it/cnr/contab/firma/bulk/FirmaOTPBulk.java index 03dfc0ad8b..12fc37fe43 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/firma/bulk/FirmaOTPBulk.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/firma/bulk/FirmaOTPBulk.java @@ -18,6 +18,10 @@ package it.cnr.contab.firma.bulk; import it.cnr.jada.bulk.OggettoBulk; +import it.cnr.jada.bulk.ValidationException; + +import javax.swing.text.html.Option; +import java.util.Optional; public class FirmaOTPBulk extends OggettoBulk { private static final long serialVersionUID = 1L; @@ -43,7 +47,15 @@ public String getOtp() { public void setOtp(String otp) { this.otp = otp; } - + + @Override + public void validate() throws ValidationException { + super.validate(); + Optional.ofNullable(userName).orElseThrow(() -> new ValidationException("Valorizzare 'Username'!")); + Optional.ofNullable(password).orElseThrow(() -> new ValidationException("Valorizzare 'password'!")); + Optional.ofNullable(otp).orElseThrow(() -> new ValidationException("Valorizzare 'OTP'!")); + } + public static String errorMessage(String messageException) { if (messageException.contains("0001")) return "Errore generico nel processo di firma"; diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/action/FirmaDigitaleStampaPdgVariazioneAction.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/action/FirmaDigitaleStampaPdgVariazioneAction.java index 1ecb0530e2..d819d44ade 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/action/FirmaDigitaleStampaPdgVariazioneAction.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/action/FirmaDigitaleStampaPdgVariazioneAction.java @@ -113,6 +113,7 @@ public Forward doBackFirmaOTP(ActionContext context) { HookForward caller = (HookForward)context.getCaller(); FirmaOTPBulk firmaOTPBulk = (FirmaOTPBulk) caller.getParameter("firmaOTP"); try { + firmaOTPBulk.validate(); bp.firmaOTP(context, firmaOTPBulk); } catch(Exception e) { return handleException(context,e);