diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index bde4606..eede620 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -4,4 +4,4 @@ jobs: compile: uses: RegioneER/parer-github-template/.github/workflows/compile.yml@v1 with: - java: '8' + java: '11' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b0c6f9..1b47b45 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,4 +11,4 @@ jobs: uses: RegioneER/parer-github-template/.github/workflows/release.yml@v1 with: version: ${{ inputs.version }} - java: '8' + java: '11' diff --git a/pom.xml b/pom.xml index b1461a8..cd6914d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 it.eng.parer client-hsm - 1.0.3-SNAPSHOT + 1.1.1-SNAPSHOT jar Client HSM Modulo per effettuare firma e validazione di documenti firmati interagendo col sistema HSM. @@ -10,12 +10,8 @@ it.eng.parer parer-pom - 4.2.0 + 6.4.1 - - - UTF-8 - @@ -29,7 +25,11 @@ github https://maven.pkg.github.com/RegioneER/parer-framework-parerpom - + + + + UTF-8 + @@ -62,45 +62,61 @@ slf4j-api 1.7.10 + + + + javax.xml.ws + jaxws-api + ${jaxws-api.version} + + + + javax.xml.bind + jaxb-api + ${jaxb.version} + + + + org.jboss.spec + jboss-jakartaee-8.0 + pom + ${jboss-jakartaee-8.0.version} + org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - + maven-compiler-plugin - org.apache.maven.plugins - maven-javadoc-plugin - - - it.eng.hsm.prod.*:it.eng.hsm.test.* - - + org.apache.maven.plugins + maven-javadoc-plugin + + + it.eng.hsm.prod.*:it.eng.hsm.test.* + + - + scm:git:https://github.com/RegioneER/parer-integrazione-hsm.git HEAD - - org.apache.maven.plugins - maven-javadoc-plugin - - - it.eng.hsm.prod.*:it.eng.hsm.test.* - - + + org.apache.maven.plugins + maven-javadoc-plugin + + + it.eng.hsm.prod.*:it.eng.hsm.test.* + + diff --git a/src/main/java/it/eng/hsm/ClientHSM.java b/src/main/java/it/eng/hsm/ClientHSM.java index 4bb492f..c0f876f 100644 --- a/src/main/java/it/eng/hsm/ClientHSM.java +++ b/src/main/java/it/eng/hsm/ClientHSM.java @@ -122,6 +122,8 @@ public byte[] signP7M(HSMSignatureSession session, byte[] fileToSign) * the user who requires the signature * @param fileToSign * file to sign + * @param marcaTemporale + * marca temporale si/no * * @return array di byte del documento XADES firmato * @@ -134,7 +136,7 @@ public byte[] signP7M(HSMSignatureSession session, byte[] fileToSign) * @throws HSMException * if a generic error occurs */ - public byte[] signXAdES(HSMUser user, byte[] fileToSign) + public byte[] signXAdES(HSMUser user, byte[] fileToSign, boolean marcaTemporale) throws AuthenticationException, OTPException, UserBlockedException, HSMException; /** @@ -168,6 +170,8 @@ public byte[] signXAdES(HSMUser user, byte[] fileToSign, ConfigurationXAdES conf * the signature session has to be previously opened * @param fileToSign * file to sign + * @param marcaTemporale + * marca temporale si/no * * @return array di byte del documento XADES firmato * @@ -180,7 +184,7 @@ public byte[] signXAdES(HSMUser user, byte[] fileToSign, ConfigurationXAdES conf * @throws HSMException * if a generic error occurs */ - public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign) + public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign, boolean marcaTemporale) throws AuthenticationException, OTPException, UserBlockedException, HSMException; /** diff --git a/src/main/java/it/eng/hsm/ClientHSM_Prod.java b/src/main/java/it/eng/hsm/ClientHSM_Prod.java index 4571a97..8c32f13 100644 --- a/src/main/java/it/eng/hsm/ClientHSM_Prod.java +++ b/src/main/java/it/eng/hsm/ClientHSM_Prod.java @@ -193,7 +193,12 @@ private byte[] signsP7M(RemoteSignatureCredentials credentials, byte[] fileToSig // private static ConfigurationXAdES getDefaultConfigurationXAdES() { - return new ConfigurationXAdES(XAdES.PROFILES.BES, XAdES.TYPE.DETACHED, XAdES.VALIDATION.T); + // return new ConfigurationXAdES(XAdES.PROFILES.BES, XAdES.TYPE.DETACHED, XAdES.VALIDATION.T); + return new ConfigurationXAdES(XAdES.PROFILES.BES, null, null); + } + + private static ConfigurationXAdES getConfigurationXAdESWithTimestamp() { + return new ConfigurationXAdES(XAdES.PROFILES.BES, null, XAdES.VALIDATION.T); } @Override @@ -208,7 +213,7 @@ public boolean isXAdESActive() { } @Override - public byte[] signXAdES(HSMUser user, byte[] fileToSign) throws HSMException { + public byte[] signXAdES(HSMUser user, byte[] fileToSign, boolean marcaTemporale) throws HSMException { byte[] result = null; @@ -216,7 +221,8 @@ public byte[] signXAdES(HSMUser user, byte[] fileToSign) throws HSMException { throw new IllegalArgumentException(); } - result = signsXAdES(getRemoteSignatureCredentials(user), fileToSign, getDefaultConfigurationXAdES()); + result = signsXAdES(getRemoteSignatureCredentials(user), fileToSign, + marcaTemporale ? getConfigurationXAdESWithTimestamp() : getDefaultConfigurationXAdES()); return result; } @@ -233,7 +239,8 @@ public byte[] signXAdES(HSMUser user, byte[] fileToSign, ConfigurationXAdES conf } @Override - public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign) throws HSMException { + public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign, boolean marcaTemporale) + throws HSMException { byte[] result = null; if (session == null || fileToSign == null) { @@ -241,7 +248,7 @@ public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign) throws H } result = signsXAdES(getRemoteSignatureCredentials(session.getUser()), fileToSign, - getDefaultConfigurationXAdES()); + marcaTemporale ? getConfigurationXAdESWithTimestamp() : getDefaultConfigurationXAdES()); return result; } @@ -276,6 +283,7 @@ private byte[] signsXAdES(RemoteSignatureCredentials credentials, byte[] fileToS } try { + logger.info("Validazione XADES richiesta: {}", params.getValidationData()); signedBytes = client.signXAdES(credentials, fileToSign, Constants.DIGEST_TYPE, null, params); logger.debug("Test HSM - " + credentials.getUserid() + " signed a XAdES file"); } catch (RemoteSignatureExceptionException er) { diff --git a/src/main/java/it/eng/hsm/ClientHSM_Test.java b/src/main/java/it/eng/hsm/ClientHSM_Test.java index a1f05f9..31bbd54 100644 --- a/src/main/java/it/eng/hsm/ClientHSM_Test.java +++ b/src/main/java/it/eng/hsm/ClientHSM_Test.java @@ -192,7 +192,12 @@ private byte[] signsP7M(RemoteSignatureCredentials credentials, byte[] fileToSig // private static ConfigurationXAdES getDefaultConfigurationXAdES() { - return new ConfigurationXAdES(XAdES.PROFILES.BES, XAdES.TYPE.DETACHED, XAdES.VALIDATION.T); + // return new ConfigurationXAdES(XAdES.PROFILES.BES, XAdES.TYPE.DETACHED, XAdES.VALIDATION.T); + return new ConfigurationXAdES(XAdES.PROFILES.BES, null, null); + } + + private static ConfigurationXAdES getConfigurationXAdESWithTimestamp() { + return new ConfigurationXAdES(XAdES.PROFILES.BES, null, XAdES.VALIDATION.T); } @Override @@ -207,7 +212,7 @@ public boolean isXAdESActive() { } @Override - public byte[] signXAdES(HSMUser user, byte[] fileToSign) throws HSMException { + public byte[] signXAdES(HSMUser user, byte[] fileToSign, boolean marcaTemporale) throws HSMException { byte[] result = null; @@ -215,7 +220,8 @@ public byte[] signXAdES(HSMUser user, byte[] fileToSign) throws HSMException { throw new IllegalArgumentException(); } - result = signsXAdES(getRemoteSignatureCredentials(user), fileToSign, getDefaultConfigurationXAdES()); + result = signsXAdES(getRemoteSignatureCredentials(user), fileToSign, + marcaTemporale ? getConfigurationXAdESWithTimestamp() : getDefaultConfigurationXAdES()); return result; } @@ -232,7 +238,8 @@ public byte[] signXAdES(HSMUser user, byte[] fileToSign, ConfigurationXAdES conf } @Override - public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign) throws HSMException { + public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign, boolean marcaTemporale) + throws HSMException { byte[] result = null; if (session == null || fileToSign == null) { @@ -240,7 +247,7 @@ public byte[] signXAdES(HSMSignatureSession session, byte[] fileToSign) throws H } result = signsXAdES(getRemoteSignatureCredentials(session.getUser()), fileToSign, - getDefaultConfigurationXAdES()); + marcaTemporale ? getConfigurationXAdESWithTimestamp() : getDefaultConfigurationXAdES()); return result; } @@ -275,6 +282,7 @@ private byte[] signsXAdES(RemoteSignatureCredentials credentials, byte[] fileToS } try { + logger.info("Validazione XADES richiesta: {}", params.getValidationData()); signedBytes = client.signXAdES(credentials, fileToSign, Constants.DIGEST_TYPE, null, params); logger.debug("Test HSM - " + credentials.getUserid() + " signed a XAdES file"); } catch (RemoteSignatureExceptionException er) { diff --git a/src/main/java/it/eng/hsm/test/itagile/firmaremota/ws/RemoteSignatureXadesParams.java b/src/main/java/it/eng/hsm/test/itagile/firmaremota/ws/RemoteSignatureXadesParams.java index 83736ab..89f2834 100644 --- a/src/main/java/it/eng/hsm/test/itagile/firmaremota/ws/RemoteSignatureXadesParams.java +++ b/src/main/java/it/eng/hsm/test/itagile/firmaremota/ws/RemoteSignatureXadesParams.java @@ -63,7 +63,7 @@ public class RemoteSignatureXadesParams { protected String signatureId; @XmlElement(required = true, nillable = true) protected String type; - @XmlElement(required = true, nillable = true) + @XmlElement(required = true, nillable = false) protected String validationData; /**